开始使用v5 config

This commit is contained in:
Womsxd 2022-04-30 09:00:07 +08:00
parent 2388fba65d
commit 884ddcd5f8
No known key found for this signature in database
GPG Key ID: 0FE76418EE689B68
4 changed files with 61 additions and 33 deletions

View File

@ -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()

View File

@ -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
"enable": false,
"version": 5,
"account": {
"cookie": "",
"login_ticket": "",
"stuid": "",
"stoken": ""
},
"genshin_Auto_sign": true,
"honkai3rd_Auto_sign": false
"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": []
}
}
}
}

View File

@ -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:

View File

@ -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账号")