diff --git a/config.py b/config.py index 0dbb309..d1710ff 100644 --- a/config.py +++ b/config.py @@ -48,6 +48,9 @@ def load_config(): config = data else: load_v4(data) + log.info("升级v5 config") + # 直接升级到v5 config + save_config() f.close() log.info("Config加载完毕") @@ -58,11 +61,7 @@ def save_config(): log.info("云函数执行,无法保存") return None with open(config_Path, "r+") as f: - data = json.load(f) - data["mihoyobbs_Login_ticket"] = config["account"]["login_ticket"] - data["mihoyobbs_Stuid"] = config["account"]["stuid"] - data["mihoyobbs_Stoken"] = config["account"]["stoken"] - temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': ')) + temp_text = json.dumps(config, sort_keys=False, indent=4, separators=(', ', ': ')) try: f.seek(0) f.truncate() @@ -78,18 +77,18 @@ def save_config(): def clear_cookies(): + global config global serverless if serverless: log.info("云函数执行,无法保存") return None with open(config_Path, "r+") as f: - data = json.load(f) - data["enable_Config"] = False - data["mihoyobbs_Login_ticket"] = "" - data["mihoyobbs_Stuid"] = "" - data["mihoyobbs_Stoken"] = "" - data["mihoyobbs_Cookies"] = "CookieError" - temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': ')) + config["enable"] = False + config["account"]["login_ticket"] = "" + config["account"]["stuid"] = "" + config["account"]["stoken"] = "" + config["account"]["cookie"] = "CookieError" + temp_text = json.dumps(config, sort_keys=False, indent=4, separators=(', ', ': ')) try: f.seek(0) f.truncate() diff --git a/config/config.json.example b/config/config.json.example index f847b83..a342553 100644 --- a/config/config.json.example +++ b/config/config.json.example @@ -1,20 +1,49 @@ { - "enable_Config": true, - "config_Version": 4, - "mihoyobbs_Login_ticket": "", - "mihoyobbs_Stuid": "", - "mihoyobbs_Stoken": "", - "mihoyobbs_Cookies": "", - "mihoyobbs": { - "bbs_Global": true, - "bbs_Signin": true, - "bbs_Signin_multi": true, - "bbs_Signin_multi_list": [2, 5], - "bbs_Read_posts": true, - "bbs_Like_posts": true, - "bbs_Unlike": true, - "bbs_Share": true - }, - "genshin_Auto_sign": true, - "honkai3rd_Auto_sign": false + "enable": false, + "version": 5, + "account": { + "cookie": "", + "login_ticket": "", + "stuid": "", + "stoken": "" + }, + "mihoyobbs": { + "enable": true, + "checkin": true, + "checkin_multi": true, + "checkin_multi_list": [2, 5], + "read_posts": true, + "like_posts": true, + "un_like": true, + "share_post": true + }, + "games": { + "cn": { + "enable": true, + "hokai2": { + "auto_checkin": false, + "black_list": [] + }, + "honkai3rd": { + "auto_checkin": false, + "black_list": [] + }, + "tears_of_themis": { + "auto_checkin": false, + "black_list": [] + }, + "genshin": { + "auto_checkin": false, + "black_list": [] + } + }, + "os": { + "enable": false, + "cookie": "", + "genshin": { + "auto_checkin": false, + "black_list": [] + } + } + } } \ No newline at end of file diff --git a/genshin.py b/genshin.py index a3e974d..401bbe3 100644 --- a/genshin.py +++ b/genshin.py @@ -32,7 +32,7 @@ class Genshin: return data["data"]["awards"] # 判断签到 - def is_sign(self, region: str, uid: str): + def is_sign(self, region: str, uid: str) -> dict: req = http.get(setting.genshin_Is_signurl.format(setting.genshin_Act_id, region, uid), headers=self.headers) data = req.json() if data["retcode"] != 0: @@ -44,7 +44,7 @@ class Genshin: return data["data"] # 签到 - def sign_account(self): + def sign_account(self) -> str: return_data = "原神: " if len(self.acc_List) != 0: for i in self.acc_List: diff --git a/honkai3rd.py b/honkai3rd.py index cecfb4f..ce41a09 100644 --- a/honkai3rd.py +++ b/honkai3rd.py @@ -34,7 +34,7 @@ class Honkai3rd: return raw_data[i] # 签到 - def sign_account(self): + def sign_account(self) -> str: return_data = "崩坏3: " if len(self.acc_List) == 0: log.warning("账号没有绑定任何崩坏3账号!")