崩坏3签到改版修复
This commit is contained in:
parent
ec2a8cdefc
commit
9b2cc0bb5d
107
honkai3rd.py
107
honkai3rd.py
@ -5,6 +5,7 @@ import random
|
|||||||
import setting
|
import setting
|
||||||
from request import http
|
from request import http
|
||||||
from loghelper import log
|
from loghelper import log
|
||||||
|
from error import CookieError
|
||||||
from account import get_account_list
|
from account import get_account_list
|
||||||
|
|
||||||
|
|
||||||
@ -12,67 +13,75 @@ class Honkai3rd:
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.headers = setting.headers
|
self.headers = setting.headers
|
||||||
self.headers['DS'] = tools.get_ds(web=True, web_old=True)
|
self.headers['DS'] = tools.get_ds(web=True, web_old=True)
|
||||||
self.headers['Referer'] = 'https://webstatic.mihoyo.com/bh3/event/euthenia/index.html?bbs_presentation_style' \
|
self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin/bh3/index.html?bbs_auth_required' \
|
||||||
'=fullscreen&bbs_game_role_required=bh3_cn&bbs_auth_required=true&act_id=' \
|
f'=true&act_id={setting.honkai3rd_Act_id}&bbs_presentation_style=fullscreen' \
|
||||||
f'{setting.honkai3rd_Act_id}&utm_source=bbs&utm_medium=mys&utm_campaign=icon'
|
'&utm_source=bbs&utm_medium=mys&utm_campaign=icon'
|
||||||
self.headers['Cookie'] = config.config["account"]["cookie"]
|
self.headers['Cookie'] = config.config["account"]["cookie"]
|
||||||
self.headers['x-rpc-device_id'] = tools.get_device_id()
|
self.headers['x-rpc-device_id'] = tools.get_device_id()
|
||||||
self.account_list = get_account_list("bh3_cn", self.headers)
|
self.account_list = get_account_list("bh3_cn", self.headers)
|
||||||
self.sign_day = 0
|
self.sign_day = 0
|
||||||
|
if len(self.account_list) != 0:
|
||||||
|
self.checkin_rewards = self.get_checkin_rewards()
|
||||||
|
|
||||||
# 获取今天已经签到了的dict
|
def get_checkin_rewards(self) -> list:
|
||||||
def get_today_item(self, raw_data: list):
|
log.info("正在获取签到奖励列表...")
|
||||||
# 用range进行循环,当status等于0的时候上一个就是今天签到的dict
|
req = http.get(setting.honkai3rd_checkin_rewards, headers=self.headers)
|
||||||
for i in range(len(raw_data)):
|
data = req.json()
|
||||||
if raw_data[i]["status"] == 0:
|
if data["retcode"] != 0:
|
||||||
self.sign_day = i - 1
|
log.warning("获取签到奖励列表失败")
|
||||||
return raw_data[i - 1]
|
print(req.text)
|
||||||
self.sign_day = i
|
return data["data"]["awards"]
|
||||||
if raw_data[i]["status"] == 1:
|
|
||||||
return raw_data[i]
|
# 判断签到
|
||||||
if i == int(len(raw_data) - 1) and raw_data[i]["status"] != 0:
|
def is_sign(self, region: str, uid: str) -> dict:
|
||||||
return raw_data[i]
|
req = http.get(setting.honkai3rd_Is_signurl.format(setting.honkai3rd_Act_id, region, uid), headers=self.headers)
|
||||||
|
data = req.json()
|
||||||
|
if data["retcode"] != 0:
|
||||||
|
log.warning("获取账号签到信息失败!")
|
||||||
|
print(req.text)
|
||||||
|
config.config["games"]["cn"]["honkai3rd"]["auto_checkin"] = False
|
||||||
|
config.save_config()
|
||||||
|
raise CookieError("BBS Cookie Errror")
|
||||||
|
return data["data"]
|
||||||
|
|
||||||
# 签到
|
# 签到
|
||||||
def sign_account(self) -> str:
|
def sign_account(self) -> str:
|
||||||
return_data = "崩坏3: "
|
return_data = "崩坏3: "
|
||||||
if len(self.account_list) == 0:
|
if len(self.account_list) != 0:
|
||||||
log.warning("账号没有绑定任何崩坏3账号!")
|
|
||||||
return_data += "\n并没有绑定任何崩坏3账号"
|
|
||||||
else:
|
|
||||||
for i in self.account_list:
|
for i in self.account_list:
|
||||||
if i[1] in config.config["games"]["cn"]["honkai3rd"]["black_list"]:
|
if i[1] in config.config["games"]["cn"]["honkai3rd"]["black_list"]:
|
||||||
continue
|
continue
|
||||||
log.info(f"正在为舰长 {i[0]} 进行签到...")
|
log.info(f"正在为舰长: {i[0]}进行签到哦...")
|
||||||
req = http.get(setting.honkai3rd_Is_signurl.format(setting.honkai3rd_Act_id, i[2], i[1]),
|
time.sleep(random.randint(2, 8))
|
||||||
headers=self.headers)
|
is_data = self.is_sign(region=i[2], uid=i[1])
|
||||||
data = req.json()
|
# if not is_data["is_sub"]: # 这个字段不知道干啥的,就先塞这里了
|
||||||
re_message = ""
|
if False: # 算了先改成false
|
||||||
if data["retcode"] != 0:
|
log.warning(f"旅行者{i[0]}是第一次绑定米游社,请先手动签到一次")
|
||||||
re_message = f"舰长 {i[0]} 获取账号签到信息失败!"
|
|
||||||
log.warning(re_message)
|
|
||||||
print(req.text)
|
|
||||||
continue
|
|
||||||
today_item = self.get_today_item(data["data"]["sign"]["list"])
|
|
||||||
# 判断是否已经签到
|
|
||||||
if today_item["status"] == 0:
|
|
||||||
re_message = f"舰长 {i[0]} 今天已经签到过了~\t已连续签到{self.sign_day + 1}天\t今天获得的奖励是{tools.get_item(today_item)}"
|
|
||||||
log.info(re_message)
|
|
||||||
else:
|
else:
|
||||||
time.sleep(random.randint(2, 8))
|
sign_days = is_data["total_sign_day"] - 1
|
||||||
req = http.post(url=setting.honkai3rd_SignUrl, headers=self.headers,
|
ok = True
|
||||||
json={'act_id': setting.honkai3rd_Act_id, 'region': i[2], 'uid': i[1]})
|
if is_data["is_sign"]:
|
||||||
data = req.json()
|
log.info(f"舰长:{i[0]}今天已经签到过了~\r\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days])}")
|
||||||
if data["retcode"] == 0:
|
sign_days += 1
|
||||||
today_item = self.get_today_item(data["data"]["list"])
|
|
||||||
re_message = f"舰长 {i[0]} 签到成功~\t已连续签到{self.sign_day + 2}天\t今天获得的奖励是{tools.get_item(today_item)}"
|
|
||||||
log.info(re_message)
|
|
||||||
elif data["retcode"] == -5003:
|
|
||||||
re_message = f"舰长 {i[0]} 今天已经签到过了~\t已连续签到{self.sign_day + 1}天\t今天获得的奖励是{tools.get_item(today_item)}"
|
|
||||||
log.info(re_message)
|
|
||||||
else:
|
else:
|
||||||
re_message = f"舰长 {i[0]} 本次签到失败!"
|
time.sleep(random.randint(2, 8))
|
||||||
log.warning(re_message)
|
req = http.post(url=setting.honkai3rd_Sign_url, headers=self.headers,
|
||||||
print(req.text)
|
json={'act_id': setting.honkai3rd_Act_id, 'region': i[2], 'uid': i[1]})
|
||||||
return_data += "\r\n" + re_message
|
data = req.json()
|
||||||
|
if data["retcode"] == 0:
|
||||||
|
log.info(f"舰长:{i[0]}签到成功~\r\n今天获得的奖励是"
|
||||||
|
f"{tools.get_item(self.checkin_rewards[0 if sign_days == 0 else sign_days + 1])}")
|
||||||
|
sign_days += 2
|
||||||
|
elif data["retcode"] == -5003:
|
||||||
|
log.info(f"舰长:{i[0]}今天已经签到过了~\r\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days])}")
|
||||||
|
else:
|
||||||
|
log.warning("账号签到失败!")
|
||||||
|
ok = False
|
||||||
|
if ok:
|
||||||
|
return_data += f"\n{i[0]}已连续签到{sign_days}天\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days - 1])}"
|
||||||
|
else:
|
||||||
|
return_data += f"\n{i[0]},本次签到失败"
|
||||||
|
else:
|
||||||
|
log.warning("账号没有绑定任何崩坏3账号!")
|
||||||
|
return_data += "\n并没有绑定任何崩坏3账号"
|
||||||
return return_data
|
return return_data
|
||||||
|
Loading…
Reference in New Issue
Block a user