diff --git a/pyrogram/client/ext/utils.py b/pyrogram/client/ext/utils.py index bb1f104a..1903aafc 100644 --- a/pyrogram/client/ext/utils.py +++ b/pyrogram/client/ext/utils.py @@ -27,7 +27,7 @@ from . import BaseClient from ...api import types -def decode(s: str) -> bytes: +def decode_file_id(s: str) -> bytes: s = base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)) r = b"" @@ -53,7 +53,7 @@ def decode(s: str) -> bytes: return r -def encode(s: bytes) -> str: +def encode_file_id(s: bytes) -> str: r = b"" n = 0 @@ -97,7 +97,7 @@ def get_input_media_from_file_id( expected_media_type: int = None ) -> Union[types.InputMediaPhoto, types.InputMediaDocument]: try: - decoded = decode(file_id_str) + decoded = decode_file_id(file_id_str) except Exception: raise ValueError("Failed to decode file_id: {}".format(file_id_str)) else: diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py index 40e150b4..053e0155 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -141,7 +141,7 @@ class DownloadMedia(BaseClient): return dict(filter(lambda x: x[1] is not None, data.__dict__.items())) try: - decoded = utils.decode(file_id_str) + decoded = utils.decode_file_id(file_id_str) media_type = decoded[0] if media_type == 1: diff --git a/pyrogram/client/methods/users/delete_profile_photos.py b/pyrogram/client/methods/users/delete_profile_photos.py index 5c3b26e8..e6b2fe5b 100644 --- a/pyrogram/client/methods/users/delete_profile_photos.py +++ b/pyrogram/client/methods/users/delete_profile_photos.py @@ -55,7 +55,7 @@ class DeleteProfilePhotos(BaseClient): input_photos = [] for photo_id in photo_ids: - unpacked = unpack(" "Animation": return Animation( - file_id=encode( + file_id=encode_file_id( pack( " "Audio": return Audio( - file_id=encode( + file_id=encode_file_id( pack( " "Document": return Document( - file_id=encode( + file_id=encode_file_id( pack( " "Video": return Video( - file_id=encode( + file_id=encode_file_id( pack( " "VideoNote": return VideoNote( - file_id=encode( + file_id=encode_file_id( pack( " "Voice": return Voice( - file_id=encode( + file_id=encode_file_id( pack( "