From c56b24d613c28ebb4e14d163fc96e7a39fec19ba Mon Sep 17 00:00:00 2001 From: 1334431750 <1334431750@qq.com> Date: Tue, 1 Jul 2025 04:45:44 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=91=E9=80=81=E7=BE=A4AI?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__init__.py | 2 ++ src/send_handler.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/__init__.py b/src/__init__.py index bfae081..788b2a7 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -73,6 +73,8 @@ class CommandType(Enum): GROUP_WHOLE_BAN = "set_group_whole_ban" # 群全体禁言 GROUP_KICK = "set_group_kick" # 踢出群聊 SEND_POKE = "send_poke" # 戳一戳 + AI_VOICE_SEND = "send_group_ai_record" # 发送群AI语音 + def __str__(self) -> str: return self.value diff --git a/src/send_handler.py b/src/send_handler.py index 2a6709e..b30fbce 100644 --- a/src/send_handler.py +++ b/src/send_handler.py @@ -99,6 +99,8 @@ class SendHandler: command, args_dict = self.handle_kick_command(seg_data.get("args"), group_info) case CommandType.SEND_POKE.name: command, args_dict = self.handle_poke_command(seg_data.get("args"), group_info) + case CommandType.AI_VOICE_SEND.name: + command, args_dict = self.handle_ai_voice_send_command(seg_data.get("args"), group_info) case _: logger.error(f"未知命令: {command_name}") return @@ -343,6 +345,26 @@ class SendHandler: "user_id": user_id, }, ) + def handle_ai_voice_send_command(self, args: Dict[str, Any], group_info: GroupInfo) -> Tuple[str, Dict[str, Any]]: + """ + 处理AI语音发送命令的逻辑。 + 并返回 NapCat 兼容的 (action, params) 元组。 + """ + group_id: int = int(group_info.group_id) + character_id = args.get("character") + text_content = args.get("text") + + if not character_id or not text_content: + raise ValueError(f"AI语音发送命令参数不完整: character='{character_id}', text='{text_content}'") + + return ( + CommandType.AI_VOICE_SEND.value, + { + "group_id": group_id, + "text": text_content, + "character": character_id, + }, + ) async def send_message_to_napcat(self, action: str, params: dict) -> dict: request_uuid = str(uuid.uuid4())