From 3343fcce2259d075afe16e1a8e6187f02d313ee3 Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Tue, 7 Apr 2026 21:40:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(ReportDispatcher):=20=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=81=87=E8=B6=85=E6=97=B6=E4=B8=8D=E5=BA=94=E8=AF=A5=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E4=B8=8A=E4=BC=A0=E7=BE=A4=E7=9B=B8=E5=86=8C=E7=BE=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Bug] 聊天记录转发,群文件上传 Fixes #160 --- src/infrastructure/reporting/dispatcher.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/infrastructure/reporting/dispatcher.py b/src/infrastructure/reporting/dispatcher.py index 872187b..e168437 100644 --- a/src/infrastructure/reporting/dispatcher.py +++ b/src/infrastructure/reporting/dispatcher.py @@ -93,15 +93,19 @@ class ReportDispatcher: # image_url and html_content remain None # 4. 发送图片 + sent = False if image_url: caption = TraceContext.make_report_caption() sent = await self.message_sender.send_image_smart( group_id, image_url, caption, platform_id ) - if sent: - # 5. 发送成功后,尝试上传到群文件/群相册(静默处理) - await self._try_upload_image(group_id, image_url, platform_id) - return True + + # 5. 尝试上传到群文件/群相册(静默处理) + # 无论消息发送是否成功(如超时回退),只要图片生成了,就尝试备份到群文件 + await self._try_upload_image(group_id, image_url, platform_id) + + if sent: + return True # 6. 最终回退:如果图片发送失败(包括生成失败或发送接口报错),直接尝试发送文本报告 logger.warning(