Skip to content

Commit d119998

Browse files
committed
Remove get_user_dc method, add dc_id attribute to User
1 parent e41d21b commit d119998

4 files changed

Lines changed: 12 additions & 66 deletions

File tree

compiler/docs/compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def get_title_list(s: str) -> list:
214214
set_profile_photo
215215
delete_profile_photos
216216
update_username
217-
get_user_dc
218217
block_user
219218
unblock_user
220219
""",

pyrogram/client/methods/users/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from .get_me import GetMe
2222
from .get_profile_photos import GetProfilePhotos
2323
from .get_profile_photos_count import GetProfilePhotosCount
24-
from .get_user_dc import GetUserDC
2524
from .get_users import GetUsers
2625
from .iter_profile_photos import IterProfilePhotos
2726
from .set_profile_photo import SetProfilePhoto
@@ -38,7 +37,6 @@ class Users(
3837
GetMe,
3938
UpdateUsername,
4039
GetProfilePhotosCount,
41-
GetUserDC,
4240
IterProfilePhotos,
4341
UnblockUser
4442
):

pyrogram/client/methods/users/get_user_dc.py

Lines changed: 0 additions & 58 deletions
This file was deleted.

pyrogram/client/types/user_and_chats/user.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ class User(Object):
7575
language_code (``str``, *optional*):
7676
IETF language tag of the user's language.
7777
78+
dc_id (``int``, *optional*):
79+
User's or bot's assigned DC (data center). Available only in case the user has set a public profile photo.
80+
Note that this information is approximate: it is based on where Telegram stores a user profile pictures and
81+
does not by any means tell you the user location (i.e. a user might travel far away, but will still connect
82+
to its assigned DC). More info at `FAQs </faq#what-are-the-ip-addresses-of-telegram-data-centers>`_.
83+
7884
phone_number (``str``, *optional*):
7985
User's phone number.
8086
@@ -88,8 +94,8 @@ class User(Object):
8894

8995
__slots__ = [
9096
"id", "is_self", "is_contact", "is_mutual_contact", "is_deleted", "is_bot", "is_verified", "is_restricted",
91-
"is_scam", "is_support", "first_name", "last_name", "status", "username", "language_code", "phone_number",
92-
"photo", "restriction_reason"
97+
"is_scam", "is_support", "first_name", "last_name", "status", "username", "language_code", "dc_id",
98+
"phone_number", "photo", "restriction_reason"
9399
]
94100

95101
def __init__(
@@ -111,6 +117,7 @@ def __init__(
111117
status: UserStatus = None,
112118
username: str = None,
113119
language_code: str = None,
120+
dc_id: int = None,
114121
phone_number: str = None,
115122
photo: ChatPhoto = None,
116123
restriction_reason: str = None
@@ -132,6 +139,7 @@ def __init__(
132139
self.status = status
133140
self.username = username
134141
self.language_code = language_code
142+
self.dc_id = dc_id
135143
self.phone_number = phone_number
136144
self.photo = photo
137145
self.restriction_reason = restriction_reason
@@ -163,6 +171,7 @@ def _parse(client, user: types.User) -> "User" or None:
163171
status=UserStatus._parse(client, user.status, user.id, user.bot),
164172
username=user.username,
165173
language_code=user.lang_code,
174+
dc_id=getattr(user.photo, "dc_id", None),
166175
phone_number=user.phone,
167176
photo=ChatPhoto._parse(client, user.photo, user.id),
168177
restriction_reason=user.restriction_reason,
@@ -214,7 +223,7 @@ def unarchive(self):
214223
"""
215224

216225
return self._client.unarchive_chats(self.id)
217-
226+
218227
def block(self):
219228
"""Bound method *block* of :obj:`User`.
220229
@@ -238,7 +247,6 @@ def block(self):
238247

239248
return self._client.block_user(self.id)
240249

241-
242250
def unblock(self):
243251
"""Bound method *unblock* of :obj:`User`.
244252
@@ -261,4 +269,3 @@ def unblock(self):
261269
"""
262270

263271
return self._client.unblock_user(self.id)
264-

0 commit comments

Comments
 (0)