diff --git a/compiler/error/source/400_BAD_REQUEST.tsv b/compiler/error/source/400_BAD_REQUEST.tsv index 77531e9b..82726bd3 100644 --- a/compiler/error/source/400_BAD_REQUEST.tsv +++ b/compiler/error/source/400_BAD_REQUEST.tsv @@ -125,6 +125,7 @@ WEBDOCUMENT_URL_INVALID The web document URL is invalid WEBDOCUMENT_MIME_INVALID The web document mime type is invalid BUTTON_URL_INVALID The button url is invalid AUTH_BYTES_INVALID The authorization bytes are invalid +USER_ID_INVALID The user ID is invalid CHANNELS_TOO_MUCH You have joined too many channels or supergroups ADMIN_RANK_INVALID The custom administrator title is invalid or is longer than 16 characters ADMIN_RANK_EMOJI_NOT_ALLOWED Emojis are not allowed in custom administrator titles diff --git a/docs/source/conf.py b/docs/source/conf.py index 2544800d..b3f72048 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -34,7 +34,8 @@ author = "Dan" extensions = [ "sphinx.ext.autodoc", "sphinx.ext.napoleon", - "sphinx.ext.autosummary" + "sphinx.ext.autosummary", + "sphinx_copybutton" ] master_doc = "index" diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index a0bf5af5..4d42acd9 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1232,6 +1232,7 @@ class Client(Methods, BaseClient): access_hash=data.access_hash, thumb_size=data.thumb_size, peer_id=data.peer_id, + peer_type=data.peer_type, peer_access_hash=data.peer_access_hash, volume_id=data.volume_id, local_id=data.local_id, @@ -1889,6 +1890,7 @@ class Client(Methods, BaseClient): access_hash: int, thumb_size: str, peer_id: int, + peer_type: str, peer_access_hash: int, volume_id: int, local_id: int, @@ -1936,11 +1938,23 @@ class Client(Methods, BaseClient): file_ref = utils.decode_file_ref(file_ref) if media_type == 1: - location = types.InputPeerPhotoFileLocation( - peer=types.InputPeerUser( + if peer_type == "user": + peer = types.InputPeerUser( user_id=peer_id, access_hash=peer_access_hash - ), + ) + elif peer_type == "chat": + peer = types.InputPeerChat( + chat_id=peer_id + ) + else: + peer = types.InputPeerChannel( + channel_id=peer_id, + access_hash=peer_access_hash + ) + + location = types.InputPeerPhotoFileLocation( + peer=peer, volume_id=volume_id, local_id=local_id, big=is_big or None diff --git a/pyrogram/client/ext/file_data.py b/pyrogram/client/ext/file_data.py index ae023d18..94c90329 100644 --- a/pyrogram/client/ext/file_data.py +++ b/pyrogram/client/ext/file_data.py @@ -20,9 +20,9 @@ class FileData: def __init__( self, *, media_type: int = None, dc_id: int = None, document_id: int = None, access_hash: int = None, - thumb_size: str = None, peer_id: int = None, peer_access_hash: int = None, volume_id: int = None, - local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None, file_name: str = None, - date: int = None, file_ref: str = None + thumb_size: str = None, peer_id: int = None, peer_type: str = None, peer_access_hash: int = None, + volume_id: int = None, local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None, + file_name: str = None, date: int = None, file_ref: str = None ): self.media_type = media_type self.dc_id = dc_id @@ -30,6 +30,7 @@ class FileData: self.access_hash = access_hash self.thumb_size = thumb_size self.peer_id = peer_id + self.peer_type = peer_type self.peer_access_hash = peer_access_hash self.volume_id = volume_id self.local_id = local_id diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py index d55426cd..30ff943a 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -147,13 +147,23 @@ class DownloadMedia(BaseClient): if media_type == 1: unpacked = struct.unpack("