From 2fd676b694d21b66a424fc5cf7d62212207ad343 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Fri, 21 Feb 2025 23:39:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=E4=BF=AE=E5=A4=8Dwebchat?= =?UTF-8?q?=E6=9C=AA=E5=A4=84=E7=90=86base64=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/platform/sources/webchat/webchat_event.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/astrbot/core/platform/sources/webchat/webchat_event.py b/astrbot/core/platform/sources/webchat/webchat_event.py index fe30151b..afcda5e1 100644 --- a/astrbot/core/platform/sources/webchat/webchat_event.py +++ b/astrbot/core/platform/sources/webchat/webchat_event.py @@ -1,5 +1,6 @@ import os import uuid +import base64 from astrbot.api import logger from astrbot.api.event import AstrMessageEvent, MessageChain from astrbot.api.message_components import Plain, Image @@ -31,6 +32,11 @@ async def send(self, message: MessageChain): with open(path, "wb") as f: with open(ph, "rb") as f2: f.write(f2.read()) + elif comp.file.startswith("base64://"): + base64_str = comp.file[9:] + image_data = base64.b64decode(base64_str) + with open(path, "wb") as f: + f.write(image_data) elif comp.file and comp.file.startswith("http"): await download_image_by_url(comp.file, path=path) else: