mirror of
https://github.com/TDSCDMAA/AutoMihoyoBBS.git
synced 2026-06-03 02:49:12 +08:00
崩坏2签到支持(copy genshin)
This commit is contained in:
parent
b31fffb91c
commit
cdcd82dac1
@ -14,9 +14,7 @@ def game_id2name(game_id: str) -> str:
|
||||
|
||||
def stop_module(game_id: str) -> None:
|
||||
if game_id == "bh2_cn":
|
||||
# config.honkai2rd_Auto_sign = False
|
||||
# 崩坏2功能敬请期待
|
||||
pass
|
||||
config.config["games"]["cn"]["hokai2"]["auto_checkin"] = False
|
||||
elif game_id == "bh3_cn":
|
||||
config.config["games"]["cn"]["honkai3rd"]["auto_checkin"] = False
|
||||
elif game_id == "nxx_cn":
|
||||
|
||||
70
honkai2.py
70
honkai2.py
@ -13,10 +13,74 @@ class Honkai2:
|
||||
def __init__(self) -> None:
|
||||
self.headers = setting.headers
|
||||
self.headers['DS'] = tools.get_ds(web=True, web_old=True)
|
||||
self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin/bh2/index.html?bbs_auth_required'\
|
||||
f'=true&act_id={setting.honkai2_Act_id}&bbs_presentation_style=fullscreen'\
|
||||
self.headers['Referer'] = 'https://webstatic.mihoyo.com/bbs/event/signin/bh2/index.html?bbs_auth_required' \
|
||||
f'=true&act_id={setting.honkai2_Act_id}&bbs_presentation_style=fullscreen' \
|
||||
'&utm_source=bbs&utm_medium=mys&utm_campaign=icon'
|
||||
self.headers['Cookie'] = config.config["account"]["cookie"]
|
||||
self.headers['x-rpc-device_id'] = tools.get_device_id()
|
||||
self.acc_List = get_account_list("bh2_cn", self.headers)
|
||||
self.account_list = get_account_list("bh2_cn", self.headers)
|
||||
self.sign_day = 0
|
||||
if len(self.account_list) != 0:
|
||||
self.checkin_rewards = self.get_checkin_rewards()
|
||||
|
||||
def get_checkin_rewards(self) -> list:
|
||||
log.info("正在获取签到奖励列表...")
|
||||
req = http.get(setting.honkai2_checkin_rewards, headers=self.headers)
|
||||
data = req.json()
|
||||
if data["retcode"] != 0:
|
||||
log.warning("获取签到奖励列表失败")
|
||||
print(req.text)
|
||||
return data["data"]["awards"]
|
||||
|
||||
# 判断签到
|
||||
def is_sign(self, region: str, uid: str) -> dict:
|
||||
req = http.get(setting.honkai2_Is_signurl.format(setting.honkai2_Act_id, region, uid), headers=self.headers)
|
||||
data = req.json()
|
||||
if data["retcode"] != 0:
|
||||
log.warning("获取账号签到信息失败!")
|
||||
print(req.text)
|
||||
config.config["games"]["cn"]["hokai2"]["auto_checkin"] = False
|
||||
config.save_config()
|
||||
raise CookieError("BBS Cookie Errror")
|
||||
return data["data"]
|
||||
|
||||
# 签到
|
||||
def sign_account(self) -> str:
|
||||
return_data = "崩坏学园2: "
|
||||
if len(self.account_list) != 0:
|
||||
for i in self.account_list:
|
||||
if i[1] in config.config["games"]["cn"]["hokai2"]["black_list"]:
|
||||
continue
|
||||
log.info(f"正在为崩坏2玩家: {i[0]}进行签到...")
|
||||
time.sleep(random.randint(2, 8))
|
||||
is_data = self.is_sign(region=i[2], uid=i[1])
|
||||
if not is_data["is_sub"]: # 这个字段不知道干啥的,就先塞这里了
|
||||
log.warning(f"旅行者{i[0]}是第一次绑定米游社,请先手动签到一次")
|
||||
else:
|
||||
sign_days = is_data["total_sign_day"] - 1
|
||||
ok = True
|
||||
if is_data["is_sign"]:
|
||||
log.info(f"崩坏2玩家:{i[0]}今天已经签到过了~\r\n今天获得的奖励是{tools.get_item(self.checkin_rewards[sign_days])}")
|
||||
sign_days += 1
|
||||
else:
|
||||
time.sleep(random.randint(2, 8))
|
||||
req = http.post(url=setting.honkai2_Sign_url, headers=self.headers,
|
||||
json={'act_id': setting.honkai2_Act_id, 'region': i[2], 'uid': i[1]})
|
||||
data = req.json()
|
||||
if data["retcode"] == 0:
|
||||
log.info(f"崩坏2玩家:{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"崩坏2玩家:{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("账号没有绑定任何崩坏学园2账号!")
|
||||
return_data += "\n并没有绑定任何崩坏学园2账号"
|
||||
return return_data
|
||||
|
||||
21
main.py
21
main.py
@ -3,6 +3,7 @@ import push
|
||||
import login
|
||||
import config
|
||||
import random
|
||||
import honkai2
|
||||
import genshin
|
||||
import setting
|
||||
import mihoyobbs
|
||||
@ -66,21 +67,23 @@ def main():
|
||||
else:
|
||||
return_data += "\n" + "米游社功能未启用!"
|
||||
log.info("米游社功能未启用!")
|
||||
# 崩坏2签到 config这里少了个n,下回config v6的时候再修复吧
|
||||
if config.config["games"]["cn"]["hokai2"]["auto_checkin"]:
|
||||
log.info("正在进行崩坏2签到")
|
||||
honkai2_help = honkai2.Honkai2()
|
||||
return_data += "\n\n" + honkai2_help.sign_account()
|
||||
time.sleep(random.randint(2, 8))
|
||||
# 崩坏3签到
|
||||
if config.config["games"]["cn"]["honkai3rd"]["auto_checkin"]:
|
||||
log.info("正在进行崩坏3签到")
|
||||
honkai3rd_help = honkai3rd.Honkai3rd()
|
||||
return_data += "\n\n" + honkai3rd_help.sign_account()
|
||||
# 原神签到
|
||||
if config.config["games"]["cn"]["genshin"]["auto_checkin"]:
|
||||
log.info("正在进行原神签到")
|
||||
genshin_help = genshin.Genshin()
|
||||
return_data += "\n\n" + genshin_help.sign_account()
|
||||
time.sleep(random.randint(2, 8))
|
||||
else:
|
||||
log.info("原神签到功能未启用!")
|
||||
# 崩坏3签到
|
||||
if config.config["games"]["cn"]["honkai3rd"]["auto_checkin"]:
|
||||
log.info("正在进行崩坏3签到")
|
||||
honkai3rd_help = honkai3rd.Honkai3rd()
|
||||
return_data += "\n\n" + honkai3rd_help.sign_account()
|
||||
else:
|
||||
log.info("崩坏3签到功能未启用!")
|
||||
return 0, return_data
|
||||
elif config.config["account"]["cookie"] == "CookieError":
|
||||
raise CookieError('Cookie expires')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user