mirror of https://github.com/Mai-with-u/MaiBot.git
feat: toml 文件格式出错时提醒用户修改
parent
bb104d65a1
commit
ebb633770a
|
|
@ -85,7 +85,11 @@ class BotConfig:
|
||||||
config = cls()
|
config = cls()
|
||||||
if os.path.exists(config_path):
|
if os.path.exists(config_path):
|
||||||
with open(config_path, "rb") as f:
|
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:
|
if 'personality' in toml_dict:
|
||||||
personality_config=toml_dict['personality']
|
personality_config=toml_dict['personality']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue