From 80bc8519c141800c83bd956d96f49a949ed82e8e Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Fri, 21 Aug 2026 10:01:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BAMarkdown=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=99=A8=E6=A3=80=E6=B5=8B=E4=B8=AD=E6=96=87=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=92=8C=E4=BB=A3=E7=A0=81=E5=9D=97=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=8C=E9=98=B2=E6=AD=A2Bot=E8=87=AA=E8=A8=80?= =?UTF-8?q?=E8=87=AA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitor.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/monitor.py b/monitor.py index b21867b..527c7c5 100644 --- a/monitor.py +++ b/monitor.py @@ -6529,6 +6529,13 @@ class MessageMonitor: if re.match(r'^#{1,6}(?:\s|\[|[\u4e00-\u9fff])', text): 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") + return True + if re.match(r'^步骤[::]', text): + logger.debug(f"[ocr] 过滤器3结果: 检测到步骤说明,返回True") + return True # 行首列表项:短文本也检测(- 玩家义务 / * 注意) # 必须放 len<10 之前,否则 "- 玩家应尊重他"(8c) 漏网 if re.match(r'^[\-\*]\s', text): @@ -6577,6 +6584,16 @@ class MessageMonitor: # 用户日常对话从不打 *...*, 只可能是 bot md 回复 if '**' in text: return True + # 代码块内容检测:包含多个编程关键字(Bot md 回复常见,用户日常不打) + 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") + return True + # 文件扩展名检测(Bot md 回复中常引用文件) + if re.search(r'\S+\.(txt|json|yml|yaml|md|py|js|ts|html|css|xml|java|c|cpp|h|rs|go|sh|bat|cmd)\b', text): + logger.debug(f"[ocr] 过滤器3结果: 检测到文件扩展名,返回True") + return True if len(text) < 10: logger.debug(f"[ocr] 过滤器3结果: 短文本(<10)无Markdown特征,返回False") return False