From 58f58144d04aeab00fab084e7876b7a8edc0d8ec Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Tue, 19 Aug 2025 13:03:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(chat):=20=E8=B0=83=E6=95=B4=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=80=89=E6=8B=A9=E7=9A=84=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在确定 `action_message` 时,优先使用 `target_message` 而不是 `message_data`。 这一变更优化了消息处理流程,确保在存在明确的目标消息时,系统能够正确地选择它,从而避免了潜在的逻辑冲突,使行为更加符合预期。 Co-authored-by: 雅诺狐 <212194964+foxcyber907@users.noreply.github.com> Co-authored-by: tt-P607 <68868379+tt-P607@users.noreply.github.com> --- src/chat/chat_loop/heartFC_chat.py | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/chat/chat_loop/heartFC_chat.py b/src/chat/chat_loop/heartFC_chat.py index c60772e8b..ec973fdc6 100644 --- a/src/chat/chat_loop/heartFC_chat.py +++ b/src/chat/chat_loop/heartFC_chat.py @@ -634,23 +634,22 @@ class HeartFChatting: logger.info( f"{self.log_prefix}{global_config.bot.nickname} 原本想要回复:{content},但选择执行{action_type},不发表回复" ) - - return { - "action_type": "no_reply", - "success": True, - "reply_text": "", - "command": "" - } - elif action_info["action_type"] != "reply": - # 执行普通动作 - with Timer("动作执行", cycle_timers): - success, reply_text, command = await self._handle_action( - action_info["action_type"], - action_info["reasoning"], - action_info["action_data"], - cycle_timers, - thinking_id, - action_info["action_message"] + else: + logger.warning(f"{self.log_prefix} 预生成的回复任务未生成有效内容") + + action_message = target_message or message_data + if action_type == "reply": + # 等待回复生成完毕 + if self.loop_mode == ChatMode.NORMAL: + # 只有在gen_task存在时才等待 + if not gen_task: + reply_to_str = await self.build_reply_to_str(message_data) + gen_task = asyncio.create_task( + self._generate_response( + message_data=message_data, + available_actions=available_actions, + reply_to=reply_to_str, + request_type="chat.replyer.normal", ) return { "action_type": action_info["action_type"],