fix: _is_markdown_document增强,拦截含'第X步'的bot回复碎片
问题:OCR把bot回复碎片'cdkl 1分 cdkz 2分 第三步:文件写好以后 游戏内/控制台执行/imp' 重新识别后进入队列,触发自动回复。_is_markdown_document漏检。 根因: 1. 第X步/步骤X检测用re.match行首匹配,碎片中'第三步'不在行首→漏网 2. 代码关键词列表缺少游戏服管理术语,只有1个命中(import不完整)不够阈值 修复: 1. 第X步/步骤X检测改为re.search全文匹配(用户日常不打'第X步',全文命中即判定bot回复) 2. 代码关键词列表增加:控制台/执行/导入/插件(游戏服管理术语,用户日常不打) commit: fcc2e51后同分支
This commit is contained in:
+9
-5
@@ -6647,11 +6647,13 @@ class MessageMonitor:
|
||||
logger.debug(f"[ocr] 过滤器3结果: 检测到Markdown标题语法,返回True")
|
||||
return True
|
||||
# 中文编号列表:第X步 / 步骤X(Bot md 回复常见,用户日常不打)
|
||||
if re.match(r'^第[一二三四五六七八九十百千万零\d]+步', text):
|
||||
logger.debug(f"[ocr] 过滤器3结果: 检测到中文编号列表,返回True")
|
||||
# ⭐ 2026-08-21 修复:OCR碎片把第X步拼到文本中部(如 'cdkl 1分 第三步:...'),
|
||||
# re.match行首匹配漏网 → 改用 re.search 全文匹配
|
||||
if re.search(r'第[一二三四五六七八九十百千万零\d]+步', text):
|
||||
logger.debug(f"[ocr] 过滤器3结果: 检测到中文编号列表(全文匹配),返回True")
|
||||
return True
|
||||
if re.match(r'^步骤[::]', text):
|
||||
logger.debug(f"[ocr] 过滤器3结果: 检测到步骤说明,返回True")
|
||||
if re.search(r'步骤[::]', text):
|
||||
logger.debug(f"[ocr] 过滤器3结果: 检测到步骤说明(全文匹配),返回True")
|
||||
return True
|
||||
# 行首列表项:短文本也检测(- 玩家义务 / * 注意)
|
||||
# 必须放 len<10 之前,否则 "- 玩家应尊重他"(8c) 漏网
|
||||
@@ -6702,7 +6704,9 @@ class MessageMonitor:
|
||||
if '**' in text:
|
||||
return True
|
||||
# 代码块内容检测:包含多个编程关键字(Bot md 回复常见,用户日常不打)
|
||||
code_keywords = ['import', 'def', 'class', 'function', 'return', 'print', 'if', 'for', 'while']
|
||||
# ⭐ 2026-08-21 扩展关键词列表:增加游戏服管理术语(控制台/执行/导入/插件)
|
||||
code_keywords = ['import', 'def', 'class', 'function', 'return', 'print', 'if', 'for', 'while',
|
||||
'控制台', '执行', '导入', '插件']
|
||||
code_keyword_count = sum(1 for kw in code_keywords if re.search(r'\b' + kw + r'\b', text))
|
||||
if code_keyword_count >= 2:
|
||||
logger.debug(f"[ocr] 过滤器3结果: 检测到代码块内容({code_keyword_count}个编程关键字),返回True")
|
||||
|
||||
Reference in New Issue
Block a user