@
fix: 微信颜色检测放宽+KB精确匹配+自动回复重试 1. monitor.py - 微信白色气泡检测阈值放宽(>=245->>=240, >=3->>=2) 适配新版微信UI颜色变化,减少漏检 2. knowledge_base.py - 精确短语匹配(5x加分)+子串匹配(2.5x/1.5x) 防止查询被不相关文档抢走高分 3. gui.py - 自动回复发送失败重试(3次/5秒间隔) 连续失败退避本轮,避免反复抢焦点 4. .gitignore - 补充build目录下的证书/构建产物 @
This commit is contained in:
@@ -383,10 +383,14 @@ class MsgBotApp(ctk.CTk):
|
||||
self.after(200, self._flush_reply_queue)
|
||||
|
||||
def _execute_reply(self, data: dict):
|
||||
"""主线程执行自动回复发送。加上发送锁防止监控轮询干扰。"""
|
||||
"""主线程执行自动回复发送。加上发送锁防止监控轮询干扰。
|
||||
自动重试:失败后延缓5秒重试,连续3次失败视为用户接管,退避本轮。
|
||||
"""
|
||||
platform = data["platform"]
|
||||
answer = data["answer"]
|
||||
sender = data.get("sender")
|
||||
max_retries = 3
|
||||
retry_delay = 5 # 秒
|
||||
|
||||
# 设发送锁,阻止监控轮询切走焦点
|
||||
self.monitor._sending_event.set()
|
||||
@@ -396,12 +400,19 @@ class MsgBotApp(ctk.CTk):
|
||||
found = self.monitor._search_contact(platform, sender)
|
||||
if not found:
|
||||
self._log(f"[{platform}] ⚠ 找不到联系人 {sender},当前会话回复")
|
||||
# 发送(主线程 SetForegroundWindow 可靠,且不受监控干扰)
|
||||
ok = self.monitor._paste_and_send(platform, answer)
|
||||
if ok:
|
||||
self._log(f"[{platform}] 🤖 已自动回复: {answer[:60]}...")
|
||||
else:
|
||||
self._log(f"[{platform}] ⚠ 自动回复发送失败(目标窗口无法带到前台)")
|
||||
|
||||
# 带重试的发送逻辑
|
||||
for attempt in range(max_retries):
|
||||
ok = self.monitor._paste_and_send(platform, answer)
|
||||
if ok:
|
||||
self._log(f"[{platform}] 🤖 已自动回复: {answer[:60]}...")
|
||||
return # 成功直接退出
|
||||
else:
|
||||
if attempt < max_retries - 1:
|
||||
self._log(f"[{platform}] ⚠ 自动回复发送失败,{retry_delay}秒后重试({attempt+1}/{max_retries})")
|
||||
time.sleep(retry_delay)
|
||||
else:
|
||||
self._log(f"[{platform}] ⚠ 自动回复发送失败(连续{max_retries}次),用户可能在接管,本轮跳过")
|
||||
finally:
|
||||
self.monitor._sending_event.clear()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user