2021-05-23 13:24:20 +00:00
|
|
|
|
import os
|
|
|
|
|
import json
|
2022-01-06 05:49:25 +00:00
|
|
|
|
from loghelper import log
|
2021-05-23 13:24:20 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 是否启用config
|
2022-04-26 07:49:55 +00:00
|
|
|
|
enable = True
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 这里的内容会自动获取
|
2022-04-26 07:49:55 +00:00
|
|
|
|
login_ticket = ""
|
|
|
|
|
stuid = ""
|
|
|
|
|
stoken = ""
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 这里是米游社的cookie
|
2022-04-26 07:49:55 +00:00
|
|
|
|
cookies = ""
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 这个dist里面的内容和米游社有关
|
2021-05-23 13:24:20 +00:00
|
|
|
|
mihoyobbs = {
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 全局开关,关闭之后下面的都不执行
|
2021-06-06 13:31:46 +00:00
|
|
|
|
"bbs_Global": True,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 讨论区签到
|
2021-08-03 02:35:55 +00:00
|
|
|
|
"bbs_Signin": True,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 多个讨论区签到
|
2021-08-03 02:35:55 +00:00
|
|
|
|
"bbs_Signin_multi": True,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 指定签到讨论区
|
|
|
|
|
# 1是崩坏3 2是原神 3是崩坏2 4是未定事件簿 5是大别墅
|
|
|
|
|
# 可以通过设置讨论区的id位置来设置主讨论区,[5,1]就是大别墅为主社区
|
|
|
|
|
# 看帖子 点赞 分享帖子都是使用主社区获取到的列表
|
2022-04-23 00:47:10 +00:00
|
|
|
|
"bbs_Signin_multi_list": [],
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 浏览3个帖子
|
2021-06-06 12:57:28 +00:00
|
|
|
|
"bbs_Read_posts": True,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 完成5次点赞
|
2021-06-06 12:57:28 +00:00
|
|
|
|
"bbs_Like_posts": True,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 完成后取消点赞
|
2021-06-06 12:57:28 +00:00
|
|
|
|
"bbs_Unlike": True,
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 分享帖子
|
2021-06-06 12:57:28 +00:00
|
|
|
|
"bbs_Share": True,
|
|
|
|
|
}
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 原神自动签到
|
2021-08-03 02:35:55 +00:00
|
|
|
|
genshin_Auto_sign = True
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 崩坏3自动签到
|
2021-08-03 02:35:55 +00:00
|
|
|
|
honkai3rd_Auto_sign = True
|
2021-05-23 13:24:20 +00:00
|
|
|
|
|
2021-05-24 08:16:52 +00:00
|
|
|
|
path = os.path.dirname(os.path.realpath(__file__)) + "/config"
|
2021-05-25 09:45:35 +00:00
|
|
|
|
config_Path = f"{path}/config.json"
|
2021-05-23 13:24:20 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
|
2022-04-26 07:49:55 +00:00
|
|
|
|
def load_v4(data: dict):
|
|
|
|
|
global enable
|
|
|
|
|
global login_ticket
|
|
|
|
|
global stuid
|
|
|
|
|
global stoken
|
|
|
|
|
global cookies
|
|
|
|
|
global mihoyobbs
|
|
|
|
|
global genshin_Auto_sign
|
|
|
|
|
global honkai3rd_Auto_sign
|
|
|
|
|
enable = data["enable_Config"]
|
|
|
|
|
login_ticket = data["mihoyobbs_Login_ticket"]
|
|
|
|
|
stuid = data["mihoyobbs_Stuid"]
|
|
|
|
|
stoken = data["mihoyobbs_Stoken"]
|
|
|
|
|
cookies = data["mihoyobbs_Cookies"]
|
|
|
|
|
mihoyobbs = data["mihoyobbs"]
|
|
|
|
|
genshin_Auto_sign = data["genshin_Auto_sign"]
|
|
|
|
|
honkai3rd_Auto_sign = data["honkai3rd_Auto_sign"]
|
|
|
|
|
|
|
|
|
|
|
2022-01-06 05:49:25 +00:00
|
|
|
|
def load_config():
|
2021-05-25 09:45:35 +00:00
|
|
|
|
with open(config_Path, "r") as f:
|
2021-06-06 12:57:28 +00:00
|
|
|
|
data = json.load(f)
|
2022-04-26 07:49:55 +00:00
|
|
|
|
if data.get('version') == 5:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
load_v4(data)
|
2021-06-06 12:57:28 +00:00
|
|
|
|
f.close()
|
2022-01-06 05:49:25 +00:00
|
|
|
|
log.info("Config加载完毕")
|
2021-05-23 13:24:20 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
|
2022-01-06 05:49:25 +00:00
|
|
|
|
def save_config():
|
2021-10-25 14:53:34 +00:00
|
|
|
|
with open(config_Path, "r+") as f:
|
2021-05-23 13:24:20 +00:00
|
|
|
|
data = json.load(f)
|
2022-04-26 07:49:55 +00:00
|
|
|
|
data["mihoyobbs_Login_ticket"] = login_ticket
|
|
|
|
|
data["mihoyobbs_Stuid"] = stuid
|
|
|
|
|
data["mihoyobbs_Stoken"] = stoken
|
2021-05-23 13:24:20 +00:00
|
|
|
|
f.seek(0)
|
|
|
|
|
f.truncate()
|
2022-04-24 05:06:26 +00:00
|
|
|
|
temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': '))
|
|
|
|
|
f.write(temp_text)
|
2021-05-23 13:24:20 +00:00
|
|
|
|
f.flush()
|
|
|
|
|
f.close()
|
2022-01-06 05:49:25 +00:00
|
|
|
|
log.info("Config保存完毕")
|
2021-05-23 13:24:20 +00:00
|
|
|
|
|
2021-10-25 14:53:34 +00:00
|
|
|
|
|
2022-01-06 05:49:25 +00:00
|
|
|
|
def clear_cookies():
|
2021-10-25 14:53:34 +00:00
|
|
|
|
with open(config_Path, "r+") as f:
|
2021-06-06 12:57:28 +00:00
|
|
|
|
data = json.load(f)
|
|
|
|
|
data["enable_Config"] = False
|
|
|
|
|
data["mihoyobbs_Login_ticket"] = ""
|
|
|
|
|
data["mihoyobbs_Stuid"] = ""
|
|
|
|
|
data["mihoyobbs_Stoken"] = ""
|
2022-04-25 08:07:37 +00:00
|
|
|
|
data["mihoyobbs_Cookies"] = "CookieError"
|
2021-06-06 12:57:28 +00:00
|
|
|
|
f.seek(0)
|
|
|
|
|
f.truncate()
|
2022-04-24 05:06:26 +00:00
|
|
|
|
temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': '))
|
|
|
|
|
f.write(temp_text)
|
2021-06-06 12:57:28 +00:00
|
|
|
|
f.flush()
|
|
|
|
|
f.close()
|
2022-01-06 05:49:25 +00:00
|
|
|
|
log.info("Cookie删除完毕")
|