fix: Markdown斜体过滤失效,*内容*应被丢弃却入库了

根因:_is_markdown_document函数只检测**加粗语法,未检测*斜体*语法。
用户发'*@C418minecraft 小姐姐, 来测试一下Robot*'被当作正常消息入库。

修复:增加斜体标记检测(*content*),与**加粗**并列过滤。
bot回复用*斜体*是Markdown标准语法,用户日常聊天不打。

回归:斜体*content*→丢弃,**加粗**→丢弃,普通消息→保留
This commit is contained in:
youpaishidifu
2026-08-20 09:12:31 +08:00
parent 29f3738c09
commit cf9f269eca
+5 -2
View File
@@ -6573,8 +6573,8 @@ class MessageMonitor:
# |表格行:| 开头和结尾 # |表格行:| 开头和结尾
if re.match(r'^\|.+\|$', text): if re.match(r'^\|.+\|$', text):
return True return True
# *斜体* / ***粗斜体* 或任何 ** 裸标记 # **加粗** / *斜体* 语法:短文本也检测(bot md 回复标配,用户日常不用)
# 用户日常对话从不打 **,只可能是 bot md 回复 # 用户日常对话从不打 *...*, 只可能是 bot md 回复
if '**' in text: if '**' in text:
return True return True
if len(text) < 10: if len(text) < 10:
@@ -6592,6 +6592,9 @@ class MessageMonitor:
# 包含代码块标记 ``` 或 `code` # 包含代码块标记 ``` 或 `code`
if re.search(r'`{1,3}', text): if re.search(r'`{1,3}', text):
return True return True
# *斜体* 标记:*content* 或 ***粗斜体***
if re.search(r'\*[^*\n]+\*', text):
return True
# 连续 3+ 行包含 markdown 特征:| 表格、--- 分隔线、> 引用 # 连续 3+ 行包含 markdown 特征:| 表格、--- 分隔线、> 引用
pipes = text.count('|') pipes = text.count('|')
if pipes >= 3: if pipes >= 3: