Update honkai3rd.py

This commit is contained in:
齐下无贰 2022-02-02 00:59:27 +08:00 committed by GitHub
parent f9c5ebe5d5
commit 62df3ffe30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,49 +59,45 @@ class Honkai3rd:
if i == int(len(raw_data) - 1) and raw_data[i]["status"] != 0: if i == int(len(raw_data) - 1) and raw_data[i]["status"] != 0:
return raw_data[i] return raw_data[i]
# 判断签到 # 签到
def is_sign(self, region: str, uid: str): def sign_account(self):
req = http.get(setting.honkai3rd_Is_signurl.format(setting.honkai3rd_Act_id, region, uid), headers=self.headers) return_data = "崩坏3"
if len(self.acc_List) == 0:
log.warning("账号没有绑定任何崩坏3账号")
return_data += "\n并没有绑定任何崩坏3账号"
else:
for i in self.acc_List:
log.info(f"正在为舰长 {i[0]} 进行签到...")
req = http.get(setting.honkai3rd_Is_signurl.format(setting.honkai3rd_Act_id, i[2], i[1]), headers=self.headers)
data = req.json() data = req.json()
if data["retcode"] != 0: if data["retcode"] != 0:
log.warning("获取账号签到信息失败!") log.warning("获取账号签到信息失败!")
print(req.text) print(req.text)
exit(1) continue
today_item = self.get_today_item(data["data"]["sign"]["list"]) today_item = self.get_today_item(data["data"]["sign"]["list"])
if today_item["status"] == 1: # 判断是否已经签到
return True if today_item["status"] == 0:
log.info(
f"舰长 {i[0]} 今天已经签到过了~\t已连续签到{self.sign_day}\t今天获得的奖励是{tools.get_item(today_item)}"
)
else: else:
return False
# 签到
def sign_account(self):
return_data = "崩坏3"
if len(self.acc_List) != 0:
for i in self.acc_List:
log.info(f"正在为舰长{i[0]}进行签到...")
time.sleep(random.randint(2, 8))
is_data = self.is_sign(region=i[2], uid=i[1])
if is_data:
time.sleep(random.randint(2, 8)) time.sleep(random.randint(2, 8))
req = http.post(url=setting.honkai3rd_SignUrl, headers=self.headers, req = http.post(url=setting.honkai3rd_SignUrl, headers=self.headers,
json={'act_id': setting.honkai3rd_Act_id, 'region': i[2], 'uid': i[1]}) json={'act_id': setting.honkai3rd_Act_id, 'region': i[2], 'uid': i[1]})
data = req.json() data = req.json()
if data["retcode"] == 0: if data["retcode"] == 0:
today_item = self.get_today_item(data["data"]["list"]) today_item = self.get_today_item(data["data"]["list"])
log.info(f"舰长{i[0]}签到成功~\r\n今天获得的奖励是{tools.get_item(today_item)}") log.info(
f"舰长 {i[0]} 签到成功~\t已连续签到{self.sign_day}\t今天获得的奖励是{tools.get_item(today_item)}"
)
elif data["retcode"] == -5003: elif data["retcode"] == -5003:
# 崩坏3应为奖励列表和签到信息在一起了加上上面已经可以进行了一次判断所以这里旧不重复再次执行判断来获取内容了 log.info(
log.info(f"舰长{i[0]}今天已经签到过了~") f"舰长 {i[0]} 今天已经签到过了~\t已连续签到{self.sign_day}\t今天获得的奖励是{tools.get_item(today_item)}"
)
else: else:
log.warning("账号签到失败!") log.warning("账号签到失败!")
print(req.text) print(req.text)
else:
log.info(f"舰长{i[0]}今天已经签到过了~\r\n今天获得的奖励是{tools.get_item(today_item)}")
if is_data["is_sign"] or data["retcode"] == 0 or data["retcode"] == -5003:
return_data += f"\n{i[0]}已连续签到{self.sign_day}\n今天获得的奖励是{tools.get_item(today_item)}"
else:
return_data += f"\n{i[0]},本次签到失败"
else:
log.warning("账号没有绑定任何崩坏3账号")
return_data += "\n并没有绑定任何崩坏3账号"
return return_data return return_data