diff --git a/cloud_genshin.py b/cloud_genshin.py index ffc3052..8de6f7f 100644 --- a/cloud_genshin.py +++ b/cloud_genshin.py @@ -6,16 +6,16 @@ class CloudGenshin: - def __init__(self) -> None: + def __init__(self, token) -> None: self.headers = { 'Host': 'api-cloudgame.mihoyo.com', 'Accept': '*/*', 'Referer': 'https://app.mihoyo.com', - 'x-rpc-combo_token': config.config['cloud_games']['genshin']['token'], + 'x-rpc-combo_token': token, 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/99.0.4844.84 Safari/537.36', - + } def sign_account(self) -> str: @@ -42,5 +42,15 @@ def sign_account(self) -> str: return ret_msg +def run_task() -> str: + ret_msg = "" + cg_cn = config.config['cloud_games']['cn'] + if cg_cn['genshin'] and cg_cn['genshin']['token'] == "": + return "" + cg_genshin = CloudGenshin(cg_cn['genshin']['token']) + ret_msg += cg_genshin.sign_account() + "\n\n" + return ret_msg + + if __name__ == '__main__': pass diff --git a/config.py b/config.py index d5c4269..081b62b 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,6 @@ import collections import os import yaml -import setting from copy import deepcopy import tools @@ -13,7 +12,7 @@ update_config_need = False config = { - 'enable': True, 'version': 11, + 'enable': True, 'version': 12, "push": "", 'account': {'cookie': '', 'stuid': '', 'stoken': '', 'mid': ''}, 'device': {'name': 'Xiaomi MI 6', 'model': 'Mi 6', 'id': ''}, 'mihoyobbs': { @@ -43,7 +42,14 @@ } }, 'cloud_games': { - "genshin": {'enable': False, 'token': ''} + "cn": { + "enable": False, + "genshin": {'enable': False, 'token': ""} + }, + "os": { + "enable": False, 'lang': 'zh-cn', + "genshin": {'enable': False, 'token': ""} + } }, 'competition': { @@ -66,24 +72,6 @@ def copy_config(): return config_raw -def config_v8_update(data: dict): - global update_config_need - update_config_need = True - returns = deepcopy(config) - returns["enable"] = data["enable"] - returns["account"].update(data["account"]) - returns["mihoyobbs"].update(data["mihoyobbs"]) - returns["cloud_games"].update(data["cloud_games"]) - returns["games"]["os"].update(data["games"]["os"]) - for i in data['games']['cn'].keys(): - if i == "hokai2": - returns['games']['cn']['honkai2'].update(data['games']['cn']['hokai2']) - continue - returns['games']['cn'][i] = data['games']['cn'][i] - log.info("config已升级到: 8") - return returns - - def config_v9_update(data: dict): global update_config_need update_config_need = True @@ -97,7 +85,7 @@ def config_v9_update(data: dict): return data -def config_v9_update_to_v11(data: dict): +def config_v9_update_to_v12(data: dict): global update_config_need update_config_need = True base_config = deepcopy(config_raw) @@ -127,8 +115,10 @@ def config_v9_update_to_v11(data: dict): region_config[item] = {'checkin': item_data['auto_checkin'], 'black_list': item_data['black_list']} else: region_config[item] = item_data - base_config['cloud_games'] = deepcopy(data['cloud_games']) - log.info("config已升级到: 10") + base_config['cloud_games']['cn']['enable'] = data['cloud_games']['genshin']['enable'] + base_config['cloud_games']['cn']['genshin']['enable'] = data['cloud_games']['genshin']['enable'] + base_config['cloud_games']['cn']['genshin']['token'] = data['cloud_games']['genshin']['token'] + log.info("config已升级到: 12") return base_config @@ -145,6 +135,25 @@ def config_v10_update(data: dict): return data +def config_v11_update(data: dict): + global update_config_need + update_config_need = True + data['version'] = 12 + new_config = {} + for key in data: + if key == "account": + new_config["push"] = "" + if key == "cloud_games": + new_config['cloud_games'] = deepcopy(config_raw['cloud_games']) + continue + new_config[key] = deepcopy(data[key]) + new_config['cloud_games']['cn']['enable'] = data['cloud_games']['genshin']['enable'] + new_config['cloud_games']['cn']['genshin']['enable'] = data['cloud_games']['genshin']['enable'] + new_config['cloud_games']['cn']['genshin']['token'] = data['cloud_games']['genshin']['token'] + log.info("config已升级到: 12") + return new_config + + def load_config(p_path=None): global config if not p_path: @@ -152,14 +161,14 @@ def load_config(p_path=None): with open(p_path, "r", encoding='utf-8') as f: data = yaml.load(f, Loader=yaml.FullLoader) if data['version'] != config_raw['version']: - if data['version'] == 7: - data = config_v8_update(data) if data['version'] == 8: data = config_v9_update(data) if data['version'] == 9: - data = config_v9_update_to_v11(data) + data = config_v9_update_to_v12(data) if data['version'] == 10: data = config_v10_update(data) + if data['version'] == 11: + data = config_v11_update(data) save_config(p_config=data) # 去除cookie最末尾的空格 data["account"]["cookie"] = str(data["account"]["cookie"]).rstrip(' ') diff --git a/config/config.yaml.example b/config/config.yaml.example index 579be00..82b1598 100644 --- a/config/config.yaml.example +++ b/config/config.yaml.example @@ -1,7 +1,9 @@ #这里控制整个config文件是否启用 enable: true #config的版本 -version: 11 +version: 12 +# todo功能 +push: "" account: #登入账号只需要修改cookie就行了 cookie: "" @@ -91,13 +93,21 @@ games: #云游戏专区 cloud_games: # 控制整个云游戏的签到 - enable: false - #云原神 - genshin: - #开启签到 + cn: enable: false - #这里填入抓包获得的token - token: "" + #云原神 + genshin: + #开启签到 + enable: false + #这里填入抓包获得的token,支持多个 + token: "" + # os还是todo功能 + os: + lang: "zh-cn" + enable: false + genshin: + enable: false + token: "" competition: enable: false genius_invokation: diff --git a/main.py b/main.py index cd60f25..21aa296 100644 --- a/main.py +++ b/main.py @@ -68,12 +68,9 @@ def main(): if os_result != '': return_data += "\n\n" + "海外版:" + os_result # 云游戏 - if config.config['cloud_games']['genshin']["enable"] \ - and config.config['cloud_games']['genshin']['token'] != "": + if config.config['cloud_games']['cn']["enable"]: log.info("正在进行云原神签到") - cloud_ys = cloud_genshin.CloudGenshin() - data = cloud_ys.sign_account() - return_data += "\n\n" + data + return_data += "\n\n" + cloud_genshin.run_task() if config.config['competition']['enable']: log.info("正在进行米游社竞赛活动签到") competition_result = competition.run_task()