fix: 群聊消息被混合乱码检测器误杀导致不回复
This commit is contained in:
+27
-5
@@ -5019,12 +5019,34 @@ class MessageMonitor:
|
||||
# 如"HHWH尸端自哪内柙登录槟J!" — Latin大写字母散落在CJK字符中间
|
||||
# 正常聊天中Latin缩写是连续块(如"登录PHP服务器"、"GTA5玩家")
|
||||
# 乱码特征:Latin大写被CJK分割成多个不连续块(≥2组)
|
||||
#
|
||||
# ⚠️ Task #1474 群聊例外(2026-08-09):
|
||||
# 群聊OCR文本天然包含多个用户名(C418minecraft、BXZYAE、youpaishidifu等)
|
||||
# 这些用户名分散在不同位置,会被误判为"混合文字乱码"。
|
||||
# 以下模式是群聊正常特征,不应判为乱码:
|
||||
# 1. @提及:@username
|
||||
# 2. QQ群名片/头衔:【...】Username 或 [...] Username
|
||||
# 3. 完整中文句子(含句末标点):说明是正常聊天而非乱码
|
||||
if re.search(r'[A-Z]', text) and re.search(r'[\u4e00-\u9fff]', text):
|
||||
_upper_groups = len(re.findall(r'[A-Z]+', text))
|
||||
if _upper_groups >= 2:
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到混合文字乱码({_upper_groups}组大写字母分散),"
|
||||
f"返回True: {text[:60]!r}")
|
||||
return True
|
||||
# ── 群聊正常模式排除 ──
|
||||
# 排除@提及(QQ群聊@用户是正常行为)
|
||||
if re.search(r'@[A-Za-z0-9_\u4e00-\u9fff]+', text):
|
||||
logger.debug(f"[ocr] 过滤器2: 检测到@提及模式,跳过混合乱码检测")
|
||||
pass # 不return,继续后续检查
|
||||
# 排除QQ群名片/头衔格式:【...】Username 或 [...]
|
||||
elif re.search(r'[【\[][^】\]]*[】\]]\s*[A-Za-z]', text):
|
||||
logger.debug(f"[ocr] 过滤器2: 检测到QQ群名片/头衔格式,跳过混合乱码检测")
|
||||
pass # 不return,继续后续检查
|
||||
# 排除含完整中文句子(有句末标点=正常聊天)
|
||||
elif re.search(r'[\u4e00-\u9fff]{4,}[。!?!?…]+$|\?$', text):
|
||||
logger.debug(f"[ocr] 过滤器2: 检测到完整中文句子,跳过混合乱码检测")
|
||||
pass # 不return,继续后续检查
|
||||
else:
|
||||
_upper_groups = len(re.findall(r'[A-Z]+', text))
|
||||
if _upper_groups >= 2:
|
||||
logger.debug(f"[ocr] 过滤器2结果: 检测到混合文字乱码({_upper_groups}组大写字母分散),"
|
||||
f"返回True: {text[:60]!r}")
|
||||
return True
|
||||
# ⭐ Task #1457: 360安全弹窗内容过滤(防误触发查库+回复)
|
||||
# 360安全卫士/杀毒弹窗常被OCR识别为用户消息,如"这是敲诈病毒,会勒索您的钱财"
|
||||
# 以下关键词覆盖360常见报毒/安全警告弹窗
|
||||
|
||||
Reference in New Issue
Block a user