mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-18 02:00:09 +08:00
fix: retry failed due to a mismatch in the msg.id data type of a WeChat Official Account (#4292)
问题描述: - 控制台显示正常发送消息,但公众号未收到 - 处理时间 > 5秒的消息几乎总是失败(如 AI 图片生成) - 短消息(<5秒)正常工作 根本原因: msg.id 是整数类型,但字典 key 使用字符串类型,导致类型不匹配。 检查时整数无法匹配字符串 key,导致每次都创建新的 future, 微信重试时无法重用,最终导致响应失败。 修复内容: 将 msg.id 转换为字符串后再检查字典 if str(msg.id) in self.wexin_event_workers: 影响范围: - 修复了微信重试时无法正确重用 future 的问题 - AI 图片生成、长文本生成等耗时操作现在可以正常工作 - 仅影响微信公众号适配器,其他平台不受影响 Fixes #1679
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user