From 7e62989702c26fb327a6a4d81cf02f21d3bd6261 Mon Sep 17 00:00:00 2001 From: Naer <88199249+V-YOP@users.noreply.github.com> Date: Thu, 19 Mar 2026 13:37:54 +0800 Subject: [PATCH] Fix payload handling for msg_id in QQ API Remove msg_id from payload to prevent errors with proactive tool-call path and avoid permission issues. --- .../sources/qqofficial/qqofficial_platform_adapter.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py b/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py index 7e31536a16..82a6afbacf 100644 --- a/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py +++ b/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py @@ -238,6 +238,9 @@ async def _send_by_session_common( ) elif session.message_type == MessageType.FRIEND_MESSAGE: + # 参考 https://bot.q.qq.com/wiki/develop/pythonsdk/api/message/post_message.html + # msg_id 缺失时认为是主动推送,而似乎至少在私聊上主动推送是没有被限制的,这里直接移除 msg_id 可以避免越权或 msg_id 不可用的bug + payload.pop("msg_id", None) payload["msg_seq"] = random.randint(1, 10000) if image_base64: media = await QQOfficialMessageEvent.upload_group_and_c2c_image( @@ -268,9 +271,6 @@ async def _send_by_session_common( if media: payload["media"] = media payload["msg_type"] = 7 - # QQ API rejects msg_id for media (video/file) messages sent - # via the proactive tool-call path; remove it to avoid 越权 error. - payload.pop("msg_id", None) if file_source: media = await QQOfficialMessageEvent.upload_group_and_c2c_media( send_helper, # type: ignore @@ -282,7 +282,6 @@ async def _send_by_session_common( if media: payload["media"] = media payload["msg_type"] = 7 - payload.pop("msg_id", None) ret = await QQOfficialMessageEvent.post_c2c_message( send_helper, # type: ignore