Skip to content

Commit bed13de

Browse files
committed
Fix ChatPreview objects failing to parse
This happened because Telegram changed the preview photo type from ChatPhoto to Photo. The reason behind this change was due to ChatPhoto requiring now a peer id to be downloaded, which is not available in case of chat previews.
1 parent 11ea15a commit bed13de

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

pyrogram/client/types/user_and_chats/chat_preview.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pyrogram
2222
from pyrogram.api import types
23-
from .chat_photo import ChatPhoto
23+
from ..messages_and_media import Photo
2424
from ..object import Object
2525
from ..user_and_chats.user import User
2626

@@ -32,48 +32,48 @@ class ChatPreview(Object):
3232
title (``str``):
3333
Title of the chat.
3434
35-
photo (:obj:`ChatPhoto`, *optional*):
36-
Chat photo. Suitable for downloads only.
37-
3835
type (``str``):
3936
Type of chat, can be either, "group", "supergroup" or "channel".
4037
4138
members_count (``int``):
4239
Chat members count.
4340
41+
photo (:obj:`Photo`, *optional*):
42+
Chat photo.
43+
4444
members (List of :obj:`User`, *optional*):
4545
Preview of some of the chat members.
4646
"""
4747

48-
__slots__ = ["title", "photo", "type", "members_count", "members"]
48+
__slots__ = ["title", "type", "members_count", "photo", "members"]
4949

5050
def __init__(
5151
self,
5252
*,
5353
client: "pyrogram.BaseClient" = None,
5454
title: str,
55-
photo: ChatPhoto = None,
5655
type: str,
5756
members_count: int,
57+
photo: Photo = None,
5858
members: List[User] = None
5959
):
6060
super().__init__(client)
6161

6262
self.title = title
63-
self.photo = photo
6463
self.type = type
6564
self.members_count = members_count
65+
self.photo = photo
6666
self.members = members
6767

6868
@staticmethod
6969
def _parse(client, chat_invite: types.ChatInvite) -> "ChatPreview":
7070
return ChatPreview(
7171
title=chat_invite.title,
72-
photo=ChatPhoto._parse(client, chat_invite.photo),
7372
type=("group" if not chat_invite.channel else
7473
"channel" if chat_invite.broadcast else
7574
"supergroup"),
7675
members_count=chat_invite.participants_count,
76+
photo=Photo._parse(client, chat_invite.photo),
7777
members=[User._parse(client, user) for user in chat_invite.participants] or None,
7878
client=client
7979
)

0 commit comments

Comments
 (0)