diff --git a/auto_reply.py b/auto_reply.py index 7178086..9cd991e 100644 --- a/auto_reply.py +++ b/auto_reply.py @@ -49,6 +49,25 @@ class AutoReply: f"[{platform}] 匹配度 {score:.2f} < 阈值 {self._min_score},跳过回复" ) return None + + # ⭐ Task #1741: 闲聊消息检测——无查询意图的陈述句直接跳过 + # 特征:无疑问词、无查询动词、无具体主题词(插件名/功能名) + # 例:"正常我们打88折"、"黑奴给1000%折扣" → 纯聊天,无查询意图 + _question_marks = ['?', '?', '吗', '呢', '什么', '怎么', '如何', '哪', '多少', '几', '为什么', '是不是', '有没有', '能否', '可以'] + _query_verbs = ['查', '问', '看', '了解', '咨询', '知道', '怎么', '如何', '在哪', '哪里', '多少'] + _has_question = any(q in msg for q in _question_marks) + _has_query_intent = any(v in msg for v in _query_verbs) + + # 提取核心名词(插件名、功能名等) + import jieba + _words = list(jieba.cut(msg)) + _nouns = [w for w in _words if len(w) >= 2 and not w.strip('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')] + _has_topic = any(n in _nouns for n in ['插件', '游戏', '配置', '绑定', '下载', '安装', '功能', '操作']) + + if not _has_question and not _has_query_intent and not _has_topic: + logger.debug(f"[{platform}] 闲聊消息检测:无查询意图,跳过KB搜索 | msg={msg[:40]!r}") + return None + # 内容相关性检查:查询词与匹配文档至少有一个共同2字+词,防偶然匹配 if not self._has_content_relevance(msg, top_doc, score): heading = top_doc.get("heading", "")[:40]