From 651a0645c5c0d803ddd3448cda8c1ab534828e83 Mon Sep 17 00:00:00 2001 From: NanoRocky <76585834+NanoRocky@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:47:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=85=E5=8F=91?= =?UTF-8?q?=E9=80=81=20JSON=20=E6=B6=88=E6=81=AF=E6=AE=B5=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D=E6=8A=A5?= =?UTF-8?q?=E9=94=99=20(#5208)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix Register_Stage · 补全 JSON 消息判断,修复发送 JSON 消息时遇到 “消息为空,跳过发送阶段” 的问题。 · 顺带补全其它消息类型判断。 Co-authored-by: Pizero * Fix formatting and comments in stage.py * Format stage.py --------- Co-authored-by: Pizero --- astrbot/core/pipeline/respond/stage.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/astrbot/core/pipeline/respond/stage.py b/astrbot/core/pipeline/respond/stage.py index b4a7ee7fa..72e853ffc 100644 --- a/astrbot/core/pipeline/respond/stage.py +++ b/astrbot/core/pipeline/respond/stage.py @@ -33,6 +33,21 @@ 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: