mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
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.
This commit is contained in:
parent
11ea15aa08
commit
bed13de413
@ -20,7 +20,7 @@ from typing import List
|
|||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .chat_photo import ChatPhoto
|
from ..messages_and_media import Photo
|
||||||
from ..object import Object
|
from ..object import Object
|
||||||
from ..user_and_chats.user import User
|
from ..user_and_chats.user import User
|
||||||
|
|
||||||
@ -32,48 +32,48 @@ class ChatPreview(Object):
|
|||||||
title (``str``):
|
title (``str``):
|
||||||
Title of the chat.
|
Title of the chat.
|
||||||
|
|
||||||
photo (:obj:`ChatPhoto`, *optional*):
|
|
||||||
Chat photo. Suitable for downloads only.
|
|
||||||
|
|
||||||
type (``str``):
|
type (``str``):
|
||||||
Type of chat, can be either, "group", "supergroup" or "channel".
|
Type of chat, can be either, "group", "supergroup" or "channel".
|
||||||
|
|
||||||
members_count (``int``):
|
members_count (``int``):
|
||||||
Chat members count.
|
Chat members count.
|
||||||
|
|
||||||
|
photo (:obj:`Photo`, *optional*):
|
||||||
|
Chat photo.
|
||||||
|
|
||||||
members (List of :obj:`User`, *optional*):
|
members (List of :obj:`User`, *optional*):
|
||||||
Preview of some of the chat members.
|
Preview of some of the chat members.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ["title", "photo", "type", "members_count", "members"]
|
__slots__ = ["title", "type", "members_count", "photo", "members"]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
client: "pyrogram.BaseClient" = None,
|
client: "pyrogram.BaseClient" = None,
|
||||||
title: str,
|
title: str,
|
||||||
photo: ChatPhoto = None,
|
|
||||||
type: str,
|
type: str,
|
||||||
members_count: int,
|
members_count: int,
|
||||||
|
photo: Photo = None,
|
||||||
members: List[User] = None
|
members: List[User] = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.title = title
|
self.title = title
|
||||||
self.photo = photo
|
|
||||||
self.type = type
|
self.type = type
|
||||||
self.members_count = members_count
|
self.members_count = members_count
|
||||||
|
self.photo = photo
|
||||||
self.members = members
|
self.members = members
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, chat_invite: types.ChatInvite) -> "ChatPreview":
|
def _parse(client, chat_invite: types.ChatInvite) -> "ChatPreview":
|
||||||
return ChatPreview(
|
return ChatPreview(
|
||||||
title=chat_invite.title,
|
title=chat_invite.title,
|
||||||
photo=ChatPhoto._parse(client, chat_invite.photo),
|
|
||||||
type=("group" if not chat_invite.channel else
|
type=("group" if not chat_invite.channel else
|
||||||
"channel" if chat_invite.broadcast else
|
"channel" if chat_invite.broadcast else
|
||||||
"supergroup"),
|
"supergroup"),
|
||||||
members_count=chat_invite.participants_count,
|
members_count=chat_invite.participants_count,
|
||||||
|
photo=Photo._parse(client, chat_invite.photo),
|
||||||
members=[User._parse(client, user) for user in chat_invite.participants] or None,
|
members=[User._parse(client, user) for user in chat_invite.participants] or None,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user