config版本更新

This commit is contained in:
Womsxd 2022-08-28 17:30:28 +08:00
parent 0a648d470d
commit f4b2433fd9
No known key found for this signature in database
GPG Key ID: 0FE76418EE689B68
2 changed files with 39 additions and 9 deletions

View File

@ -9,7 +9,7 @@ serverless = False
update_config_need = False update_config_need = False
config = { config = {
'enable': True, 'version': 6, 'enable': True, 'version': 7,
'account': { 'account': {
'cookie': '', 'cookie': '',
'login_ticket': '', 'login_ticket': '',
@ -35,9 +35,11 @@ config = {
'genshin': {'auto_checkin': False, 'black_list': []} 'genshin': {'auto_checkin': False, 'black_list': []}
} }
}, },
'cloud_genshin': { 'cloud_games': {
'token': '', "genshin": {
'enable': False 'enable': False,
'token': ''
}
} }
} }
@ -93,10 +95,24 @@ def update_config():
log.error("请本地更新一下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(): def load_config():
global config global config
with open(config_Path, "r", encoding='utf-8') as f: 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加载完毕") log.info("Config加载完毕")
@ -143,6 +159,18 @@ def clear_cookies():
log.info("Cookie删除完毕") 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__": if __name__ == "__main__":
# 初始化配置文件 # 初始化配置文件
# try: # try:
@ -153,4 +181,5 @@ if __name__ == "__main__":
# pass # pass
# save_config() # save_config()
# update_config() # update_config()
load_config()
pass pass

View File

@ -1,5 +1,5 @@
enable: true #这里控制整个config文件是否启用 enable: true #这里控制整个config文件是否启用
version: 6 #config的版本 version: 7 #config的版本
account: account:
cookie: "" #登入账号只需要修改这里就行了,下面会自动获取 cookie: "" #登入账号只需要修改这里就行了,下面会自动获取
login_ticket: "" login_ticket: ""
@ -39,6 +39,7 @@ games:
genshin: genshin:
auto_checkin: false auto_checkin: false
black_list: [] black_list: []
cloud_genshin: cloud_games: #云游戏专区
token: '' genshin: #云原神
enable: true enable: true #开启签到
token: "" #这里填入抓包获得的token