1
0
forked from bot/app

feat: 添加了对自定义命令前缀的支持

This commit is contained in:
远野千束 2024-03-31 09:03:28 +08:00
parent 2ad2bb4182
commit 724e13180c
3 changed files with 8 additions and 3 deletions

View File

@ -46,7 +46,6 @@ npm_alc = on_alconna(
permission=SUPERUSER
)
@npm_alc.handle()
async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
ulang = get_user_lang(str(event.user_id))

View File

@ -24,9 +24,15 @@ def load_from_yaml(file: str) -> dict:
yaml.dump(BasicConfig().dict(), f, default_flow_style=False)
with open(file, "r", encoding="utf-8") as f:
conf = yaml.load(f, Loader=yaml.FullLoader)
conf = init_conf(yaml.load(f, Loader=yaml.FullLoader))
config = conf
if conf is None:
nonebot.logger.warning(f"Config file {file} is empty, use default config. please modify it and restart")
conf = BasicConfig().dict()
return conf
def init_conf(conf: dict) -> dict:
if "" not in conf.get("command_start", []):
conf["alconna_use_command_start"] = True
return conf

View File

@ -146,7 +146,7 @@ class Markdown:
markdown格式的可点击回调按钮
"""
if "" not in config.get("command_start", ["/"]):
if "" not in config.get("command_start", ["/"]) and config.get("alconna_use_command_start", False):
cmd = f"{config['command_start'][0]}{cmd}"
return f"[{name}](mqqapi://aio/inlinecmd?command={quote(cmd)}&reply={str(reply).lower()}&enter={str(enter).lower()})"