From 7c0efafd50a39be60597ac4125517bde7e52d343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=85=E8=AF=BA=E7=8B=90?= <212194964+foxcyber907@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:43:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=92=E4=BB=B6=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=EF=BC=8C=E5=8F=8A=E4=BF=A1=E6=81=AF=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/hello_world_plugin/plugin.py | 50 ++++++++++++++++++++++++++++ src/chat/message_receive/storage.py | 3 +- template/bot_config_template.toml | 4 +-- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/plugins/hello_world_plugin/plugin.py b/plugins/hello_world_plugin/plugin.py index 7e33f0890..c4430db0e 100644 --- a/plugins/hello_world_plugin/plugin.py +++ b/plugins/hello_world_plugin/plugin.py @@ -12,6 +12,55 @@ from src.plugin_system import ( ) +from src.plugin_system.base.base_command import BaseCommand +from src.plugin_system.apis import send_api +from typing import Tuple + +class GetGroupListCommand(BaseCommand): + """获取群列表命令""" + + command_name = "get_groups" + command_description = "获取机器人加入的群列表" + command_pattern = r"^/get_groups$" + command_help = "获取机器人加入的群列表" + command_examples = ["/get_groups"] + intercept_message = True + + async def execute(self) -> Tuple[bool, str, bool]: + try: + # 获取聊天流ID + stream_id = self.message.chat_stream.stream_id + + # 调用适配器命令API + response = await send_api.adapter_command_to_stream( + action="get_group_list", + params={}, + stream_id=stream_id + ) + + if response["status"] == "ok": + group_list = response.get("data", []) + + if group_list: + # 格式化群列表信息 + group_info = "\\n".join([ + f"群号: {group['group_id']}, 群名: {group['group_name']}" + for group in group_list + ]) + await self.send_text(f"机器人加入的群列表:\\n{group_info}") + else: + await self.send_text("机器人未加入任何群") + + return True, "获取群列表成功", True + else: + await self.send_text(f"获取群列表失败: {response['message']}") + return False, "获取群列表失败", True + + except Exception as e: + logger.error(f"执行获取群列表命令时出错: {e}") + await self.send_text("命令执行失败") + return False, "命令执行失败", True + class CompareNumbersTool(BaseTool): """比较两个数大小的工具""" @@ -182,6 +231,7 @@ class HelloWorldPlugin(BasePlugin): (CompareNumbersTool.get_tool_info(), CompareNumbersTool), # 添加比较数字工具 (ByeAction.get_action_info(), ByeAction), # 添加告别Action (TimeCommand.get_command_info(), TimeCommand), + (GetGroupListCommand.get_command_info(), GetGroupListCommand), # 添加获取群列表命令 # (PrintMessage.get_handler_info(), PrintMessage), ] diff --git a/src/chat/message_receive/storage.py b/src/chat/message_receive/storage.py index c0041efa2..feecd696a 100644 --- a/src/chat/message_receive/storage.py +++ b/src/chat/message_receive/storage.py @@ -123,7 +123,8 @@ class MessageStorage: elif message.message_segment.type == "reply": qq_message_id = message.message_segment.data.get("id") logger.info(f"更新消息ID完成,消息ID为{qq_message_id}") - + elif message.message_segment.type == "adapter_response": + logger.debug("适配器响应消息,不需要更新ID") else: logger.info(f"更新消息ID错误,seg类型为{message.message_segment.type}") return diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index b67d73aac..e5f602b7f 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "6.2.4" +version = "6.2.5" #----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读---- #如果你想要修改配置文件,请递增version的值 @@ -245,7 +245,7 @@ console_log_level = "INFO" # 控制台日志级别,可选: DEBUG, INFO, WARNIN file_log_level = "DEBUG" # 文件日志级别,可选: DEBUG, INFO, WARNING, ERROR, CRITICAL # 第三方库日志控制 -suppress_libraries = ["faiss","httpx", "urllib3", "asyncio", "websockets", "httpcore", "requests", "peewee", "openai","uvicorn","jieba"] # 完全屏蔽的库 +suppress_libraries = ["faiss","httpx", "urllib3", "asyncio", "websockets", "httpcore", "requests", "peewee", "openai","uvicorn","jieba","maim_message"] # 完全屏蔽的库 library_log_levels = { "aiohttp" = "WARNING"} # 设置特定库的日志级别 [debug]