From 362250402139433d1fe47de634e54bb7ee208e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=AA=E8=AA=9E?= <167516635+YukiRa1n@users.noreply.github.com> Date: Fri, 2 Jan 2026 22:16:04 +0800 Subject: [PATCH] fix: retry failed due to a mismatch in the msg.id data type of a WeChat Official Account (#4292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题描述: - 控制台显示正常发送消息,但公众号未收到 - 处理时间 > 5秒的消息几乎总是失败(如 AI 图片生成) - 短消息(<5秒)正常工作 根本原因: msg.id 是整数类型,但字典 key 使用字符串类型,导致类型不匹配。 检查时整数无法匹配字符串 key,导致每次都创建新的 future, 微信重试时无法重用,最终导致响应失败。 修复内容: 将 msg.id 转换为字符串后再检查字典 if str(msg.id) in self.wexin_event_workers: 影响范围: - 修复了微信重试时无法正确重用 future 的问题 - AI 图片生成、长文本生成等耗时操作现在可以正常工作 - 仅影响微信公众号适配器,其他平台不受影响 Fixes #1679 --- .../sources/weixin_official_account/weixin_offacc_adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py b/astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py index d12285d68..2828c0392 100644 --- a/astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py +++ b/astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py @@ -191,7 +191,7 @@ class WeixinOfficialAccountPlatformAdapter(Platform): if self.active_send_mode: await self.convert_message(msg, None) else: - if msg.id in self.wexin_event_workers: + if str(msg.id) in self.wexin_event_workers: future = self.wexin_event_workers[str(cast(str | int, msg.id))] logger.debug(f"duplicate message id checked: {msg.id}") else: