新增获取用户信息方法

This commit is contained in:
liulong 2024-09-24 16:06:20 +08:00
parent bda28e00ae
commit ab30398389

43
hykb.py
View File

@ -33,6 +33,28 @@ class HaoYouKuaiBao():
"User-Agent": user_agent "User-Agent": user_agent
} }
def user_info(self):
"""
获取用户信息
:return:
"""
url = self.url.format("qdjh", "")
data = {
"ac": "login",
"r": f"0.{random.randint(1000000000000000, 8999999999999999)}",
"scookie": self.cookie,
"device": "kbA25014349F11473F467DC6FF5C89E9D6"
}
try:
response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok':
return {
"user": response["config"]["name"],
"uuid": response["config"]["uuid"]
}
except Exception as e:
print("好游快爆-获取用户信息出现错误:{}".format(e))
def plant(self) -> int: def plant(self) -> int:
"""播种 """播种
""" """
@ -42,16 +64,19 @@ class HaoYouKuaiBao():
response = requests.post(url, headers=self.headers, data=data).json() response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok': if response['key'] == 'ok':
print("好游快爆-播种成功") print("好游快爆-播种成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-播种成功") send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-播种成功")
return 1 return 1
else: else:
if response['seed'] == 0: if response['seed'] == 0:
print("好游快爆-种子已用完") print("好游快爆-种子已用完")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-种子已用完") send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-种子已用完")
return -1 return -1
else: else:
print("好游快爆-播种失败") print("好游快爆-播种失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-播种失败") send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-播种失败")
return 0 return 0
except Exception as e: except Exception as e:
print(f"好游快爆-播种出现错误:{e}") print(f"好游快爆-播种出现错误:{e}")
@ -66,11 +91,13 @@ class HaoYouKuaiBao():
response = requests.post(url, headers=self.headers, data=data).json() response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok': if response['key'] == 'ok':
print("好游快爆-收获成功") print("好游快爆-收获成功")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-收获成功") send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-收获成功")
return True return True
else: else:
print("好游快爆-收获失败") print("好游快爆-收获失败")
send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), "好游快爆-收获失败") send_notification_message("好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
"好游快爆-收获失败")
return False return False
except Exception as e: except Exception as e:
print(f"好游快爆-收获出现错误:{e}") print(f"好游快爆-收获出现错误:{e}")
@ -100,11 +127,13 @@ class HaoYouKuaiBao():
response = requests.post(url, headers=self.headers, data=data).json() response = requests.post(url, headers=self.headers, data=data).json()
if response['key'] == 'ok': if response['key'] == 'ok':
print("好游快爆-浇水成功") print("好游快爆-浇水成功")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), content="好游快爆-浇水成功") send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content="好游快爆-浇水成功")
return 1, response['add_baomihua'] return 1, response['add_baomihua']
elif response['key'] == '1001': elif response['key'] == '1001':
print("好游快爆-今日已浇水") print("好游快爆-今日已浇水")
send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"), content="好游快爆-今日已浇水") send_notification_message(title="好游快爆签到通知 - " + datetime.now().strftime("%Y/%m/%d"),
content="好游快爆-今日已浇水")
return 0, 0 return 0, 0
else: else:
print("好游快爆-浇水出现错误:{}".format(response)) print("好游快爆-浇水出现错误:{}".format(response))