🐛 fix bug in cqhttp MessageSegment

This commit is contained in:
AkiraXie 2021-10-03 23:20:17 +08:00 committed by GitHub
parent 33f605a947
commit ac87107556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,7 +164,7 @@ class MessageSegment(BaseMessageSegment["Message"]):
proxy: Optional[bool] = None,
timeout: Optional[int] = None) -> "MessageSegment":
if isinstance(file, BytesIO):
file = file.read()
file = file.getvalue()
if isinstance(file, bytes):
file = f"base64://{b64encode(file).decode()}"
elif isinstance(file, Path):
@ -212,7 +212,7 @@ class MessageSegment(BaseMessageSegment["Message"]):
proxy: Optional[bool] = None,
timeout: Optional[int] = None) -> "MessageSegment":
if isinstance(file, BytesIO):
file = file.read()
file = file.getvalue()
if isinstance(file, bytes):
file = f"base64://{b64encode(file).decode()}"
elif isinstance(file, Path):