Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 4dd0686

Browse files
committed
Fix get_profile_photos not working properly in channels
1 parent 899bd7b commit 4dd0686

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pyrogram/methods/users/get_profile_photos.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ async def get_profile_photos(
6565
peer_id = await self.resolve_peer(chat_id)
6666

6767
if isinstance(peer_id, raw.types.InputPeerChannel):
68+
r = await self.send(
69+
raw.functions.channels.GetFullChannel(
70+
channel=peer_id
71+
)
72+
)
73+
74+
current = types.Photo._parse(self, r.full_chat.chat_photo) or []
75+
6876
r = await utils.parse_messages(
6977
self,
7078
await self.send(
@@ -75,7 +83,7 @@ async def get_profile_photos(
7583
min_date=0,
7684
max_date=0,
7785
offset_id=0,
78-
add_offset=offset,
86+
add_offset=0,
7987
limit=limit,
8088
max_id=0,
8189
min_id=0,
@@ -84,7 +92,17 @@ async def get_profile_photos(
8492
)
8593
)
8694

87-
return types.List([message.new_chat_photo for message in r][:limit])
95+
extra = [message.new_chat_photo for message in r]
96+
97+
if extra:
98+
if current:
99+
photos = ([current] + extra) if current.file_id != extra[0].file_id else extra
100+
else:
101+
photos = extra
102+
else:
103+
photos = [current]
104+
105+
return types.List(photos[offset:limit])
88106
else:
89107
r = await self.send(
90108
raw.functions.photos.GetUserPhotos(

0 commit comments

Comments
 (0)