From ddb2d84f968fe5c3120edbf4387937156fe82373 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 17 Mar 2021 15:19:36 +0100 Subject: [PATCH] Add support for can_manage_chat permission --- pyrogram/methods/chats/promote_chat_member.py | 17 ++++++++++++----- pyrogram/types/user_and_chats/chat_member.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pyrogram/methods/chats/promote_chat_member.py b/pyrogram/methods/chats/promote_chat_member.py index 4d0f15c0..e45b5876 100644 --- a/pyrogram/methods/chats/promote_chat_member.py +++ b/pyrogram/methods/chats/promote_chat_member.py @@ -28,12 +28,13 @@ class PromoteChatMember(Scaffold): chat_id: Union[int, str], user_id: Union[int, str], is_anonymous: bool = False, - can_change_info: bool = True, + can_manage_chat: bool = True, + can_change_info: bool = False, can_post_messages: bool = False, can_edit_messages: bool = False, - can_delete_messages: bool = True, - can_restrict_members: bool = True, - can_invite_users: bool = True, + can_delete_messages: bool = False, + can_restrict_members: bool = False, + can_invite_users: bool = False, can_pin_messages: bool = False, can_promote_members: bool = False, can_manage_voice_chats: bool = False @@ -54,6 +55,11 @@ class PromoteChatMember(Scaffold): is_anonymous (``bool``, *optional*): Pass True, if the administrator's presence in the chat is hidden. + can_manage_chat (``bool``, *optional*): + Pass True, if the administrator can access the chat event log, chat statistics, message statistics + in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. + Implied by any other administrator privilege. + can_change_info (``bool``, *optional*): Pass True, if the administrator can change chat title, photo and other settings. @@ -106,7 +112,8 @@ class PromoteChatMember(Scaffold): invite_users=can_invite_users or None, pin_messages=can_pin_messages or None, add_admins=can_promote_members or None, - manage_call=can_manage_voice_chats or None + manage_call=can_manage_voice_chats or None, + other=can_manage_chat or None ), rank="" ) diff --git a/pyrogram/types/user_and_chats/chat_member.py b/pyrogram/types/user_and_chats/chat_member.py index a3c87c24..7853042a 100644 --- a/pyrogram/types/user_and_chats/chat_member.py +++ b/pyrogram/types/user_and_chats/chat_member.py @@ -66,6 +66,12 @@ class ChatMember(Object): Administrators only. True, if you are allowed to edit administrator privileges of the user. + can_manage_chat (``bool``, *optional*): + Administrators only. + True, if the administrator can access the chat event log, chat statistics, message statistics in channels, + see channel members, see anonymous administrators in supergroups and ignore slow mode. + Implied by any other administrator privilege. + can_post_messages (``bool``, *optional*): Administrators only. Channels only. True, if the administrator can post messages in the channel. @@ -150,6 +156,7 @@ class ChatMember(Object): # Admin permissions can_be_edited: bool = None, + can_manage_chat: bool = None, can_post_messages: bool = None, # Channels only can_edit_messages: bool = None, # Channels only can_delete_messages: bool = None, @@ -184,6 +191,7 @@ class ChatMember(Object): self.is_anonymous = is_anonymous self.can_be_edited = can_be_edited + self.can_manage_chat = can_manage_chat self.can_post_messages = can_post_messages self.can_edit_messages = can_edit_messages self.can_delete_messages = can_delete_messages @@ -248,6 +256,7 @@ class ChatMember(Object): title=member.rank, invited_by=invited_by, can_change_info=permissions.change_info, + can_manage_chat=permissions.other, can_post_messages=permissions.post_messages, can_edit_messages=permissions.edit_messages, can_delete_messages=permissions.delete_messages, @@ -271,6 +280,7 @@ class ChatMember(Object): invited_by=invited_by, promoted_by=types.User._parse(client, users[member.promoted_by]), can_be_edited=member.can_edit, + can_manage_chat=permissions.other, can_change_info=permissions.change_info, can_post_messages=permissions.post_messages, can_edit_messages=permissions.edit_messages,