mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-28 16:24:51 +08:00
fix: alconna
响应器命令头别名配置错误的问题
This commit is contained in:
parent
d3f3ee6dfa
commit
3065122059
@ -27,22 +27,25 @@ cmd_liteyuki = on_alconna(
|
|||||||
)
|
)
|
||||||
|
|
||||||
update_liteyuki = on_alconna(
|
update_liteyuki = on_alconna(
|
||||||
Alconna(
|
aliases={"更新轻雪"},
|
||||||
["update-liteyuki", "更新轻雪"]
|
command=Alconna(
|
||||||
|
"update-liteyuki"
|
||||||
),
|
),
|
||||||
permission=SUPERUSER
|
permission=SUPERUSER
|
||||||
)
|
)
|
||||||
|
|
||||||
reload_liteyuki = on_alconna(
|
reload_liteyuki = on_alconna(
|
||||||
Alconna(
|
aliases={"重启轻雪"},
|
||||||
["reload-liteyuki", "restart-liteyuki", "重启轻雪"]
|
command=Alconna(
|
||||||
|
"reload-liteyuki"
|
||||||
),
|
),
|
||||||
permission=SUPERUSER
|
permission=SUPERUSER
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd_config = on_alconna(
|
cmd_config = on_alconna(
|
||||||
Alconna(
|
aliases={"配置"},
|
||||||
["config", "配置"],
|
command=Alconna(
|
||||||
|
"config",
|
||||||
Subcommand(
|
Subcommand(
|
||||||
"set",
|
"set",
|
||||||
Args["key", str]["value", Any],
|
Args["key", str]["value", Any],
|
||||||
|
@ -9,8 +9,9 @@ from .game import Minesweeper
|
|||||||
from nonebot_plugin_alconna import Alconna, on_alconna, Subcommand, Args, Arparma
|
from nonebot_plugin_alconna import Alconna, on_alconna, Subcommand, Args, Arparma
|
||||||
|
|
||||||
minesweeper = on_alconna(
|
minesweeper = on_alconna(
|
||||||
Alconna(
|
aliases={"扫雷"},
|
||||||
["minesweeper", "扫雷"],
|
command=Alconna(
|
||||||
|
"minesweeper",
|
||||||
Subcommand(
|
Subcommand(
|
||||||
"start",
|
"start",
|
||||||
Args["row", int, 8]["col", int, 8]["mines", int, 10],
|
Args["row", int, 8]["col", int, 8]["mines", int, 10],
|
||||||
|
@ -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.data_manager import GlobalPlugin, Group, InstalledPlugin, User, group_db, plugin_db, user_db
|
||||||
from liteyuki.utils.ly_typing import T_MessageEvent
|
from liteyuki.utils.ly_typing import T_MessageEvent
|
||||||
|
|
||||||
LNPM_COMMAND_START = "lnpm"
|
|
||||||
|
|
||||||
|
|
||||||
class PluginTag(LiteModel):
|
class PluginTag(LiteModel):
|
||||||
label: str
|
label: str
|
||||||
|
@ -18,7 +18,7 @@ from nonebot_plugin_alconna import Alconna, Args, Subcommand, on_alconna
|
|||||||
|
|
||||||
npm_alc = on_alconna(
|
npm_alc = on_alconna(
|
||||||
Alconna(
|
Alconna(
|
||||||
["npm", "插件"],
|
"npm",
|
||||||
Subcommand(
|
Subcommand(
|
||||||
"update",
|
"update",
|
||||||
alias=["u"],
|
alias=["u"],
|
||||||
@ -43,9 +43,11 @@ npm_alc = on_alconna(
|
|||||||
alias=["l", "ls", "列表"],
|
alias=["l", "ls", "列表"],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
permission=SUPERUSER
|
aliases={"插件"},
|
||||||
|
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))
|
||||||
|
@ -23,23 +23,26 @@ from nonebot_plugin_alconna import on_alconna, Alconna, Args, Arparma
|
|||||||
|
|
||||||
list_plugins = on_alconna(
|
list_plugins = on_alconna(
|
||||||
Alconna(
|
Alconna(
|
||||||
["list-plugins", "插件列表", "列出插件"],
|
"list-plugin",
|
||||||
)
|
),
|
||||||
|
aliases={"列出插件", "插件列表", "菜单"}
|
||||||
)
|
)
|
||||||
|
|
||||||
toggle_plugin = on_alconna(
|
toggle_plugin = on_alconna(
|
||||||
Alconna(
|
Alconna(
|
||||||
["enable", "disable", "启用", "停用"],
|
"enable",
|
||||||
Args["plugin_name", str],
|
Args["plugin_name", str],
|
||||||
)
|
),
|
||||||
|
aliases={"disable", "启用", "停用"}
|
||||||
)
|
)
|
||||||
|
|
||||||
toggle_plugin_global = on_alconna(
|
toggle_plugin_global = on_alconna(
|
||||||
Alconna(
|
Alconna(
|
||||||
["enable-global", "disable-global", "全局启用", "全局停用"],
|
"enable-global",
|
||||||
Args["plugin_name", str],
|
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))
|
ulang = get_user_lang(str(event.user_id))
|
||||||
plugin_module_name = result.args.get("plugin_name")
|
plugin_module_name = result.args.get("plugin_name")
|
||||||
|
# 支持对自定义command_start的判断
|
||||||
toggle = result.header_result in ["enable-plugin", "启用"] # 判断是启用还是停用
|
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) # 获取插件当前状态
|
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))
|
ulang = get_user_lang(str(event.user_id))
|
||||||
plugin_module_name = result.args.get("plugin_name")
|
plugin_module_name = result.args.get("plugin_name")
|
||||||
|
# 支持对自定义command_start的判断
|
||||||
toggle = result.header_result in ["enable-global", "全局启用"]
|
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)
|
can_be_toggled = get_plugin_can_be_toggle(plugin_module_name)
|
||||||
if not can_be_toggled:
|
if not can_be_toggled:
|
||||||
await toggle_plugin_global.finish(ulang.get("npm.plugin_cannot_be_toggled", NAME=plugin_module_name))
|
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:
|
if not plugin_session_enable:
|
||||||
raise IgnoredException("Plugin disabled in session")
|
raise IgnoredException("Plugin disabled in session")
|
||||||
|
|
||||||
|
|
||||||
# @Bot.on_calling_api
|
# @Bot.on_calling_api
|
||||||
# async def _(bot: Bot, api: str, data: dict[str, any]):
|
# async def _(bot: Bot, api: str, data: dict[str, any]):
|
||||||
# nonebot.logger.info(f"Plugin Callapi: {api}: {data}")
|
# nonebot.logger.info(f"Plugin Callapi: {api}: {data}")
|
||||||
|
@ -15,7 +15,7 @@ from nonebot_plugin_alconna import Alconna, Args, Arparma, Subcommand, on_alconn
|
|||||||
|
|
||||||
profile_alc = on_alconna(
|
profile_alc = on_alconna(
|
||||||
Alconna(
|
Alconna(
|
||||||
["profile", "个人信息"],
|
"profile",
|
||||||
Subcommand(
|
Subcommand(
|
||||||
"set",
|
"set",
|
||||||
Args["key", str]["value", str, None],
|
Args["key", str]["value", str, None],
|
||||||
@ -26,7 +26,8 @@ profile_alc = on_alconna(
|
|||||||
Args["key", str],
|
Args["key", str],
|
||||||
alias=["g", "查询"],
|
alias=["g", "查询"],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
aliases={"用户信息"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user