From 7c5958a81da8fdde488991443b05eeaf12ae7e87 Mon Sep 17 00:00:00 2001 From: NanoRocky <76585834+NanoRocky@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:50:41 +0800 Subject: [PATCH 1/3] Fix Register_Stage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit · 补全 JSON 消息判断,修复发送 JSON 消息时遇到 “消息为空,跳过发送阶段” 的问题。 · 顺带补全其它消息类型判断。 Co-authored-by: Pizero --- astrbot/core/pipeline/respond/stage.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/astrbot/core/pipeline/respond/stage.py b/astrbot/core/pipeline/respond/stage.py index b4a7ee7fa..502e3ba7e 100644 --- a/astrbot/core/pipeline/respond/stage.py +++ b/astrbot/core/pipeline/respond/stage.py @@ -33,6 +33,16 @@ class RespondStage(Stage): Comp.Nodes: lambda comp: bool(comp.nodes), # 多个转发节点 Comp.File: lambda comp: bool(comp.file_ or comp.url), Comp.WechatEmoji: lambda comp: comp.md5 is not None, # 微信表情 + Comp.Json: lambda comp: bool(comp.data), # Json 卡片 + Comp.Share: lambda comp: bool(comp.url) or bool(comp.title), + Comp.Music: lambda comp: (comp.id and comp._type and comp._type != 'custom') or (comp._type == 'custom' and comp.url and comp.audio and comp.title), # 音乐分享 + Comp.Forward: lambda comp: bool(comp.id), # 合并转发 + Comp.Location: lambda comp: bool(comp.lat is not None and comp.lon is not None), # 位置 + Comp.Contact: lambda comp: bool(comp._type and comp.id), # 推荐好友 or 群 + Comp.Shake: lambda _: True, # 窗口抖动(戳一戳) + Comp.Dice: lambda _: True, # 掷骰子魔法表情 + Comp.RPS: lambda _: True, # 猜拳魔法表情 + Comp.Unknown: lambda comp: bool(comp.text and comp.text.strip()), } async def initialize(self, ctx: PipelineContext) -> None: From 159cc1f7119c22e6d6fee117f6698c0bc20c7db8 Mon Sep 17 00:00:00 2001 From: NanoRocky <76585834+NanoRocky@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:59:06 +0800 Subject: [PATCH 2/3] Fix formatting and comments in stage.py --- astrbot/core/pipeline/respond/stage.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/astrbot/core/pipeline/respond/stage.py b/astrbot/core/pipeline/respond/stage.py index 502e3ba7e..bc1e6055f 100644 --- a/astrbot/core/pipeline/respond/stage.py +++ b/astrbot/core/pipeline/respond/stage.py @@ -33,15 +33,15 @@ class RespondStage(Stage): Comp.Nodes: lambda comp: bool(comp.nodes), # 多个转发节点 Comp.File: lambda comp: bool(comp.file_ or comp.url), Comp.WechatEmoji: lambda comp: comp.md5 is not None, # 微信表情 - Comp.Json: lambda comp: bool(comp.data), # Json 卡片 + Comp.Json: lambda comp: bool(comp.data), # Json 卡片 Comp.Share: lambda comp: bool(comp.url) or bool(comp.title), - Comp.Music: lambda comp: (comp.id and comp._type and comp._type != 'custom') or (comp._type == 'custom' and comp.url and comp.audio and comp.title), # 音乐分享 - Comp.Forward: lambda comp: bool(comp.id), # 合并转发 - Comp.Location: lambda comp: bool(comp.lat is not None and comp.lon is not None), # 位置 - Comp.Contact: lambda comp: bool(comp._type and comp.id), # 推荐好友 or 群 - Comp.Shake: lambda _: True, # 窗口抖动(戳一戳) - Comp.Dice: lambda _: True, # 掷骰子魔法表情 - Comp.RPS: lambda _: True, # 猜拳魔法表情 + Comp.Music: lambda comp: (comp.id and comp._type and comp._type != 'custom') or (comp._type == 'custom' and comp.url and comp.audio and comp.title), # 音乐分享 + Comp.Forward: lambda comp: bool(comp.id), # 合并转发 + Comp.Location: lambda comp: bool(comp.lat is not None and comp.lon is not None), # 位置 + Comp.Contact: lambda comp: bool(comp._type and comp.id), # 推荐好友 or 群 + Comp.Shake: lambda _: True, # 窗口抖动(戳一戳) + Comp.Dice: lambda _: True, # 掷骰子魔法表情 + Comp.RPS: lambda _: True, # 猜拳魔法表情 Comp.Unknown: lambda comp: bool(comp.text and comp.text.strip()), } From 7d6e699473f6dd4306803b16b0dca0f69b7e2712 Mon Sep 17 00:00:00 2001 From: NanoRocky <76585834+NanoRocky@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:09:15 +0800 Subject: [PATCH 3/3] Format stage.py --- astrbot/core/pipeline/respond/stage.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/astrbot/core/pipeline/respond/stage.py b/astrbot/core/pipeline/respond/stage.py index bc1e6055f..72e853ffc 100644 --- a/astrbot/core/pipeline/respond/stage.py +++ b/astrbot/core/pipeline/respond/stage.py @@ -35,9 +35,14 @@ class RespondStage(Stage): Comp.WechatEmoji: lambda comp: comp.md5 is not None, # 微信表情 Comp.Json: lambda comp: bool(comp.data), # Json 卡片 Comp.Share: lambda comp: bool(comp.url) or bool(comp.title), - Comp.Music: lambda comp: (comp.id and comp._type and comp._type != 'custom') or (comp._type == 'custom' and comp.url and comp.audio and comp.title), # 音乐分享 + Comp.Music: lambda comp: ( + (comp.id and comp._type and comp._type != "custom") + or (comp._type == "custom" and comp.url and comp.audio and comp.title) + ), # 音乐分享 Comp.Forward: lambda comp: bool(comp.id), # 合并转发 - Comp.Location: lambda comp: bool(comp.lat is not None and comp.lon is not None), # 位置 + Comp.Location: lambda comp: bool( + comp.lat is not None and comp.lon is not None + ), # 位置 Comp.Contact: lambda comp: bool(comp._type and comp.id), # 推荐好友 or 群 Comp.Shake: lambda _: True, # 窗口抖动(戳一戳) Comp.Dice: lambda _: True, # 掷骰子魔法表情