From 7bef2293b2bc03984bbcd664be20867f4a268f00 Mon Sep 17 00:00:00 2001 From: Kyomotoi <0w0@imki.moe> Date: Thu, 13 Oct 2022 16:25:50 +0800 Subject: =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20=E6=96=B0=E5=A2=9E=E5=AF=B9?= =?UTF-8?q?=E8=80=81=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/configs/config.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ATRI/configs/config.py b/ATRI/configs/config.py index 57a94e9..e944a43 100644 --- a/ATRI/configs/config.py +++ b/ATRI/configs/config.py @@ -1,4 +1,5 @@ import yaml +from time import sleep from pathlib import Path from ATRI.log import log @@ -18,14 +19,23 @@ class Config: def __init__(self, config_path: Path): if not config_path.is_file(): try: - log.warning("未检测到 config.yml, 已于当前目录生成, 请参照文档进行填写并重新启动") - log.warning("文档地址: https://atri.imki.moe/install/configuration-bot/") with open(config_path, "w", encoding="utf-8") as w: w.write(_DEFAULT_CONFIG_PATH.read_text("utf-8")) + + log.warning("未检测到 config.yml, 已于当前目录生成, 请参照文档进行填写并重新启动") + log.warning("文档地址: https://atri.imki.moe/install/configuration-bot/") + sleep(3) exit(0) except Exception as err: log.error(f"写入文件 config.yml 失败, 请确认是否给足权限: {err}") + sleep(3) exit(-1) + else: + with open(config_path, "r", encoding="utf-8") as r: + if "BotSelfConfig" in r.read(): + log.warning("你的 config.yml 文件已废弃, 请删除并重新启动") + sleep(3) + exit(-1) self.config_path = config_path with open(self.config_path, "r", encoding="utf-8") as f: -- cgit v1.2.3