任务#1441: 修复bot自言自语和双重回复问题

**问题1: 自言自语**
- OCR把bot自己的回复再读一遍,当成新消息触发二次回复
- 修复: 查库对比bot历史回复,重合率≥50%(高分消息)或≥70%(普通消息)则丢弃

**问题2: 双重回复**
- 用户操作电脑打断bot回复发送时,_last_hash_replied标志被重置,下次轮询重复触发
- 修复: 新增_reply_in_progress标志,回复进行中时跳过所有轮询处理

**修改文件:**
- monitor.py: 添加_reply_in_progress状态追踪+动态阈值bot消息过滤
- gui.py: 在回复执行前后设置/清除_reply_in_progress标志
- _keyword_scorer.py: 新增get_last_score()方法用于查询得分而不记录
This commit is contained in:
youpaishidifu
2026-08-22 10:50:56 +08:00
parent 1ab422cfd5
commit 9152c3529f
3 changed files with 51 additions and 7 deletions
+17
View File
@@ -187,6 +187,23 @@ class KeywordScorer:
finally:
conn.close()
def get_last_score(self, platform: str, text: str) -> int:
"""获取指定文本最近一次的关键词得分(不记录新行)"""
keywords = self.extract_keywords(text)
if not keywords:
return 0
conn = sqlite3.connect(self.db_path, check_same_thread=False)
try:
cursor = conn.execute("""
SELECT score FROM keyword_scores
WHERE platform = ? AND message_text = ?
ORDER BY id DESC LIMIT 1
""", (platform, text.strip()))
row = cursor.fetchone()
return row[0] if row else 0
finally:
conn.close()
def should_skip_message(self, text: str, platform: str,
ocr_time: Optional[str] = None,
threshold: int = 2) -> Tuple[bool, int, List[str]]: