Skip to content

Commit ddb2d84

Browse files
committed
Add support for can_manage_chat permission
1 parent dff3d99 commit ddb2d84

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

pyrogram/methods/chats/promote_chat_member.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ async def promote_chat_member(
2828
chat_id: Union[int, str],
2929
user_id: Union[int, str],
3030
is_anonymous: bool = False,
31-
can_change_info: bool = True,
31+
can_manage_chat: bool = True,
32+
can_change_info: bool = False,
3233
can_post_messages: bool = False,
3334
can_edit_messages: bool = False,
34-
can_delete_messages: bool = True,
35-
can_restrict_members: bool = True,
36-
can_invite_users: bool = True,
35+
can_delete_messages: bool = False,
36+
can_restrict_members: bool = False,
37+
can_invite_users: bool = False,
3738
can_pin_messages: bool = False,
3839
can_promote_members: bool = False,
3940
can_manage_voice_chats: bool = False
@@ -54,6 +55,11 @@ async def promote_chat_member(
5455
is_anonymous (``bool``, *optional*):
5556
Pass True, if the administrator's presence in the chat is hidden.
5657
58+
can_manage_chat (``bool``, *optional*):
59+
Pass True, if the administrator can access the chat event log, chat statistics, message statistics
60+
in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode.
61+
Implied by any other administrator privilege.
62+
5763
can_change_info (``bool``, *optional*):
5864
Pass True, if the administrator can change chat title, photo and other settings.
5965
@@ -106,7 +112,8 @@ async def promote_chat_member(
106112
invite_users=can_invite_users or None,
107113
pin_messages=can_pin_messages or None,
108114
add_admins=can_promote_members or None,
109-
manage_call=can_manage_voice_chats or None
115+
manage_call=can_manage_voice_chats or None,
116+
other=can_manage_chat or None
110117
),
111118
rank=""
112119
)

pyrogram/types/user_and_chats/chat_member.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class ChatMember(Object):
6666
Administrators only.
6767
True, if you are allowed to edit administrator privileges of the user.
6868
69+
can_manage_chat (``bool``, *optional*):
70+
Administrators only.
71+
True, if the administrator can access the chat event log, chat statistics, message statistics in channels,
72+
see channel members, see anonymous administrators in supergroups and ignore slow mode.
73+
Implied by any other administrator privilege.
74+
6975
can_post_messages (``bool``, *optional*):
7076
Administrators only. Channels only.
7177
True, if the administrator can post messages in the channel.
@@ -150,6 +156,7 @@ def __init__(
150156

151157
# Admin permissions
152158
can_be_edited: bool = None,
159+
can_manage_chat: bool = None,
153160
can_post_messages: bool = None, # Channels only
154161
can_edit_messages: bool = None, # Channels only
155162
can_delete_messages: bool = None,
@@ -184,6 +191,7 @@ def __init__(
184191
self.is_anonymous = is_anonymous
185192

186193
self.can_be_edited = can_be_edited
194+
self.can_manage_chat = can_manage_chat
187195
self.can_post_messages = can_post_messages
188196
self.can_edit_messages = can_edit_messages
189197
self.can_delete_messages = can_delete_messages
@@ -248,6 +256,7 @@ def _parse(client, member, users) -> "ChatMember":
248256
title=member.rank,
249257
invited_by=invited_by,
250258
can_change_info=permissions.change_info,
259+
can_manage_chat=permissions.other,
251260
can_post_messages=permissions.post_messages,
252261
can_edit_messages=permissions.edit_messages,
253262
can_delete_messages=permissions.delete_messages,
@@ -271,6 +280,7 @@ def _parse(client, member, users) -> "ChatMember":
271280
invited_by=invited_by,
272281
promoted_by=types.User._parse(client, users[member.promoted_by]),
273282
can_be_edited=member.can_edit,
283+
can_manage_chat=permissions.other,
274284
can_change_info=permissions.change_info,
275285
can_post_messages=permissions.post_messages,
276286
can_edit_messages=permissions.edit_messages,

0 commit comments

Comments
 (0)