fix: 修复KB搜索回复内容不对和历史消息重复处理问题

问题1:回复内容不对
- protect.md的section heading包含整个section内容(含<br>和列表标记),导致下载意图加权检查误匹配
- 修复:增加检查,如果heading含<br>或列表标记,说明是复合标题,需检查下载是否出现在标题主体部分

问题2:历史消息重复处理
- 基线轮处理后seen.discard(item)从持久化集合中移除,但未重新加入_seen_messages
- 修复:基线轮处理后增加self._seen_messages.add(item),确保下次轮询不再处理此消息
This commit is contained in:
youpaishidifu
2026-08-15 10:13:55 +08:00
parent ad9b1dc59b
commit ae27ee91cd
3 changed files with 27 additions and 3 deletions
+11
View File
@@ -270,7 +270,18 @@ class AutoReply:
# 修复"在哪儿能下到那登录插件啊?"——原文无"下载"二字(口语"下到"),
# q_mean 不含"下载","## 4. 下载地址"heading 虽有"下载"仍被相关性拒绝,
# 导致误回"插件设置"(body 恰含"登录超时秒数")
# ⚠ 只检查真正的标题行:如果heading含<br>或列表标记,说明是复合标题,
# 需检查"下载"是否出现在标题主体部分(<br>之前),而非列表项内容
_download_match = False
if any(w in query for w in ('下载', '下到', '哪下', '在哪下', '怎么下')) and '下载' in heading_clean:
if '<br>' not in heading and '- [' not in heading and '|-' not in heading:
_download_match = True
else:
# 复合标题:检查标题主体部分(<br>或列表之前)是否含"下载"
_title_part = re.split(r'<br>|- |\|-', heading_clean)[0]
if '下载' in _title_part:
_download_match = True
if _download_match:
logger.debug(f"下载意图放行: query={query[:30]!r} heading={heading[:30]!r}")
return True