From ebb633770a894ea55e10e605ccbaae033533ffd7 Mon Sep 17 00:00:00 2001 From: jiajiu123 <1771663559@qq.com> Date: Sat, 8 Mar 2025 04:24:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20toml=20=E6=96=87=E4=BB=B6=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=87=BA=E9=94=99=E6=97=B6=E6=8F=90=E9=86=92=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/chat/config.py b/src/plugins/chat/config.py index 0186001a..6ebf5b16 100644 --- a/src/plugins/chat/config.py +++ b/src/plugins/chat/config.py @@ -85,7 +85,11 @@ class BotConfig: config = cls() if os.path.exists(config_path): with open(config_path, "rb") as f: - toml_dict = tomli.load(f) + try: + toml_dict = tomli.load(f) + except(tomli.TOMLDecodeError) as e: + logger.critical(f"配置文件bot_config.toml填写有误,请检查第{e.lineno}行第{e.colno}处:{e.msg}") + exit(1) if 'personality' in toml_dict: personality_config=toml_dict['personality']