Make max photo size before sending as file configurable. Fixes #141

This commit is contained in:
Tulir Asokan
2019-02-16 17:14:02 +02:00
parent be255ec7af
commit 5af045844e
5 changed files with 11 additions and 5 deletions
+2 -2
View File
@@ -27,11 +27,11 @@ from telethon.tl.patched import Message
class MautrixTelegramClient(TelegramClient):
async def upload_file_direct(self, file: bytes, mime_type: str = None,
attributes: List[TypeDocumentAttribute] = None,
file_name: str = None
file_name: str = None, max_image_size: float = 10 * 1000 ** 2,
) -> Union[InputMediaUploadedDocument, InputMediaUploadedPhoto]:
file_handle = await super().upload_file(file, file_name=file_name, use_cache=False)
if (mime_type == "image/png" or mime_type == "image/jpeg") and len(file) < 10 * 1000 ** 2:
if (mime_type == "image/png" or mime_type == "image/jpeg") and len(file) < max_image_size:
return InputMediaUploadedPhoto(file_handle)
else:
attributes = attributes or []