清理代码

This commit is contained in:
Womsxd 2022-06-24 10:13:29 +08:00
parent 642ca8a0b5
commit 76048a8149
No known key found for this signature in database
GPG Key ID: 0FE76418EE689B68

View File

@ -5,13 +5,6 @@ from loghelper import log
from error import CookieError
def game_id2name(game_id: str) -> str:
try:
return setting.game_id2name[game_id]
except NameError:
return game_id
def stop_module(game_id: str) -> None:
if game_id == "bh2_cn":
config.config["games"]["cn"]["hokai2"]["auto_checkin"] = False
@ -27,15 +20,15 @@ def stop_module(game_id: str) -> None:
def get_account_list(game_id: str, headers: dict) -> list:
log.info(f"正在获取米哈游账号绑定的{game_id2name(game_id)}账号列表...")
log.info(f"正在获取米哈游账号绑定的{setting.game_id2name.get(game_id,game_id)}账号列表...")
temp_list = []
req = http.get(setting.account_Info_url + game_id, headers=headers)
data = req.json()
if data["retcode"] != 0:
log.warning(f"获取{game_id2name(game_id)}账号列表失败!")
log.warning(f"获取{setting.game_id2name.get(game_id,game_id)}账号列表失败!")
stop_module(game_id)
raise CookieError("BBS Cookie Error")
for i in data["data"]["list"]:
temp_list.append([i["nickname"], i["game_uid"], i["region"]])
log.info(f"已获取到{len(temp_list)}{game_id2name(game_id)}账号信息")
log.info(f"已获取到{len(temp_list)}{setting.game_id2name.get(game_id,game_id)}账号信息")
return temp_list