feat(chat): 优化消息打断逻辑,仅限触发用户

为了防止群聊中其他用户的消息意外中断正在进行的AI多重回复,引入了“触发用户”机制。

- 现在,只有发起该轮对话的用户发送的新消息才可能触发打断。
- 此外,表情包和Emoji等非文本消息将被忽略,不再触发打断,以提高交互的流畅性。
This commit is contained in:
tt-P607
2025-10-23 14:30:42 +08:00
parent a94bd57912
commit cce30f34f1
3 changed files with 25 additions and 7 deletions

View File

@@ -110,6 +110,11 @@ class ChatterManager:
self.stats["streams_processed"] += 1
try:
# 设置触发用户ID
last_message = context.get_last_message()
if last_message:
context.triggering_user_id = last_message.user_info.user_id
result = await self.instances[stream_id].execute(context)
# 检查执行结果是否真正成功
@@ -156,6 +161,7 @@ class ChatterManager:
finally:
# 无论成功还是失败,都要清理处理任务记录
self.remove_processing_task(stream_id)
context.triggering_user_id = None # 清除触发用户ID
def get_stats(self) -> dict[str, Any]:
"""获取管理器统计信息"""