修复OCR重复回复+KB后台密码匹配+QQ UI过滤'有人@我'
This commit is contained in:
@@ -142,6 +142,15 @@ class AutoReply:
|
||||
)
|
||||
return False
|
||||
|
||||
# ⭐ 后台/前台关键词区分:查询含"后台"但文档不含"后台"→ 不相关
|
||||
full = heading_clean + " " + title.lower() + " " + body_clean[:800]
|
||||
if "后台" in query and "后台" not in full:
|
||||
logger.debug(f"后台关键词缺失: query={query[:40]!r} doc={doc.get('heading', '')[:30]!r}")
|
||||
return False
|
||||
if "前台" in query and "前台" not in full:
|
||||
logger.debug(f"前台关键词缺失: query={query[:40]!r} doc={doc.get('heading', '')[:30]!r}")
|
||||
return False
|
||||
|
||||
if has_ht or has_body:
|
||||
return True
|
||||
|
||||
|
||||
+31
@@ -177,6 +177,8 @@ _UI_EXACT_BLOCKLIST = frozenset({
|
||||
'正在加载页面,请稍后',
|
||||
# — Smart-Dump 漏网 —
|
||||
'手机',
|
||||
# — QQ 系统通知 —
|
||||
'有人@我',
|
||||
})
|
||||
|
||||
# ===== 主动防御: UI 子串黑名单(含其中任何子串即跳过)=====
|
||||
@@ -398,6 +400,8 @@ class MessageMonitor:
|
||||
self._seen_messages: set = set()
|
||||
# 已回复文本的永久集—永不裁切(剪贴板读到自己回复时必拦)
|
||||
self._replied_texts: set = set()
|
||||
# 最近已处理的消息(用于5分钟内OCR重复识别去重)
|
||||
self._recent_processed_messages = [] # list of (text, timestamp)
|
||||
# 上次回复时间戳(冷却期内跳过该平台 poll)
|
||||
self._last_reply_time: dict = {}
|
||||
# 同平台新消息冷却:同一 poll 或相邻 poll 内多条消息只处理第一条
|
||||
@@ -7092,6 +7096,33 @@ class MessageMonitor:
|
||||
seen.add(cleaned_item)
|
||||
self._last_new_msg_time[platform] = time.time()
|
||||
continue # 跳过本条消息,处理下一条
|
||||
# ⭐ 5分钟内OCR重复识别去重:同一消息被OCR识别两次(乱码+正确文本),相似度>=90%则跳过
|
||||
now = time.time()
|
||||
# 清理过期条目
|
||||
self._recent_processed_messages = [
|
||||
(txt, ts) for txt, ts in self._recent_processed_messages
|
||||
if now - ts <= 300
|
||||
]
|
||||
# 检查是否与最近处理的消息相似
|
||||
is_duplicate = False
|
||||
for recent_text, recent_ts in self._recent_processed_messages:
|
||||
if now - recent_ts > 300:
|
||||
continue
|
||||
if len(recent_text) < 4 or len(cleaned_item) < 4:
|
||||
continue
|
||||
# 快速长度剪枝
|
||||
if abs(len(recent_text) - len(cleaned_item)) > max(len(recent_text), len(cleaned_item)) * 0.4:
|
||||
continue
|
||||
sim = SequenceMatcher(None, cleaned_item, recent_text).quick_ratio()
|
||||
if sim >= 0.9:
|
||||
logger.info(f"[{platform}] OCR重复识别去重: 相似度{sim:.2%},跳过: {cleaned_item[:60]}")
|
||||
is_duplicate = True
|
||||
break
|
||||
if is_duplicate:
|
||||
self._last_new_msg_time[platform] = time.time()
|
||||
continue
|
||||
# 添加到最近处理列表
|
||||
self._recent_processed_messages.append((cleaned_item, now))
|
||||
self._last_new_msg_time[platform] = time.time()
|
||||
self._last_msg[platform] = cleaned_item
|
||||
engine_tag = self._last_chosen_engine.get(platform, "")
|
||||
|
||||
Reference in New Issue
Block a user