From b913590cea6d103c18a583555e10a6f81a96a833 Mon Sep 17 00:00:00 2001 From: Yusuf_M_Thon_iD <32301831+Sunda001@users.noreply.github.com> Date: Sat, 21 Mar 2020 22:03:54 +0700 Subject: [PATCH] add missing file_ref in set_chat_photo (#369) --- pyrogram/client/methods/chats/set_chat_photo.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/methods/chats/set_chat_photo.py b/pyrogram/client/methods/chats/set_chat_photo.py index 461b3474..3a996711 100644 --- a/pyrogram/client/methods/chats/set_chat_photo.py +++ b/pyrogram/client/methods/chats/set_chat_photo.py @@ -27,7 +27,8 @@ class SetChatPhoto(BaseClient): def set_chat_photo( self, chat_id: Union[int, str], - photo: str + photo: str, + file_ref: str = None ) -> bool: """Set a new profile photo for the chat. @@ -40,6 +41,10 @@ class SetChatPhoto(BaseClient): photo (``str``): New chat photo. You can pass a :obj:`Photo` file_id or a file path to upload a new photo from your local machine. + + file_ref (``str``, *optional*): + A valid file reference obtained by a recently fetched media message. + To be used in combination with a file id in case a file reference is needed. Returns: ``bool``: True on success. @@ -54,14 +59,14 @@ class SetChatPhoto(BaseClient): app.set_chat_photo(chat_id, "photo.jpg") # Set chat photo using an exiting Photo file_id - app.set_chat_photo(chat_id, photo.file_id) + app.set_chat_photo(chat_id, photo.file_id, photo.file_ref) """ peer = self.resolve_peer(chat_id) if os.path.exists(photo): photo = types.InputChatUploadedPhoto(file=self.save_file(photo)) else: - photo = utils.get_input_media_from_file_id(photo) + photo = utils.get_input_media_from_file_id(photo, file_ref, 2) photo = types.InputChatPhoto(id=photo.id) if isinstance(peer, types.InputPeerChat):