From a47121b849e056a5961d026d2906fbb90eeaa9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=B0=B8=E8=B5=AB?= <1259085392@qq.com> Date: Mon, 23 Jun 2025 18:49:47 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AE=9A=E4=B9=89=E7=9A=84Pl?= =?UTF-8?q?ain=E7=B1=BB=E5=9E=8B=E4=BB=A3=E6=9B=BF=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E7=B1=BB=E5=9E=8Bstr=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=BB=A3=E7=A0=81=E7=BB=9F=E4=B8=80=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/message/components.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/astrbot/core/message/components.py b/astrbot/core/message/components.py index e7b25eacf..beb6e40bb 100644 --- a/astrbot/core/message/components.py +++ b/astrbot/core/message/components.py @@ -125,6 +125,8 @@ class Plain(BaseMessageComponent): def toDict(self): return {"type": "text", "data": {"text": self.text.strip()}} + async def to_dict(self): + return {"type": "text", "data": {"text": self.text}} class Face(BaseMessageComponent): type: ComponentType = "Face" @@ -610,13 +612,10 @@ class Node(BaseMessageComponent): "data": {"file": f"base64://{bs64}"}, } ) - elif isinstance(comp, str): - data_content.append( - { - "type": "text", - "data": {"text": comp.strip()} - } - ) + elif isinstance(comp, Plain): + # For Plain segments, we need to handle the plain differently + d = await comp.to_dict() + data_content.append(d) elif isinstance(comp, File): # For File segments, we need to handle the file differently d = await comp.to_dict()