From 04b810e3118d6e9bd663ca81855599671fcff25c Mon Sep 17 00:00:00 2001 From: LuiKlee Date: Wed, 17 Dec 2025 23:18:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(send=5Fapi):=20=E5=BF=BD=E7=95=A5=E5=AF=B9?= =?UTF-8?q?=20notice=20=E8=99=9A=E6=8B=9F=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E4=BB=A5=E9=98=B2=E8=AF=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin_system/apis/send_api.py | 8 +++++++- .../napcat_adapter/src/handlers/to_core/notice_handler.py | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugin_system/apis/send_api.py b/src/plugin_system/apis/send_api.py index d579aa696..ced68f965 100644 --- a/src/plugin_system/apis/send_api.py +++ b/src/plugin_system/apis/send_api.py @@ -294,10 +294,16 @@ async def _send_to_target( if anchor_message: reply_to_platform_id = f"{anchor_message.chat_info.platform}:{anchor_message.user_info.user_id}" + # 如果引用的是 notice 虚拟消息,避免构造引用段,防止误用 + effective_set_reply = set_reply + if anchor_message and getattr(anchor_message, "message_id", None) == "notice": + logger.debug("[SendAPI] 检测到对 notice 虚拟消息的引用,已忽略引用并直接发送内容") + effective_set_reply = False + base_segment: dict[str, Any] = {"type": message_type, "data": content} message_segment: dict[str, Any] - if set_reply and anchor_message and anchor_message.message_id: + if effective_set_reply and anchor_message and anchor_message.message_id: message_segment = { "type": "seglist", "data": [ diff --git a/src/plugins/built_in/napcat_adapter/src/handlers/to_core/notice_handler.py b/src/plugins/built_in/napcat_adapter/src/handlers/to_core/notice_handler.py index 1b235a735..731b4f1e7 100644 --- a/src/plugins/built_in/napcat_adapter/src/handlers/to_core/notice_handler.py +++ b/src/plugins/built_in/napcat_adapter/src/handlers/to_core/notice_handler.py @@ -168,7 +168,9 @@ class NoticeHandler: return None if not handled_segment or not user_info: - logger.warning("notice处理失败或不支持") + logger.debug( + f"忽略 notice:type={notice_type}(无有效段/用户信息,可能为被禁用、过滤或自回声)" + ) return None # 使用 MessageBuilder 构建消息