Skip to content

Commit cecf5a1

Browse files
committed
Add dc_id to Chat objects
1 parent d385aae commit cecf5a1

File tree

1 file changed

+11
-0
lines changed
  • pyrogram/types/user_and_chats

1 file changed

+11
-0
lines changed

pyrogram/types/user_and_chats/chat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class Chat(Object):
7070
Bio, for private chats and bots or description for groups, supergroups and channels.
7171
Returned only in :meth:`~pyrogram.Client.get_chat`.
7272
73+
dc_id (``int``, *optional*):
74+
The chat assigned DC (data center). Available only in case the chat has a photo.
75+
Note that this information is approximate; it is based on where Telegram stores the current chat photo.
76+
It is accurate only in case the owner has set the chat photo, otherwise the dc_id will be the one assigned
77+
to the administrator who set the current chat photo.
78+
7379
invite_link (``str``, *optional*):
7480
Chat invite link, for groups, supergroups and channels.
7581
Returned only in :meth:`~pyrogram.Client.get_chat`.
@@ -121,6 +127,7 @@ def __init__(
121127
last_name: str = None,
122128
photo: "types.ChatPhoto" = None,
123129
description: str = None,
130+
dc_id: int = None,
124131
invite_link: str = None,
125132
pinned_message=None,
126133
sticker_set_name: str = None,
@@ -146,6 +153,7 @@ def __init__(
146153
self.last_name = last_name
147154
self.photo = photo
148155
self.description = description
156+
self.dc_id = dc_id
149157
self.invite_link = invite_link
150158
self.pinned_message = pinned_message
151159
self.sticker_set_name = sticker_set_name
@@ -172,6 +180,7 @@ def _parse_user_chat(client, user: raw.types.User) -> "Chat":
172180
last_name=user.last_name,
173181
photo=types.ChatPhoto._parse(client, user.photo, peer_id, user.access_hash),
174182
restrictions=types.List([types.Restriction._parse(r) for r in user.restriction_reason]) or None,
183+
dc_id=getattr(user.photo, "dc_id", None),
175184
client=client
176185
)
177186

@@ -187,6 +196,7 @@ def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
187196
photo=types.ChatPhoto._parse(client, getattr(chat, "photo", None), peer_id, 0),
188197
permissions=types.ChatPermissions._parse(getattr(chat, "default_banned_rights", None)),
189198
members_count=getattr(chat, "participants_count", None),
199+
dc_id=getattr(chat.photo, "dc_id", None),
190200
client=client
191201
)
192202

@@ -208,6 +218,7 @@ def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
208218
restrictions=types.List([types.Restriction._parse(r) for r in restriction_reason]) or None,
209219
permissions=types.ChatPermissions._parse(getattr(channel, "default_banned_rights", None)),
210220
members_count=getattr(channel, "participants_count", None),
221+
dc_id=getattr(channel.photo, "dc_id", None),
211222
client=client
212223
)
213224

0 commit comments

Comments
 (0)