优先从内存读取用户信息

This commit is contained in:
2024-04-17 17:45:32 +08:00
parent c4db4dc6a6
commit 0e02af59ca
8 changed files with 158 additions and 57 deletions

View File

@ -36,7 +36,7 @@ def load_from_yaml(file: str) -> dict:
return conf
def get_config(key: str, bot: T_Bot = None, default=None):
def get_config(key: str, *, bot: T_Bot = None, default=None):
"""获取配置项优先级bot > config > db > yaml"""
if bot is None:
bot_config = {}
@ -59,6 +59,15 @@ def get_config(key: str, bot: T_Bot = None, default=None):
def init_conf(conf: dict) -> dict:
"""
初始化配置文件,确保配置文件中的必要字段存在,且不会冲突
Args:
conf:
Returns:
"""
# 若command_start中无""则添加必要命令头开启alconna_use_command_start防止冲突
if "" not in conf.get("command_start", []):
conf["alconna_use_command_start"] = True
return conf