Skip to content

Commit

Permalink
Merge pull request #568 from Raven95676/master
Browse files Browse the repository at this point in the history
🐛 fix: 修复webchat未处理base64的问题
  • Loading branch information
Soulter authored Feb 21, 2025
2 parents b83e57c + 2fd676b commit 908eb47
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions astrbot/core/platform/sources/webchat/webchat_event.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 908eb47

Please # to comment.