diff options
author | Kyomotoi <[email protected]> | 2022-10-14 10:23:01 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2022-10-14 10:23:01 +0800 |
commit | 17d9585ea50ef00b96dce7c9114294e433be132f (patch) | |
tree | 5eb04d54a162839ed1bc105d3441f4de46ce153a /ATRI/configs | |
parent | 207f5501d4a82f26b991243914e637a735296ab5 (diff) | |
download | ATRI-17d9585ea50ef00b96dce7c9114294e433be132f.tar.gz ATRI-17d9585ea50ef00b96dce7c9114294e433be132f.tar.bz2 ATRI-17d9585ea50ef00b96dce7c9114294e433be132f.zip |
🔧 更新配置项
Diffstat (limited to 'ATRI/configs')
-rw-r--r-- | ATRI/configs/config.py | 17 | ||||
-rw-r--r-- | ATRI/configs/default_config.yml | 5 | ||||
-rw-r--r-- | ATRI/configs/models.py | 5 |
3 files changed, 22 insertions, 5 deletions
diff --git a/ATRI/configs/config.py b/ATRI/configs/config.py index caa7db1..32ce52f 100644 --- a/ATRI/configs/config.py +++ b/ATRI/configs/config.py @@ -26,13 +26,19 @@ class Config: else: with open(config_path, "r", encoding="utf-8") as r: if "BotSelfConfig" in r.read(): - print("!!! 你的 config.yml 文件已废弃, 请删除并重新启动") + print("!!! 你的 config.yml 文件已废弃, 请 删除/备份 并重新启动") sleep(3) exit(-1) - self.config_path = config_path - with open(self.config_path, "r", encoding="utf-8") as f: - self.config = yaml.safe_load(f) + raw_conf = yaml.safe_load(_DEFAULT_CONFIG_PATH.read_bytes()) + conf = yaml.safe_load(config_path.read_bytes()) + + if raw_conf["ConfigVersion"] != conf["ConfigVersion"]: + print("!!! 你的 config.yml 文件已废弃, 请 删除/备份 并重新启动") + sleep(3) + exit(-1) + + self.config = conf def parse(self) -> ConfigModel: return ConfigModel.parse_obj(self.config) @@ -47,10 +53,13 @@ class Config: debug=bot_conf.debug, superusers=bot_conf.superusers, nickname=bot_conf.nickname, + onebot_access_token=bot_conf.access_token, command_start=bot_conf.command_start, command_sep=bot_conf.command_sep, session_expire_timeout=bot_conf.session_expire_timeout, gocq_accoutns=gocq_conf.accounts, gocq_download_domain=gocq_conf.download_version, gocq_version=gocq_conf.download_version, + gocq_webui_username=gocq_conf.gocq_webui_password, + gocq_webui_password=gocq_conf.gocq_webui_password, ).dict() diff --git a/ATRI/configs/default_config.yml b/ATRI/configs/default_config.yml index 37db00d..34ab716 100644 --- a/ATRI/configs/default_config.yml +++ b/ATRI/configs/default_config.yml @@ -1,5 +1,5 @@ # 设置参考文档: https://atri.imki.moe/install/configuration-bot/ -ConfigVersion: "1.0.0" +ConfigVersion: "1.1.0" BotConfig: host: "127.0.0.1" @@ -24,6 +24,9 @@ WithGoCQHTTP: download_domain: "github.com" download_version: "v1.0.0-rc1" + gocq_webui_username: "ATRI" + gocq_webui_password: "ATRI1314000***" + SauceNAO: key: "" diff --git a/ATRI/configs/models.py b/ATRI/configs/models.py index 8043f8a..e81a633 100644 --- a/ATRI/configs/models.py +++ b/ATRI/configs/models.py @@ -27,6 +27,8 @@ class WithGoCQHTTP(BaseModel): accounts: List[GoCQHTTPAccountList] download_domain: str download_version: str + gocq_webui_username: str + gocq_webui_password: str class SauceNAO(BaseModel): @@ -52,9 +54,12 @@ class RuntimeConfig(BaseModel): debug: bool superusers: set nickname: set + onebot_access_token: str command_start: set command_sep: set session_expire_timeout: int gocq_accoutns: list gocq_download_domain: str gocq_version: str + gocq_webui_username: str + gocq_webui_password: str
\ No newline at end of file |