From 0616ed5084dfd4af462ef955924d55ef4f03a9db Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 16 Dec 2024 12:53:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86MessageEvent=E6=94=B9=E4=B8=BAEvent?= =?UTF-8?q?=E5=9F=BA=E7=B1=BB=EF=BC=8C=E5=A2=9E=E5=BC=BA=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/snowykami_testplugin/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py b/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py index 25c19862..e8f9c445 100644 --- a/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py +++ b/nonebot_plugin_marshoai/plugins/snowykami_testplugin/__init__.py @@ -2,8 +2,9 @@ import os import platform import psutil -from nonebot.adapters import Bot -from nonebot.adapters.onebot.v11 import MessageEvent +from nonebot.adapters import Bot, Event + +# from nonebot.adapters.onebot.v11 import MessageEvent from nonebot.permission import SUPERUSER from nonebot_plugin_marshoai.plugin import ( @@ -58,7 +59,7 @@ def get_location() -> str: @on_function_call(description="获取聊天者个人信息及发送的消息和function call调用参数") -async def get_user_info(e: MessageEvent, c: Caller) -> str: +async def get_user_info(e: Event, c: Caller) -> str: return ( f"用户ID: {e.user_id} " "用户昵称: {e.sender.nickname} " @@ -86,7 +87,7 @@ def get_device_info() -> str: @on_function_call(description="在设备上运行Python代码,需要超级用户权限").params( code=String(description="Python代码内容") ).permission(SUPERUSER) -async def run_python_code(code: str, b: Bot, e: MessageEvent) -> str: +async def run_python_code(code: str, b: Bot, e: Event) -> str: """运行Python代码""" try: r = eval(code) @@ -98,7 +99,7 @@ async def run_python_code(code: str, b: Bot, e: MessageEvent) -> str: @on_function_call( description="在设备上运行shell命令, Run command on this device" ).params(command=String(description="shell命令内容")).permission(SUPERUSER) -async def run_shell_command(command: str, b: Bot, e: MessageEvent) -> str: +async def run_shell_command(command: str, b: Bot, e: Event) -> str: """运行shell命令""" try: r = os.popen(command).read()