mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Don't set force_file on force_document with images
Otherwise, Telegram won't analyze the image and won't add it the DocumentAttributeImageSize, causing some bots like t.me/Stickers to break. Closes #1507.
This commit is contained in:
parent
ddeefff431
commit
9a0d6b9931
|
@ -687,8 +687,9 @@ class UploadMethods:
|
|||
if isinstance(file, pathlib.Path):
|
||||
file = str(file.absolute())
|
||||
|
||||
is_image = utils.is_image(file)
|
||||
if as_image is None:
|
||||
as_image = utils.is_image(file) and not force_document
|
||||
as_image = is_image and not force_document
|
||||
|
||||
# `aiofiles` do not base `io.IOBase` but do have `read`, so we
|
||||
# just check for the read attribute to see if it's file-like.
|
||||
|
@ -749,7 +750,7 @@ class UploadMethods:
|
|||
file,
|
||||
mime_type=mime_type,
|
||||
attributes=attributes,
|
||||
force_document=force_document,
|
||||
force_document=force_document and not is_image,
|
||||
voice_note=voice_note,
|
||||
video_note=video_note,
|
||||
supports_streaming=supports_streaming
|
||||
|
@ -767,7 +768,7 @@ class UploadMethods:
|
|||
mime_type=mime_type,
|
||||
attributes=attributes,
|
||||
thumb=thumb,
|
||||
force_file=force_document
|
||||
force_file=force_document and not is_image
|
||||
)
|
||||
return file_handle, media, as_image
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user