diff --git a/liteyuki/liteyuki_main/core.py b/liteyuki/liteyuki_main/core.py index fa1d4019..3817226f 100644 --- a/liteyuki/liteyuki_main/core.py +++ b/liteyuki/liteyuki_main/core.py @@ -27,22 +27,25 @@ cmd_liteyuki = on_alconna( ) update_liteyuki = on_alconna( - Alconna( - ["update-liteyuki", "更新轻雪"] + aliases={"更新轻雪"}, + command=Alconna( + "update-liteyuki" ), permission=SUPERUSER ) reload_liteyuki = on_alconna( - Alconna( - ["reload-liteyuki", "restart-liteyuki", "重启轻雪"] + aliases={"重启轻雪"}, + command=Alconna( + "reload-liteyuki" ), permission=SUPERUSER ) cmd_config = on_alconna( - Alconna( - ["config", "配置"], + aliases={"配置"}, + command=Alconna( + "config", Subcommand( "set", Args["key", str]["value", Any], diff --git a/liteyuki/plugins/liteyuki_minigame/minesweeper.py b/liteyuki/plugins/liteyuki_minigame/minesweeper.py index 5318a5a1..004adbc5 100644 --- a/liteyuki/plugins/liteyuki_minigame/minesweeper.py +++ b/liteyuki/plugins/liteyuki_minigame/minesweeper.py @@ -9,8 +9,9 @@ from .game import Minesweeper from nonebot_plugin_alconna import Alconna, on_alconna, Subcommand, Args, Arparma minesweeper = on_alconna( - Alconna( - ["minesweeper", "扫雷"], + aliases={"扫雷"}, + command=Alconna( + "minesweeper", Subcommand( "start", Args["row", int, 8]["col", int, 8]["mines", int, 10], diff --git a/liteyuki/plugins/liteyuki_npm/common.py b/liteyuki/plugins/liteyuki_npm/common.py index 27559a55..2e5717de 100644 --- a/liteyuki/plugins/liteyuki_npm/common.py +++ b/liteyuki/plugins/liteyuki_npm/common.py @@ -8,8 +8,6 @@ from liteyuki.utils.data import Database, LiteModel from liteyuki.utils.data_manager import GlobalPlugin, Group, InstalledPlugin, User, group_db, plugin_db, user_db from liteyuki.utils.ly_typing import T_MessageEvent -LNPM_COMMAND_START = "lnpm" - class PluginTag(LiteModel): label: str diff --git a/liteyuki/plugins/liteyuki_npm/installer.py b/liteyuki/plugins/liteyuki_npm/installer.py index 7a912d1b..50a993bc 100644 --- a/liteyuki/plugins/liteyuki_npm/installer.py +++ b/liteyuki/plugins/liteyuki_npm/installer.py @@ -18,7 +18,7 @@ from nonebot_plugin_alconna import Alconna, Args, Subcommand, on_alconna npm_alc = on_alconna( Alconna( - ["npm", "插件"], + "npm", Subcommand( "update", alias=["u"], @@ -43,9 +43,11 @@ npm_alc = on_alconna( alias=["l", "ls", "列表"], ) ), - permission=SUPERUSER + aliases={"插件"}, + permission=SUPERUSER, ) + @npm_alc.handle() async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): ulang = get_user_lang(str(event.user_id)) diff --git a/liteyuki/plugins/liteyuki_npm/manager.py b/liteyuki/plugins/liteyuki_npm/manager.py index baaa5857..76860df5 100644 --- a/liteyuki/plugins/liteyuki_npm/manager.py +++ b/liteyuki/plugins/liteyuki_npm/manager.py @@ -23,23 +23,26 @@ from nonebot_plugin_alconna import on_alconna, Alconna, Args, Arparma list_plugins = on_alconna( Alconna( - ["list-plugins", "插件列表", "列出插件"], - ) + "list-plugin", + ), + aliases={"列出插件", "插件列表", "菜单"} ) toggle_plugin = on_alconna( Alconna( - ["enable", "disable", "启用", "停用"], + "enable", Args["plugin_name", str], - ) + ), + aliases={"disable", "启用", "停用"} ) toggle_plugin_global = on_alconna( Alconna( - ["enable-global", "disable-global", "全局启用", "全局停用"], + "enable-global", Args["plugin_name", str], ), - permission=SUPERUSER + permission=SUPERUSER, + aliases={"disable-global", "全局启用", "全局停用"} ) @@ -117,8 +120,8 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): # 判断会话类型 ulang = get_user_lang(str(event.user_id)) plugin_module_name = result.args.get("plugin_name") - - toggle = result.header_result in ["enable-plugin", "启用"] # 判断是启用还是停用 + # 支持对自定义command_start的判断 + toggle = result.header_result in [prefix+header for prefix in bot.config.command_start for header in ["enable-plugin", "启用"]] # 判断是启用还是停用 session_enable = get_plugin_session_enable(event, plugin_module_name) # 获取插件当前状态 @@ -180,8 +183,8 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): # 判断会话类型 ulang = get_user_lang(str(event.user_id)) plugin_module_name = result.args.get("plugin_name") - - toggle = result.header_result in ["enable-global", "全局启用"] + # 支持对自定义command_start的判断 + toggle = result.header_result in [prefix + header for prefix in bot.config.command_start for header in ["enable-global", "全局启用"]] can_be_toggled = get_plugin_can_be_toggle(plugin_module_name) if not can_be_toggled: await toggle_plugin_global.finish(ulang.get("npm.plugin_cannot_be_toggled", NAME=plugin_module_name)) @@ -227,7 +230,6 @@ async def pre_handle(event: Event, matcher: Matcher): if not plugin_session_enable: raise IgnoredException("Plugin disabled in session") - # @Bot.on_calling_api # async def _(bot: Bot, api: str, data: dict[str, any]): # nonebot.logger.info(f"Plugin Callapi: {api}: {data}") diff --git a/liteyuki/plugins/liteyuki_user/profile_manager.py b/liteyuki/plugins/liteyuki_user/profile_manager.py index 730be345..ecc40456 100644 --- a/liteyuki/plugins/liteyuki_user/profile_manager.py +++ b/liteyuki/plugins/liteyuki_user/profile_manager.py @@ -15,7 +15,7 @@ from nonebot_plugin_alconna import Alconna, Args, Arparma, Subcommand, on_alconn profile_alc = on_alconna( Alconna( - ["profile", "个人信息"], + "profile", Subcommand( "set", Args["key", str]["value", str, None], @@ -26,7 +26,8 @@ profile_alc = on_alconna( Args["key", str], alias=["g", "查询"], ), - ) + ), + aliases={"用户信息"} )