mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Add linked chats to Chat objects
This commit is contained in:
parent
128ab4b0b9
commit
12ce0a33c1
@ -101,6 +101,9 @@ class Chat(Object):
|
|||||||
distance (``int``, *optional*):
|
distance (``int``, *optional*):
|
||||||
Distance in meters of this group chat from your location.
|
Distance in meters of this group chat from your location.
|
||||||
Returned only in :meth:`~Client.get_nearby_chats`.
|
Returned only in :meth:`~Client.get_nearby_chats`.
|
||||||
|
|
||||||
|
linked_chat (:obj:`Chat`, *optional*):
|
||||||
|
The linked discussion group (in case of channels) or the linked channel (in case of supergroups).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -127,7 +130,8 @@ class Chat(Object):
|
|||||||
members_count: int = None,
|
members_count: int = None,
|
||||||
restrictions: List[Restriction] = None,
|
restrictions: List[Restriction] = None,
|
||||||
permissions: "pyrogram.ChatPermissions" = None,
|
permissions: "pyrogram.ChatPermissions" = None,
|
||||||
distance: int = None
|
distance: int = None,
|
||||||
|
linked_chat: "pyrogram.Chat" = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
@ -152,6 +156,7 @@ class Chat(Object):
|
|||||||
self.restrictions = restrictions
|
self.restrictions = restrictions
|
||||||
self.permissions = permissions
|
self.permissions = permissions
|
||||||
self.distance = distance
|
self.distance = distance
|
||||||
|
self.linked_chat = linked_chat
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_user_chat(client, user: types.User) -> "Chat":
|
def _parse_user_chat(client, user: types.User) -> "Chat":
|
||||||
@ -241,10 +246,14 @@ class Chat(Object):
|
|||||||
else:
|
else:
|
||||||
full_chat = chat_full.full_chat
|
full_chat = chat_full.full_chat
|
||||||
chat = None
|
chat = None
|
||||||
|
linked_chat = None
|
||||||
|
|
||||||
for i in chat_full.chats:
|
for c in chat_full.chats:
|
||||||
if full_chat.id == i.id:
|
if full_chat.id == c.id:
|
||||||
chat = i
|
chat = c
|
||||||
|
|
||||||
|
if full_chat.linked_chat_id == c.id:
|
||||||
|
linked_chat = c
|
||||||
|
|
||||||
if isinstance(full_chat, types.ChatFull):
|
if isinstance(full_chat, types.ChatFull):
|
||||||
parsed_chat = Chat._parse_chat_chat(client, chat)
|
parsed_chat = Chat._parse_chat_chat(client, chat)
|
||||||
@ -259,6 +268,7 @@ class Chat(Object):
|
|||||||
# TODO: Add StickerSet type
|
# TODO: Add StickerSet type
|
||||||
parsed_chat.can_set_sticker_set = full_chat.can_set_stickers
|
parsed_chat.can_set_sticker_set = full_chat.can_set_stickers
|
||||||
parsed_chat.sticker_set_name = getattr(full_chat.stickerset, "short_name", None)
|
parsed_chat.sticker_set_name = getattr(full_chat.stickerset, "short_name", None)
|
||||||
|
parsed_chat.linked_chat = Chat._parse_channel_chat(client, linked_chat)
|
||||||
|
|
||||||
if full_chat.pinned_msg_id:
|
if full_chat.pinned_msg_id:
|
||||||
parsed_chat.pinned_message = client.get_messages(
|
parsed_chat.pinned_message = client.get_messages(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user