fix(kb+filter): 修复管理员密码查询返回玩家端问题 + 问句豁免公共子串跳过

1. auto_reply.py: 管理员密码查询(含php)要求heading含"管理员",防止php.md玩家端被误选
2. monitor.py: Poll阶段回复公共子串跳过增加问句豁免,含疑问词的消息不再被误判为旧回复片段
This commit is contained in:
youpaishidifu
2026-08-13 17:17:28 +08:00
parent 8d0670ce81
commit 2a5f16ae1f
2 changed files with 11 additions and 1 deletions
+6
View File
@@ -175,6 +175,12 @@ class AutoReply:
if 'php' not in heading_clean:
logger.debug(f"php查询意图不匹配: query={query[:40]!r} heading={heading[:30]!r}")
return False
# 查询含"管理员密码"且含"php"时,heading必须含"管理员"(防止php.md玩家端被误选,应返回phpadmin.md)
# 例:"PHP默认的那管理后台管理密码是多少" → 应返回phpadmin.md(heading含"管理员"),而非php.md(玩家端)
if '管理员' in query and '密码' in query and 'php' in query.lower():
if '管理员' not in heading_clean:
logger.debug(f"管理员密码查询意图不匹配(玩家端): query={query[:40]!r} heading={heading[:30]!r}")
return False
# 查询含"管理员密码"且不含"php"时,heading必须含"密码"或"php"
# (防止beibao的"管理员密码qweasd"被误选,应返回phpadmin的"ypshidifu2026")
if '管理员' in query and '密码' in query and 'php' not in query.lower():
+5 -1
View File
@@ -7092,7 +7092,11 @@ class MessageMonitor:
continue
# _replied_texts 长公共子串检测:OCR 截取的碎片开头/结尾有噪声,精确/子串匹配失效
# 先试原始文本(含字母数字),再试 CJK-only(进一步降阈值)
if len(ts) > 8:
# ⭐ Task #1534: 问句豁免——用户提问即使与旧回复有部分匹配也放行
# 例:"PHP默认的那管理后台管理密码是多少,php有2种登陆模式..."
# 该问句与旧回复共享"php有2种登陆模式"子串,但不应被跳过
is_question = bool(re.search(r'[??]', ts)) or any(qw in ts for qw in ('吗', '呢', '多少', '怎么', '如何', '哪', '什么'))
if len(ts) > 8 and not is_question:
import difflib
matched_r = False
# 第一轮:原始文本匹配(阈值 6,OCR 噪声导致连续匹配可能中断)