diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 79275103..d2add202 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1783,6 +1783,9 @@ class Client(Methods, BaseClient): Raises: RPCError: In case of a Telegram RPC error. """ + if path is None: + return None + part_size = 512 * 1024 if isinstance(path, str): diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index 3ab90744..6950c255 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -109,7 +109,7 @@ class EditMessageMedia(BaseClient): peer=self.resolve_peer(chat_id), media=types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(media.media) or "video/mp4", - thumb=None if media.thumb is None else self.save_file(media.thumb), + thumb=self.save_file(media.thumb), file=self.save_file(media.media), attributes=[ types.DocumentAttributeVideo( @@ -146,7 +146,7 @@ class EditMessageMedia(BaseClient): peer=self.resolve_peer(chat_id), media=types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(media.media) or "audio/mpeg", - thumb=None if media.thumb is None else self.save_file(media.thumb), + thumb=self.save_file(media.thumb), file=self.save_file(media.media), attributes=[ types.DocumentAttributeAudio( @@ -182,7 +182,7 @@ class EditMessageMedia(BaseClient): peer=self.resolve_peer(chat_id), media=types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(media.media) or "video/mp4", - thumb=None if media.thumb is None else self.save_file(media.thumb), + thumb=self.save_file(media.thumb), file=self.save_file(media.media), attributes=[ types.DocumentAttributeVideo( @@ -220,7 +220,7 @@ class EditMessageMedia(BaseClient): peer=self.resolve_peer(chat_id), media=types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(media.media) or "application/zip", - thumb=None if media.thumb is None else self.save_file(media.thumb), + thumb=self.save_file(media.thumb), file=self.save_file(media.media), attributes=[ types.DocumentAttributeFilename( diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index a38856a0..e8d9285f 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -167,7 +167,7 @@ class SendAnimation(BaseClient): try: if isinstance(animation, str): if os.path.isfile(animation): - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(animation, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(animation) or "video/mp4", @@ -191,7 +191,7 @@ class SendAnimation(BaseClient): else: media = utils.get_input_media_from_file_id(animation, file_ref, 10) else: - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(animation, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(animation.name) or "video/mp4", diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index 08c03d07..8dfabe8c 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -167,7 +167,7 @@ class SendAudio(BaseClient): try: if isinstance(audio, str): if os.path.isfile(audio): - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(audio, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(audio) or "audio/mpeg", @@ -189,7 +189,7 @@ class SendAudio(BaseClient): else: media = utils.get_input_media_from_file_id(audio, file_ref, 9) else: - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(audio, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(audio.name) or "audio/mpeg", diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 8faf8374..8ca7fc4e 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -147,7 +147,7 @@ class SendDocument(BaseClient): try: if isinstance(document, str): if os.path.isfile(document): - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(document, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(document) or "application/zip", @@ -165,7 +165,7 @@ class SendDocument(BaseClient): else: media = utils.get_input_media_from_file_id(document, file_ref, 5) else: - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(document, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(document.name) or "application/zip", diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py index 9ca4473b..2a2cca74 100644 --- a/pyrogram/client/methods/messages/send_media_group.py +++ b/pyrogram/client/methods/messages/send_media_group.py @@ -119,7 +119,7 @@ class SendMediaGroup(BaseClient): peer=self.resolve_peer(chat_id), media=types.InputMediaUploadedDocument( file=self.save_file(i.media), - thumb=None if i.thumb is None else self.save_file(i.thumb), + thumb=self.save_file(i.thumb), mime_type=self.guess_mime_type(i.media) or "video/mp4", attributes=[ types.DocumentAttributeVideo( diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index 1f46252f..40691771 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -164,7 +164,7 @@ class SendVideo(BaseClient): try: if isinstance(video, str): if os.path.isfile(video): - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(video, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(video) or "video/mp4", @@ -187,7 +187,7 @@ class SendVideo(BaseClient): else: media = utils.get_input_media_from_file_id(video, file_ref, 4) else: - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(video, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(video.name) or "video/mp4", diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py index 829f1459..d3b32834 100644 --- a/pyrogram/client/methods/messages/send_video_note.py +++ b/pyrogram/client/methods/messages/send_video_note.py @@ -131,7 +131,7 @@ class SendVideoNote(BaseClient): try: if isinstance(video_note, str): if os.path.isfile(video_note): - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(video_note, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(video_note) or "video/mp4", @@ -149,7 +149,7 @@ class SendVideoNote(BaseClient): else: media = utils.get_input_media_from_file_id(video_note, file_ref, 13) else: - thumb = None if thumb is None else self.save_file(thumb) + thumb = self.save_file(thumb) file = self.save_file(video_note, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(video_note.name) or "video/mp4",