From af3b7301062a12025d7bb24592d6b1aaf035ab5a Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Sun, 26 Jul 2026 13:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=87=E6=BB=A4=E8=BF=87?= =?UTF-8?q?=E5=AE=BD+=E8=A3=81=E5=89=AA=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. _is_system_message 中系统模式匹配从 in 改为 startswith 否则 OCR 捕获的多行合一文本只要包含答:就被整行丢弃 用户消息你叫啥名字啊?混在文本里一起被杀 2. cap_left 从 25% → 35% 25% 覆盖到联系人列表,OCR 读出多面板混合文本 35% 从会话列表偏右到消息面板,减少噪声 3. 保留上轮加的前台切换和 debug 日志 --- monitor.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/monitor.py b/monitor.py index 1cc8626..7e32204 100644 --- a/monitor.py +++ b/monitor.py @@ -570,8 +570,9 @@ class MessageMonitor: # 先切 QQ 到前台再截屏,避免 CMD 窗口遮挡→OCR 读到终端文字 self._ensure_foreground(hwnd) time.sleep(0.15) - # 左边界调到 33%,捕获更靠左的消息文字 - cap_left = int(left + win_w * 0.25) + # 左边界 35%,从消息面板左侧开始(联系人/会话列表 / 消息面板分界约 55%) + # 但消息正文在面板左侧,因此稍左移 35% 覆盖消息文字左侧边缘 + cap_left = int(left + win_w * 0.35) cap_top = top + max(40, int(win_h * 0.04)) # 标题栏下方 cap_right = int(left + win_w * 0.95) # 跳过滚动条 cap_bottom = bottom - max(100, int(win_h * 0.10)) # 输入框上方 @@ -946,19 +947,20 @@ class MessageMonitor: for n in qq_ui_noise: if text == n: return True - # 系统事件模板 + # 系统事件模板 — 注意:用 startswith 而非 in,避免混合文本(OCR 多行合一)误杀 system_patterns = [ "已自动回复", "知识库中未找到", "找到相关结果", "监控已启动", "监控已暂停", "设置已保存", "🤖", "找不到联系人", "当前会话回复", "自动回复触发", "匹配度", - # KB 文档内容格式(机器人回复内容特征) + # KB 文档内容格式(机器人回复格式),OCR 可能把用户消息+KB 回复混成一行 + # 只有全行以"答:"开头才过滤,内含"答:"的混合文本不过滤 "答:", # 纯系统命令反馈 "PS ", "❯ ", "$ ", ] for p in system_patterns: - if p in text: + if text.startswith(p): return True # 纯时间格式(不含消息内容) if re.match(r'^\d{1,2}:\d{2}', text):