fix(send_api): 忽略对 notice 虚拟消息的引用以防误用
This commit is contained in:
@@ -294,10 +294,16 @@ async def _send_to_target(
|
|||||||
if anchor_message:
|
if anchor_message:
|
||||||
reply_to_platform_id = f"{anchor_message.chat_info.platform}:{anchor_message.user_info.user_id}"
|
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}
|
base_segment: dict[str, Any] = {"type": message_type, "data": content}
|
||||||
message_segment: dict[str, Any]
|
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 = {
|
message_segment = {
|
||||||
"type": "seglist",
|
"type": "seglist",
|
||||||
"data": [
|
"data": [
|
||||||
|
|||||||
@@ -168,7 +168,9 @@ class NoticeHandler:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if not handled_segment or not user_info:
|
if not handled_segment or not user_info:
|
||||||
logger.warning("notice处理失败或不支持")
|
logger.debug(
|
||||||
|
f"忽略 notice:type={notice_type}(无有效段/用户信息,可能为被禁用、过滤或自回声)"
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 使用 MessageBuilder 构建消息
|
# 使用 MessageBuilder 构建消息
|
||||||
|
|||||||
Reference in New Issue
Block a user