更新插件示例,及信息类型问题
This commit is contained in:
@@ -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):
|
class CompareNumbersTool(BaseTool):
|
||||||
"""比较两个数大小的工具"""
|
"""比较两个数大小的工具"""
|
||||||
|
|
||||||
@@ -182,6 +231,7 @@ class HelloWorldPlugin(BasePlugin):
|
|||||||
(CompareNumbersTool.get_tool_info(), CompareNumbersTool), # 添加比较数字工具
|
(CompareNumbersTool.get_tool_info(), CompareNumbersTool), # 添加比较数字工具
|
||||||
(ByeAction.get_action_info(), ByeAction), # 添加告别Action
|
(ByeAction.get_action_info(), ByeAction), # 添加告别Action
|
||||||
(TimeCommand.get_command_info(), TimeCommand),
|
(TimeCommand.get_command_info(), TimeCommand),
|
||||||
|
(GetGroupListCommand.get_command_info(), GetGroupListCommand), # 添加获取群列表命令
|
||||||
# (PrintMessage.get_handler_info(), PrintMessage),
|
# (PrintMessage.get_handler_info(), PrintMessage),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ class MessageStorage:
|
|||||||
elif message.message_segment.type == "reply":
|
elif message.message_segment.type == "reply":
|
||||||
qq_message_id = message.message_segment.data.get("id")
|
qq_message_id = message.message_segment.data.get("id")
|
||||||
logger.info(f"更新消息ID完成,消息ID为{qq_message_id}")
|
logger.info(f"更新消息ID完成,消息ID为{qq_message_id}")
|
||||||
|
elif message.message_segment.type == "adapter_response":
|
||||||
|
logger.debug("适配器响应消息,不需要更新ID")
|
||||||
else:
|
else:
|
||||||
logger.info(f"更新消息ID错误,seg类型为{message.message_segment.type}")
|
logger.info(f"更新消息ID错误,seg类型为{message.message_segment.type}")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[inner]
|
[inner]
|
||||||
version = "6.2.4"
|
version = "6.2.5"
|
||||||
|
|
||||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||||
#如果你想要修改配置文件,请递增version的值
|
#如果你想要修改配置文件,请递增version的值
|
||||||
@@ -245,7 +245,7 @@ console_log_level = "INFO" # 控制台日志级别,可选: DEBUG, INFO, WARNIN
|
|||||||
file_log_level = "DEBUG" # 文件日志级别,可选: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
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"} # 设置特定库的日志级别
|
library_log_levels = { "aiohttp" = "WARNING"} # 设置特定库的日志级别
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|||||||
Reference in New Issue
Block a user