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()