fix(msgbot): 修复OCR时间戳过滤器误丢含问号的新查询——旧消息时间戳拖累新消息丢弃(Task #1624)
This commit is contained in:
+14
@@ -6672,6 +6672,20 @@ class MessageMonitor:
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
# ⭐ Task #1624: 无日期+时间戳全部过期时,检查最后一个时间戳之后是否含问号
|
||||
# 根因:OCR一次读到整屏聊天,含旧消息(带时间戳) + 新查询(无时间戳)。
|
||||
# 例:旧消息"21:35:46"上方 + 新查询"云背包有哪些可用参数?"底部。
|
||||
# 22:51新消息的时间戳不在OCR输出中(QQ窗口底部未捕获/时间戳渲染在消息下方),
|
||||
# 但问号是强用户查询信号,不应被上方旧时间戳"拖累"丢弃。
|
||||
# 后顾:仅当问号紧跟在最后一个时间戳之后(新消息在底部)时放行。
|
||||
# ⚠ timestamps 来自 normalized,搜索也在 normalized 中进行
|
||||
_last_ts = timestamps[-1]
|
||||
_last_ts_pos = normalized.rfind(_last_ts)
|
||||
_after_last_ts = normalized[_last_ts_pos + len(_last_ts):] if _last_ts_pos >= 0 else ''
|
||||
if '?' in _after_last_ts or '?' in _after_last_ts:
|
||||
logger.debug(f"[ocr] 过滤器1结果: 无日期+时间戳过期但最后时间戳后有问号(新查询),放行")
|
||||
self._msg_history.record_user_message(platform, stripped)
|
||||
return True
|
||||
# ⭐ 2026-08-29 修复:无日期+时间戳全部过期 → 必须丢弃,不可放行
|
||||
# QQ聊天窗口中历史消息(如12:08/12:24)不带日期,但时间戳准确且已过期(>300s)。
|
||||
# 原"OCR时间戳不准确"的假设会让这些老消息被当成新消息 → 触发自言自语。
|
||||
|
||||
Reference in New Issue
Block a user