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]