|
20 | 20 | from typing import Union, AsyncGenerator, Optional |
21 | 21 |
|
22 | 22 | import pyrogram |
23 | | -from pyrogram import types, raw, utils |
| 23 | +from pyrogram import types, raw |
24 | 24 |
|
25 | 25 |
|
26 | 26 | class GetChatPhotos: |
@@ -70,37 +70,37 @@ async def get_chat_photos( |
70 | 70 | chat_icons = [_animation or _photo] |
71 | 71 |
|
72 | 72 | if not (self.me and self.me.is_bot): |
73 | | - r = await utils.parse_messages( |
74 | | - self, |
75 | | - await self.invoke( |
76 | | - raw.functions.messages.Search( |
77 | | - peer=peer_id, |
78 | | - q="", |
79 | | - filter=raw.types.InputMessagesFilterChatPhotos(), |
80 | | - min_date=0, |
81 | | - max_date=0, |
82 | | - offset_id=0, |
83 | | - add_offset=0, |
84 | | - limit=limit, |
85 | | - max_id=0, |
86 | | - min_id=0, |
87 | | - hash=0, |
88 | | - ) |
89 | | - ), |
| 73 | + r = await self.invoke( |
| 74 | + raw.functions.messages.Search( |
| 75 | + peer=peer_id, |
| 76 | + q="", |
| 77 | + filter=raw.types.InputMessagesFilterChatPhotos(), |
| 78 | + min_date=0, |
| 79 | + max_date=0, |
| 80 | + offset_id=0, |
| 81 | + add_offset=0, |
| 82 | + limit=limit, |
| 83 | + max_id=0, |
| 84 | + min_id=0, |
| 85 | + hash=0, |
| 86 | + ) |
90 | 87 | ) |
91 | 88 | if _icon := chat_icons[0]: |
92 | 89 | _first_file_id = _icon.file_id if _animation else _icon.sizes[0].file_id |
93 | 90 | else: |
94 | 91 | _first_file_id = None |
95 | | - for m in r: |
96 | | - if isinstance(m.new_chat_photo, types.Animation): |
97 | | - _current_file_id = m.new_chat_photo.file_id |
98 | | - elif isinstance(m.new_chat_photo, types.Photo): |
99 | | - _current_file_id = m.new_chat_photo.sizes[0].file_id |
100 | | - else: |
| 92 | + |
| 93 | + for m in getattr(r, "messages", []): |
| 94 | + if not isinstance(getattr(m, "action", None), raw.types.MessageActionChatEditPhoto): |
101 | 95 | continue |
102 | | - if _first_file_id != _current_file_id: |
103 | | - chat_icons.append(m.new_chat_photo) |
| 96 | + |
| 97 | + _c_animation = types.Animation._parse_chat_animation(self, m.action.photo) |
| 98 | + _c_photo = types.Photo._parse(self, m.action.photo) |
| 99 | + |
| 100 | + _current_file_id = (_c_animation and _c_animation.file_id) or (_c_photo and _c_photo.sizes[0].file_id) |
| 101 | + |
| 102 | + if (_c_animation or _c_photo) and _first_file_id != _current_file_id: |
| 103 | + chat_icons.append(_c_animation or _c_photo) |
104 | 104 |
|
105 | 105 | current = 0 |
106 | 106 |
|
|
0 commit comments