mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-01-26 18:12:47 +08:00
✨ 更新Caller类,修复模块名称为空的情况并添加调试日志;修改run_shell_command描述并重命名
This commit is contained in:
parent
b3c63f0ae4
commit
dacb5aa854
@ -82,7 +82,7 @@ class Caller:
|
|||||||
if module := inspect.getmodule(func):
|
if module := inspect.getmodule(func):
|
||||||
module_name = module.__name__.split(".")[-1]
|
module_name = module.__name__.split(".")[-1]
|
||||||
else:
|
else:
|
||||||
module_name = "global"
|
module_name = ""
|
||||||
self._name = f"{module_name}-{func.__name__}"
|
self._name = f"{module_name}-{func.__name__}"
|
||||||
_caller_data[self._name] = self
|
_caller_data[self._name] = self
|
||||||
|
|
||||||
@ -140,6 +140,7 @@ class Caller:
|
|||||||
"""
|
"""
|
||||||
y, r = await self.pre_check()
|
y, r = await self.pre_check()
|
||||||
if not y:
|
if not y:
|
||||||
|
logger.debug(f"Function {self._name} pre_check failed: {r}")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
if self.func is None:
|
if self.func is None:
|
||||||
|
@ -95,9 +95,11 @@ async def run_python_code(code: str, b: Bot, e: MessageEvent) -> str:
|
|||||||
return "运行成功: " + str(r)
|
return "运行成功: " + str(r)
|
||||||
|
|
||||||
|
|
||||||
@on_function_call(description="运行shell命令,需要超级用户权限").params(
|
@on_function_call(
|
||||||
command=String(description="shell命令内容")
|
description="在设备上运行shell命令, Run command on this device"
|
||||||
).permission(SUPERUSER)
|
).params(command=String(description="shell命令内容")).permission(SUPERUSER).name(
|
||||||
|
"run_shell_command"
|
||||||
|
)
|
||||||
async def run_shell_command(command: str, b: Bot, e: MessageEvent) -> str:
|
async def run_shell_command(command: str, b: Bot, e: MessageEvent) -> str:
|
||||||
"""运行shell命令"""
|
"""运行shell命令"""
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user