From 83005e9ba991ecb406b8c6a07d7d275dda94443f Mon Sep 17 00:00:00 2001 From: LINSTCL Date: Mon, 6 Mar 2023 09:40:33 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=AE=8C=E6=95=B4=E6=80=A7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0d130c9..6f39f33 100644 --- a/main.py +++ b/main.py @@ -129,6 +129,14 @@ def main(first_time_init=False): config = importlib.import_module('config') + #配置完整性校验 + config_template = importlib.import_module('config-template') + for key in dir(config_template): + if not hasattr(config, key): + setattr(config, key, getattr(config_template, key)) + logging.warning("[{}]未配置,请更新或检查config.py".format(key)) + input('按回车继续...') + import pkg.utils.context pkg.utils.context.set_config(config) @@ -182,8 +190,7 @@ def main(first_time_init=False): # 初始化qq机器人 qqbot = pkg.qqbot.manager.QQBotManager(mirai_http_api_config=config.mirai_http_api_config, timeout=config.process_message_timeout, retry=config.retry_times, - first_time_init=first_time_init, - pool_num=config.pool_num if hasattr(config, 'pool_num') else 10) + first_time_init=first_time_init, pool_num=config.pool_num) # 加载插件 import pkg.plugin.host From 85c623fb0fb5f19de2534b5ee0b645aed3c3020e Mon Sep 17 00:00:00 2001 From: LINSTCL Date: Mon, 6 Mar 2023 11:27:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6f39f33..c5aded9 100644 --- a/main.py +++ b/main.py @@ -130,12 +130,17 @@ def main(first_time_init=False): config = importlib.import_module('config') #配置完整性校验 + is_integrity = True config_template = importlib.import_module('config-template') for key in dir(config_template): if not hasattr(config, key): setattr(config, key, getattr(config_template, key)) - logging.warning("[{}]未配置,请更新或检查config.py".format(key)) - input('按回车继续...') + logging.warning("[{}]不存在".format(key)) + is_integrity = False + if not is_integrity: + logging.warning("配置文件不完整,请依据config-template.py检查config.py") + logging.warning("以上配置已被设为默认值,将在5秒后继续启动... ") + time.sleep(5) import pkg.utils.context pkg.utils.context.set_config(config) From 49f4ab0ec80c19032b514f00b4d60bd64ea7a5ca Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Mon, 6 Mar 2023 12:34:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?perf:=20=E5=AE=8C=E6=95=B4=E6=80=A7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=BF=BD=E7=95=A5=5F=5F=E5=BC=80=E5=A4=B4?= =?UTF-8?q?=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index c5aded9..24b8eec 100644 --- a/main.py +++ b/main.py @@ -129,11 +129,15 @@ def main(first_time_init=False): config = importlib.import_module('config') - #配置完整性校验 + init_runtime_log_file() + + sh = reset_logging() + + # 配置完整性校验 is_integrity = True config_template = importlib.import_module('config-template') for key in dir(config_template): - if not hasattr(config, key): + if not key.startswith("__") and not hasattr(config, key): setattr(config, key, getattr(config_template, key)) logging.warning("[{}]不存在".format(key)) is_integrity = False @@ -145,10 +149,6 @@ def main(first_time_init=False): import pkg.utils.context pkg.utils.context.set_config(config) - init_runtime_log_file() - - sh = reset_logging() - # 检查是否设置了管理员 if not (hasattr(config, 'admin_qq') and config.admin_qq != 0): # logging.warning("未设置管理员QQ,管理员权限指令及运行告警将无法使用,如需设置请修改config.py中的admin_qq字段")