From f4b2433fd9e1074a45dd42633f96fa61c052a9e8 Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Sun, 28 Aug 2022 17:30:28 +0800 Subject: [PATCH] =?UTF-8?q?config=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 39 +++++++++++++++++++++++++++++++++----- config/config.yaml.example | 9 +++++---- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/config.py b/config.py index b0f04cf..aa23d14 100644 --- a/config.py +++ b/config.py @@ -9,7 +9,7 @@ serverless = False update_config_need = False config = { - 'enable': True, 'version': 6, + 'enable': True, 'version': 7, 'account': { 'cookie': '', 'login_ticket': '', @@ -35,9 +35,11 @@ config = { 'genshin': {'auto_checkin': False, 'black_list': []} } }, - 'cloud_genshin': { - 'token': '', - 'enable': False + 'cloud_games': { + "genshin": { + 'enable': False, + 'token': '' + } } } @@ -93,10 +95,24 @@ def update_config(): log.error("请本地更新一下config") +def config_v7_update(data: dict): + global update_config_need + update_config_need = True + data['version'] = 7 + data['cloud_games'] = {"genshin": {'enable': False, 'token': ''}} + log.info("config已升级到: 7") + return data + + def load_config(): global config with open(config_Path, "r", encoding='utf-8') as f: - config = yaml.load(f, Loader=yaml.FullLoader) + data = yaml.load(f, Loader=yaml.FullLoader) + if data['version'] == 7: + config = data + else: + config = config_v7_update(data) + save_config() log.info("Config加载完毕") @@ -143,6 +159,18 @@ def clear_cookies(): log.info("Cookie删除完毕") +def clear_cookie_cloudgame(): + global config + global serverless + if serverless: + log.info("云函数执行,无法保存") + return None + config['cloud_games']['genshin']["enable"] = False + config['cloud_games']['genshin']['token'] = "" + log.info("云原神Cookie删除完毕") + save_config() + + if __name__ == "__main__": # 初始化配置文件 # try: @@ -153,4 +181,5 @@ if __name__ == "__main__": # pass # save_config() # update_config() + load_config() pass diff --git a/config/config.yaml.example b/config/config.yaml.example index abc3efe..a29e814 100644 --- a/config/config.yaml.example +++ b/config/config.yaml.example @@ -1,5 +1,5 @@ enable: true #这里控制整个config文件是否启用 -version: 6 #config的版本 +version: 7 #config的版本 account: cookie: "" #登入账号只需要修改这里就行了,下面会自动获取 login_ticket: "" @@ -39,6 +39,7 @@ games: genshin: auto_checkin: false black_list: [] -cloud_genshin: - token: '' - enable: true \ No newline at end of file +cloud_games: #云游戏专区 + genshin: #云原神 + enable: true #开启签到 + token: "" #这里填入抓包获得的token