diff --git a/pyrogram/methods/chats/restrict_chat_member.py b/pyrogram/methods/chats/restrict_chat_member.py index d31d8481d..3bf58fdf8 100644 --- a/pyrogram/methods/chats/restrict_chat_member.py +++ b/pyrogram/methods/chats/restrict_chat_member.py @@ -52,7 +52,10 @@ async def restrict_chat_member( New user permissions. use_independent_chat_permissions (``bool``, *optional*): - Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission. + Pass True if chat permissions are set independently. + Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will + imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; + the can_send_polls permission will imply the can_send_messages permission. until_date (:py:obj:`~datetime.datetime`, *optional*): Date when the user will be unbanned. diff --git a/pyrogram/methods/chats/set_chat_permissions.py b/pyrogram/methods/chats/set_chat_permissions.py index d8ec0cf02..a985175ad 100644 --- a/pyrogram/methods/chats/set_chat_permissions.py +++ b/pyrogram/methods/chats/set_chat_permissions.py @@ -28,6 +28,7 @@ async def set_chat_permissions( self: "pyrogram.Client", chat_id: Union[int, str], permissions: "types.ChatPermissions", + use_independent_chat_permissions: bool = False, ) -> "types.Chat": """Set default chat permissions for all members. @@ -43,6 +44,12 @@ async def set_chat_permissions( permissions (:obj:`~pyrogram.types.ChatPermissions`): New default chat permissions. + use_independent_chat_permissions (``bool``, *optional*): + Pass True if chat permissions are set independently. + Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will + imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; + the can_send_polls permission will imply the can_send_messages permission. + Returns: :obj:`~pyrogram.types.Chat`: On success, a chat object is returned. @@ -67,20 +74,7 @@ async def set_chat_permissions( r = await self.invoke( raw.functions.messages.EditChatDefaultBannedRights( peer=await self.resolve_peer(chat_id), - banned_rights=raw.types.ChatBannedRights( - until_date=0, - send_messages=not permissions.can_send_messages, - send_media=not permissions.can_send_media_messages, - send_stickers=not permissions.can_send_other_messages, - send_gifs=not permissions.can_send_other_messages, - send_games=not permissions.can_send_other_messages, - send_inline=not permissions.can_send_other_messages, - embed_links=not permissions.can_add_web_page_previews, - send_polls=not permissions.can_send_polls, - change_info=not permissions.can_change_info, - invite_users=not permissions.can_invite_users, - pin_messages=not permissions.can_pin_messages, - ) + banned_rights=permissions.write(use_independent_chat_permissions) ) )