From dacb5aa85405450cca1dfc8e07b2581c2d79fd4e Mon Sep 17 00:00:00 2001 From: Snowykami Date: Mon, 16 Dec 2024 02:15:55 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=9B=B4=E6=96=B0Caller=E7=B1=BB?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=9D=97=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9run=5Fshell=5Fcommand=E6=8F=8F=E8=BF=B0=E5=B9=B6?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/plugin/func_call/caller.py | 3 ++- .../plugins/snowykami_testplugin/__init__.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nonebot_plugin_marshoai/plugin/func_call/caller.py b/nonebot_plugin_marshoai/plugin/func_call/caller.py index e812835d..41b73505 100644 --- a/nonebot_plugin_marshoai/plugin/func_call/caller.py +++ b/nonebot_plugin_marshoai/plugin/func_call/caller.py @@ -82,7 +82,7 @@ class Caller: if module := inspect.getmodule(func): module_name = module.__name__.split(".")[-1] else: - module_name = "global" + module_name = "" self._name = f"{module_name}-{func.__name__}" _caller_data[self._name] = self @@ -140,6 +140,7 @@ class Caller: """ y, r = await self.pre_check() if not y: + logger.debug(f"Function {self._name} pre_check failed: {r}") return r if self.func is None: diff --git a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py b/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py index 3b6bc565..b3083bbc 100644 --- a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py +++ b/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py @@ -95,9 +95,11 @@ async def run_python_code(code: str, b: Bot, e: MessageEvent) -> str: return "运行成功: " + str(r) -@on_function_call(description="运行shell命令,需要超级用户权限").params( - command=String(description="shell命令内容") -).permission(SUPERUSER) +@on_function_call( + description="在设备上运行shell命令, Run command on this device" +).params(command=String(description="shell命令内容")).permission(SUPERUSER).name( + "run_shell_command" +) async def run_shell_command(command: str, b: Bot, e: MessageEvent) -> str: """运行shell命令""" try: