diff --git a/monitor.py b/monitor.py index 093fd25..4ce4098 100644 --- a/monitor.py +++ b/monitor.py @@ -1704,6 +1704,16 @@ class MessageMonitor: logger.debug(f"[{platform}] OCR 过滤: 斜线英文命令 line={line!r}") continue + # —— OCR 误读斜线为 I/J:"/sdfl"→"Isdfl", "/import"→"Jimport" —— + # 特征1:含已知命令关键词(sdfl/sdf1),零误杀 + if re.match(r'^[A-Za-z]', line) and ('sdfl' in line.lower() or 'sdf1' in line.lower()): + logger.debug(f"[{platform}] OCR 过滤: 变形命令(sdfl) line={line!r}") + continue + # 特征2:大写字母+4+小写 + CJK + >10 字符 → 非自然对话 + if re.match(r'^[A-Z][a-z]{4,}', line) and re.search(r'[\u4e00-\u9fff]', line) and len(line) > 10: + logger.debug(f"[{platform}] OCR 过滤: 变形命令(大写+字母) line={line!r}") + continue + # —— JSON/YAML 碎片兜底:OCR 截屏混入配置面板 —— # 行首是 "key": value 或 key: value(YAML)→ 配置面板碎片 if re.match(r'^["\']?[a-zA-Z_][\w]*["\']?\s*:\s*["\d\[\{tfn]', line): @@ -3392,6 +3402,13 @@ class MessageMonitor: if re.match(r'^/[A-Za-z]', ts): logger.debug(f"[{platform}] Poll过滤: 斜线英文命令 ts={ts!r}") continue + # === OCR 误读斜线为 I/J:"/sdfl"→"Isdfl", "/import"→"Jimport" === + if re.match(r'^[A-Za-z]', ts) and ('sdfl' in ts.lower() or 'sdf1' in ts.lower()): + logger.debug(f"[{platform}] Poll过滤: 变形命令(sdfl) ts={ts!r}") + continue + if re.match(r'^[A-Z][a-z]{4,}', ts) and re.search(r'[\u4e00-\u9fff]', ts) and len(ts) > 10: + logger.debug(f"[{platform}] Poll过滤: 变形命令(大写+字母) ts={ts!r}") + continue # === 结构化数据面板:QQ/TIM 指令面板(指令:/rtp 权限类型:玩家 图标:标题:)=== colon_kv = re.findall(r'[\u4e00-\u9fff]{1,6}[::](?:[A-Za-z0-9/]|[\u4e00-\u9fff])', ts) if len(colon_kv) >= 3: @@ -3535,11 +3552,23 @@ class MessageMonitor: # 有纯粹的新文本 → 逐一报告(同平台同一 poll 内只处理第一条) first = True + + # ⭐ 首次成功轮询(上次无消息→本次有消息):拦截历史基线 + is_baseline = self._last_new_msg_time.get(platform, 0) == 0 + if is_baseline: + logger.info(f"[{platform}] 首次消息→基线拦截({len(new_items)}条): {new_items[0][:60]}") + for item in new_items: if not first: logger.debug(f"[{platform}] 同poll第条,跳过防多发: {item[:40]}") continue first = False # 只处理第一条 + if is_baseline: + # 基线轮:日志标记但不触发回复,添加到 seen 防止下次再来 + logger.info(f"[{platform}] 基线↺(不回复): {item[:60]}") + seen.add(item) + self._last_new_msg_time[platform] = time.time() + continue self._last_new_msg_time[platform] = time.time() self._last_msg[platform] = item engine_tag = self._last_chosen_engine.get(platform, "")