Merge branch 'dev-s4u' into dev

This commit is contained in:
SengokuCola
2025-07-01 19:33:06 +08:00
committed by GitHub
12 changed files with 1197 additions and 3 deletions

View File

@@ -13,8 +13,11 @@ from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
from src.config.config import global_config
from src.plugin_system.core.component_registry import component_registry # 导入新插件系统
from src.plugin_system.base.base_command import BaseCommand
from src.mais4u.mais4u_chat.s4u_msg_processor import S4UMessageProcessor
# 定义日志配置
ENABLE_S4U_CHAT = True
# 仅内部开启
# 配置主程序日志格式
logger = get_logger("chat")
@@ -30,6 +33,7 @@ class ChatBot:
# 创建初始化PFC管理器的任务会在_ensure_started时执行
self.only_process_chat = MessageProcessor()
self.pfc_manager = PFCManager.get_instance()
self.s4u_message_processor = S4UMessageProcessor()
async def _ensure_started(self):
"""确保所有任务已启动"""
@@ -176,6 +180,14 @@ class ChatBot:
# 如果在私聊中
if group_info is None:
logger.debug("检测到私聊消息")
if ENABLE_S4U_CHAT:
logger.debug("进入S4U私聊处理流程")
await self.s4u_message_processor.process_message(message)
return
if global_config.experimental.pfc_chatting:
logger.debug("进入PFC私聊处理流程")
# 创建聊天流
@@ -188,6 +200,13 @@ class ChatBot:
await self.heartflow_message_receiver.process_message(message)
# 群聊默认进入心流消息处理逻辑
else:
if ENABLE_S4U_CHAT:
logger.debug("进入S4U私聊处理流程")
await self.s4u_message_processor.process_message(message)
return
logger.debug(f"检测到群聊消息群ID: {group_info.group_id}")
await self.heartflow_message_receiver.process_message(message)

View File

@@ -305,6 +305,7 @@ class MessageSending(MessageProcessBase):
is_emoji: bool = False,
thinking_start_time: float = 0,
apply_set_reply_logic: bool = False,
reply_to: str = None,
):
# 调用父类初始化
super().__init__(
@@ -322,6 +323,8 @@ class MessageSending(MessageProcessBase):
self.is_head = is_head
self.is_emoji = is_emoji
self.apply_set_reply_logic = apply_set_reply_logic
self.reply_to = reply_to
# 用于显示发送内容与显示不一致的情况
self.display_message = display_message

View File

@@ -35,8 +35,12 @@ class MessageStorage:
filtered_display_message = re.sub(pattern, "", display_message, flags=re.DOTALL)
else:
filtered_display_message = ""
reply_to = message.reply_to
else:
filtered_display_message = ""
reply_to = ""
chat_info_dict = chat_stream.to_dict()
user_info_dict = message.message_info.user_info.to_dict()
@@ -54,6 +58,7 @@ class MessageStorage:
time=float(message.message_info.time),
chat_id=chat_stream.stream_id,
# Flattened chat_info
reply_to=reply_to,
chat_info_stream_id=chat_info_dict.get("stream_id"),
chat_info_platform=chat_info_dict.get("platform"),
chat_info_user_platform=user_info_from_chat.get("platform"),