Visitar URL original
Add missing attributes to the Chat type · dev8tg/pyrogram@6e6dd54 · GitHub
Skip to content

Commit 6e6dd54

Browse files
committed
Add missing attributes to the Chat type
1 parent 34616eb commit 6e6dd54

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

‎pyrogram/client/types/user_and_chats/chat.py‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ class Chat(Object):
3636
Type of chat, can be either "private", "bot", "group", "supergroup" or "channel".
3737
3838
is_verified (``bool``, *optional*):
39-
True, if this chat has been verified by Telegram. Supergroups and channels only.
39+
True, if this chat has been verified by Telegram. Supergroups, channels and bots only.
4040
4141
is_restricted (``bool``, *optional*):
42-
True, if this chat has been restricted. Supergroups and channels only.
42+
True, if this chat has been restricted. Supergroups, channels and bots only.
4343
See *restriction_reason* for details.
4444
4545
is_scam (``bool``, *optional*):
46-
True, if this chat has been flagged for scam. Supergroups and channels only.
46+
True, if this chat has been flagged for scam. Supergroups, channels and bots only.
47+
48+
is_support (``bool``):
49+
True, if this chat is part of the Telegram support team. Users and bots only.
4750
4851
title (``str``, *optional*):
4952
Title, for supergroups, channels and basic group chats.
@@ -92,8 +95,8 @@ class Chat(Object):
9295
"""
9396

9497
__slots__ = [
95-
"id", "type", "is_verified", "is_restricted", "is_scam", "title", "username", "first_name", "last_name",
96-
"photo", "description", "invite_link", "pinned_message", "sticker_set_name", "can_set_sticker_set",
98+
"id", "type", "is_verified", "is_restricted", "is_scam", "is_support", "title", "username", "first_name",
99+
"last_name", "photo", "description", "invite_link", "pinned_message", "sticker_set_name", "can_set_sticker_set",
97100
"members_count", "restriction_reason", "permissions"
98101
]
99102

@@ -106,6 +109,7 @@ def __init__(
106109
is_verified: bool = None,
107110
is_restricted: bool = None,
108111
is_scam: bool = None,
112+
is_support: bool = None,
109113
title: str = None,
110114
username: str = None,
111115
first_name: str = None,
@@ -127,6 +131,7 @@ def __init__(
127131
self.is_verified = is_verified
128132
self.is_restricted = is_restricted
129133
self.is_scam = is_scam
134+
self.is_support = is_support
130135
self.title = title
131136
self.username = username
132137
self.first_name = first_name
@@ -148,6 +153,10 @@ def _parse_user_chat(client, user: types.User) -> "Chat":
148153
return Chat(
149154
id=peer_id,
150155
type="bot" if user.bot else "private",
156+
is_verified=getattr(user, "verified", None),
157+
is_restricted=getattr(user, "restricted", None),
158+
is_scam=getattr(user, "scam", None),
159+
is_support=getattr(user, "support", None),
151160
username=user.username,
152161
first_name=user.first_name,
153162
last_name=user.last_name,

‎pyrogram/client/types/user_and_chats/user.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ class User(Object):
5252
True, if this user has been restricted. Bots only.
5353
See *restriction_reason* for details.
5454
55-
is_support (``bool``):
56-
True, if this user is part of the Telegram support team.
57-
5855
is_scam (``bool``):
5956
True, if this user has been flagged for scam.
6057
58+
is_support (``bool``):
59+
True, if this user is part of the Telegram support team.
60+
6161
first_name (``str``):
6262
User's or bot's first name.
6363
@@ -86,7 +86,7 @@ class User(Object):
8686

8787
__slots__ = [
8888
"id", "is_self", "is_contact", "is_mutual_contact", "is_deleted", "is_bot", "is_verified", "is_restricted",
89-
"is_support", "is_scam", "first_name", "last_name", "status", "username", "language_code", "phone_number",
89+
"is_scam", "is_support", "first_name", "last_name", "status", "username", "language_code", "phone_number",
9090
"photo", "restriction_reason"
9191
]
9292

@@ -102,8 +102,8 @@ def __init__(
102102
is_bot: bool,
103103
is_verified: bool,
104104
is_restricted: bool,
105-
is_support: bool,
106105
is_scam: bool,
106+
is_support: bool,
107107
first_name: str,
108108
last_name: str = None,
109109
status: UserStatus = None,
@@ -123,8 +123,8 @@ def __init__(
123123
self.is_bot = is_bot
124124
self.is_verified = is_verified
125125
self.is_restricted = is_restricted
126-
self.is_support = is_support
127126
self.is_scam = is_scam
127+
self.is_support = is_support
128128
self.first_name = first_name
129129
self.last_name = last_name
130130
self.status = status
@@ -148,8 +148,8 @@ def _parse(client, user: types.User) -> "User" or None:
148148
is_bot=user.bot,
149149
is_verified=user.verified,
150150
is_restricted=user.restricted,
151-
is_support=user.support,
152151
is_scam=user.scam,
152+
is_support=user.support,
153153
first_name=user.first_name,
154154
last_name=user.last_name,
155155
status=UserStatus._parse(client, user.status, user.id, user.bot),

0 commit comments

Comments
 (0)