From 3cdfd322256c015ef9de0ea93d5766687449f8f3 Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Sun, 16 Aug 2026 15:32:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(monitor):=20=E7=AD=96=E7=95=A53=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=BE=B9=E7=95=8C=E6=A3=80=E6=9F=A5=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E8=AF=AF=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:'? 插件下载见github'这种问句前无内容的情况也会触发剥离 修复: 1. 要求问句前至少有8个字符(避免单字符问句误触发) 2. 要求问句前至少有4个中文字符(确保是完整问句) 3. 要求问句后至少有4个中文字符(确保尾部有足够匹配内容) 测试覆盖: - ✓ 污染查询正确剥离 - ✓ 正常查询保持不变 - ✓ 边界情况不再误触发 --- monitor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index 8c99911..e1fbd03 100644 --- a/monitor.py +++ b/monitor.py @@ -4770,10 +4770,14 @@ class MessageMonitor: # 使用纯中文相似度匹配,抵抗OCR噪声和英文/数字干扰 if not stripped_bot: q_mark_pos = max(ts.find('?'), ts.find('?')) - if q_mark_pos >= 0 and q_mark_pos < len(ts) - 15: + # 确保问句前有足够内容(避免"? 插件下载..."这种误触发) + if q_mark_pos >= 0 and q_mark_pos >= 8 and q_mark_pos < len(ts) - 15: + before_q = ts[:q_mark_pos] after_q = ts[q_mark_pos + 1:] + # 问句前必须有足够中文内容(至少4个汉字) + before_chinese = re.sub(r'[^\u4e00-\u9fff]', '', before_q) after_chinese = re.sub(r'[^\u4e00-\u9fff]', '', after_q) - if len(after_chinese) >= 4: # 尾部有足够中文内容 + if len(before_chinese) >= 4 and len(after_chinese) >= 4: for r in replied: if len(r) < 10: continue