fix(chat): 增强消息查找功能并添加未读消息自动清理机制

- 重构 `_find_message_by_id` 方法,支持多种消息ID格式和模糊匹配
- 在动作执行后自动清理未读消息,防止消息堆积
- 为 `reply` 动作添加目标消息查找失败时的降级处理
- 将消息计数和关系查询方法改为异步调用以保持一致性
This commit is contained in:
Windpicker-owo
2025-09-29 10:47:43 +08:00
parent 02d0490da7
commit fc429228b5
5 changed files with 177 additions and 51 deletions

View File

@@ -288,8 +288,8 @@ class MessageManager:
else:
logger.debug(f"聊天流 {stream_id} 未触发打断,打断概率: {interruption_probability:.2f}")
def _clear_all_unread_messages(self, stream_id: str):
"""清除指定上下文中的所有未读消息,防止意外情况导致消息一直未读"""
async def clear_all_unread_messages(self, stream_id: str):
"""清除指定上下文中的所有未读消息,在消息处理完成后调用"""
try:
# 通过 ChatManager 获取 ChatStream
chat_manager = get_chat_manager()