feat: toml 文件格式出错时提醒用户修改

This commit is contained in:
jiajiu123
2025-03-08 04:24:43 +08:00
parent bb104d65a1
commit ebb633770a

View File

@@ -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']