游戏部分cookie失效后处理
This commit is contained in:
parent
bc9c05e6d6
commit
2852a27dfe
16
account.py
16
account.py
@ -5,20 +5,6 @@ from loghelper import log
|
||||
from error import CookieError
|
||||
|
||||
|
||||
def stop_module(game_id: str) -> None:
|
||||
if game_id == "bh2_cn":
|
||||
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":
|
||||
config.config["games"]["cn"]["tears_of_themis"]["auto_checkin"] = False
|
||||
elif game_id == "hk4e_cn":
|
||||
config.config["games"]["cn"]["genshin"]["auto_checkin"] = False
|
||||
else:
|
||||
raise NameError
|
||||
config.save_config()
|
||||
|
||||
|
||||
def get_account_list(game_id: str, headers: dict) -> list:
|
||||
log.info(f"正在获取米哈游账号绑定的{setting.game_id2name.get(game_id,game_id)}账号列表...")
|
||||
temp_list = []
|
||||
@ -26,7 +12,7 @@ def get_account_list(game_id: str, headers: dict) -> list:
|
||||
data = req.json()
|
||||
if data["retcode"] != 0:
|
||||
log.warning(f"获取{setting.game_id2name.get(game_id,game_id)}账号列表失败!")
|
||||
stop_module(game_id)
|
||||
config.clear_cookie_game(game_id)
|
||||
raise CookieError("BBS Cookie Error")
|
||||
for i in data["data"]["list"]:
|
||||
temp_list.append([i["nickname"], i["game_uid"], i["region"]])
|
||||
|
13
config.py
13
config.py
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import yaml
|
||||
import setting
|
||||
from loghelper import log
|
||||
|
||||
# 这个字段现在还没找好塞什么地方好,就先塞config这里了
|
||||
@ -115,9 +116,19 @@ def clear_cookies():
|
||||
save_config()
|
||||
|
||||
|
||||
def clear_cookie_game(game_id: str):
|
||||
global config
|
||||
if serverless:
|
||||
log.info("云函数执行,无法保存")
|
||||
return None
|
||||
config["account"]["cookie"] = "GameCookieError"
|
||||
config["games"]["cn"][setting.game_id2config[game_id]]["auto_checkin"] = False
|
||||
log.info(f"游戏签到Cookie已删除")
|
||||
save_config()
|
||||
|
||||
|
||||
def clear_cookie_cloudgame():
|
||||
global config
|
||||
global serverless
|
||||
if serverless:
|
||||
log.info("云函数执行,无法保存")
|
||||
return None
|
||||
|
@ -54,6 +54,13 @@ game_id2name = {
|
||||
"nxx_cn": "未定事件簿",
|
||||
"hk4e_cn": "原神",
|
||||
}
|
||||
|
||||
game_id2config = {
|
||||
"bh2_cn": "hokai2",
|
||||
"bh3_cn": "honkai3rd",
|
||||
"nxx_cn": "tears_of_themis",
|
||||
"hk4e_cn": "genshin",
|
||||
}
|
||||
# Config Load之后run里面进行列表的选择
|
||||
mihoyobbs_List_Use = []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user