fix: Markdown斜体过滤失效,*内容*应被丢弃却入库了
根因:_is_markdown_document函数只检测**加粗语法,未检测*斜体*语法。 用户发'*@C418minecraft 小姐姐, 来测试一下Robot*'被当作正常消息入库。 修复:增加斜体标记检测(*content*),与**加粗**并列过滤。 bot回复用*斜体*是Markdown标准语法,用户日常聊天不打。 回归:斜体*content*→丢弃,**加粗**→丢弃,普通消息→保留
This commit is contained in:
+5
-2
@@ -6573,8 +6573,8 @@ class MessageMonitor:
|
||||
# |表格行:| 开头和结尾
|
||||
if re.match(r'^\|.+\|$', text):
|
||||
return True
|
||||
# *斜体* / ***粗斜体* 或任何 ** 裸标记
|
||||
# 用户日常对话从不打 **,只可能是 bot md 回复
|
||||
# **加粗** / *斜体* 语法:短文本也检测(bot md 回复标配,用户日常不用)
|
||||
# 用户日常对话从不打 *...*, 只可能是 bot md 回复
|
||||
if '**' in text:
|
||||
return True
|
||||
if len(text) < 10:
|
||||
@@ -6592,6 +6592,9 @@ class MessageMonitor:
|
||||
# 包含代码块标记 ``` 或 `code`
|
||||
if re.search(r'`{1,3}', text):
|
||||
return True
|
||||
# *斜体* 标记:*content* 或 ***粗斜体***
|
||||
if re.search(r'\*[^*\n]+\*', text):
|
||||
return True
|
||||
# 连续 3+ 行包含 markdown 特征:| 表格、--- 分隔线、> 引用
|
||||
pipes = text.count('|')
|
||||
if pipes >= 3:
|
||||
|
||||
Reference in New Issue
Block a user