From 4dd068643da09642384483aab922787a61fa46c4 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 29 Aug 2020 15:11:21 +0200 Subject: [PATCH] Fix get_profile_photos not working properly in channels --- pyrogram/methods/users/get_profile_photos.py | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pyrogram/methods/users/get_profile_photos.py b/pyrogram/methods/users/get_profile_photos.py index b27687a1..8a222564 100644 --- a/pyrogram/methods/users/get_profile_photos.py +++ b/pyrogram/methods/users/get_profile_photos.py @@ -65,6 +65,14 @@ class GetProfilePhotos(Scaffold): peer_id = await self.resolve_peer(chat_id) if isinstance(peer_id, raw.types.InputPeerChannel): + r = await self.send( + raw.functions.channels.GetFullChannel( + channel=peer_id + ) + ) + + current = types.Photo._parse(self, r.full_chat.chat_photo) or [] + r = await utils.parse_messages( self, await self.send( @@ -75,7 +83,7 @@ class GetProfilePhotos(Scaffold): min_date=0, max_date=0, offset_id=0, - add_offset=offset, + add_offset=0, limit=limit, max_id=0, min_id=0, @@ -84,7 +92,17 @@ class GetProfilePhotos(Scaffold): ) ) - return types.List([message.new_chat_photo for message in r][:limit]) + extra = [message.new_chat_photo for message in r] + + if extra: + if current: + photos = ([current] + extra) if current.file_id != extra[0].file_id else extra + else: + photos = extra + else: + photos = [current] + + return types.List(photos[offset:limit]) else: r = await self.send( raw.functions.photos.GetUserPhotos(