mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-11 14:37:31 +08:00
feat: 添加了对自定义命令前缀的支持
This commit is contained in:
parent
2ad2bb4182
commit
724e13180c
@ -46,7 +46,6 @@ npm_alc = on_alconna(
|
|||||||
permission=SUPERUSER
|
permission=SUPERUSER
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@npm_alc.handle()
|
@npm_alc.handle()
|
||||||
async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
|
async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
|
||||||
ulang = get_user_lang(str(event.user_id))
|
ulang = get_user_lang(str(event.user_id))
|
||||||
|
@ -24,9 +24,15 @@ def load_from_yaml(file: str) -> dict:
|
|||||||
yaml.dump(BasicConfig().dict(), f, default_flow_style=False)
|
yaml.dump(BasicConfig().dict(), f, default_flow_style=False)
|
||||||
|
|
||||||
with open(file, "r", encoding="utf-8") as f:
|
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
|
config = conf
|
||||||
if conf is None:
|
if conf is None:
|
||||||
nonebot.logger.warning(f"Config file {file} is empty, use default config. please modify it and restart")
|
nonebot.logger.warning(f"Config file {file} is empty, use default config. please modify it and restart")
|
||||||
conf = BasicConfig().dict()
|
conf = BasicConfig().dict()
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
def init_conf(conf: dict) -> dict:
|
||||||
|
if "" not in conf.get("command_start", []):
|
||||||
|
conf["alconna_use_command_start"] = True
|
||||||
|
return conf
|
||||||
|
@ -146,7 +146,7 @@ class Markdown:
|
|||||||
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}"
|
cmd = f"{config['command_start'][0]}{cmd}"
|
||||||
return f"[{name}](mqqapi://aio/inlinecmd?command={quote(cmd)}&reply={str(reply).lower()}&enter={str(enter).lower()})"
|
return f"[{name}](mqqapi://aio/inlinecmd?command={quote(cmd)}&reply={str(reply).lower()}&enter={str(enter).lower()})"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user