From a275aa2e4d543ec9fdb0bf37c9d4da00f8740d03 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Wed, 26 Feb 2025 16:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=E4=BF=AE=E5=A4=8Dtelegra?= =?UTF-8?q?m=E9=80=82=E9=85=8D=E5=99=A8=E4=B8=AD=E6=9C=AA=E5=A4=84?= =?UTF-8?q?=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/telegram/tg_event.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/astrbot/core/platform/sources/telegram/tg_event.py b/astrbot/core/platform/sources/telegram/tg_event.py index 04b82bdea..19dddafb1 100644 --- a/astrbot/core/platform/sources/telegram/tg_event.py +++ b/astrbot/core/platform/sources/telegram/tg_event.py @@ -40,8 +40,15 @@ class TelegramPlatformEvent(AstrMessageEvent): image_path = i.path else: image_path = i.file - await client.send_photo(photo=image_path, **payload) - + + if image_path.startswith("base64://"): + import base64 + base64_data = image_path[9:] + image_bytes = base64.b64decode(base64_data) + await client.send_photo(photo=image_bytes, **payload) + else: + await client.send_photo(photo=image_path, **payload) + async def send(self, message: MessageChain): if self.get_message_type() == MessageType.GROUP_MESSAGE: await self.send_with_client(self.client, message, self.message_obj.group_id)