修复:KB同义词(权力→权利) + 微信"关闭"按钮过滤(NFKC标准化+行尾跳过)
This commit is contained in:
@@ -33,6 +33,7 @@ class KnowledgeBase:
|
||||
SYNONYMS = {
|
||||
"登陆": ["登录"],
|
||||
"版号": ["版本号"],
|
||||
"权力": ["权利"],
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
||||
+12
-1
@@ -4,6 +4,7 @@ import time
|
||||
import logging
|
||||
import threading
|
||||
import traceback
|
||||
import unicodedata
|
||||
from typing import Optional, Callable, List
|
||||
|
||||
logging.getLogger("comtypes").setLevel(logging.WARNING)
|
||||
@@ -1244,6 +1245,8 @@ class MessageMonitor:
|
||||
"""过滤机器人/系统消息,不作为用户消息处理。"""
|
||||
if not text:
|
||||
return True
|
||||
# NFKC 标准化:去除 UIA/OCR 夹杂的零宽字符、不可见 Unicode
|
||||
text = unicodedata.normalize('NFKC', text)
|
||||
# 系统前缀/标记
|
||||
system_markers = [
|
||||
"✅", "❌", "📝", "🔍", "📄", "➡", "♡", "✿",
|
||||
@@ -1700,7 +1703,15 @@ class MessageMonitor:
|
||||
name = item.Name
|
||||
if name and name.strip():
|
||||
lines = [l.strip() for l in name.split("\n") if l.strip()]
|
||||
if lines:
|
||||
if not lines:
|
||||
continue
|
||||
# NFKC 标准化(去除零宽字符后比较)
|
||||
norm = unicodedata.normalize('NFKC', lines[-1])
|
||||
# 跳过末尾按钮文字(微信消息项的"关闭"等)和时间戳
|
||||
ui_known = {"关闭", "发送", "接收", "取消", "确定", "更多"}
|
||||
if len(lines) >= 2 and (norm in ui_known or re.match(r'^\d{1,2}:\d{2}', norm)):
|
||||
texts.append(lines[-2])
|
||||
else:
|
||||
texts.append(lines[-1])
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user