diff --git a/pyrogram/methods/chats/set_chat_permissions.py b/pyrogram/methods/chats/set_chat_permissions.py index b84fd80e7..7fc0e18a0 100644 --- a/pyrogram/methods/chats/set_chat_permissions.py +++ b/pyrogram/methods/chats/set_chat_permissions.py @@ -70,7 +70,6 @@ async def set_chat_permissions( send_docs=None send_games=None send_gifs=None - send_inline=None send_photos=None send_plain=None send_roundvideos=None @@ -99,8 +98,8 @@ async def set_chat_permissions( send_inline=True else: old_permissions = (await self.get_chat(chat_id)).permissions - send_messages=not permissions.can_send_messages if permissions.can_send_messages is not None else None - send_media=not permissions.can_send_media_messages if permissions.can_send_media_messages is not None else None + send_messages = None + send_media = None embed_links=not permissions.can_add_web_page_previews if permissions.can_add_web_page_previews is not None else not old_permissions.can_add_web_page_previews send_polls=not permissions.can_send_polls if permissions.can_send_polls is not None else not old_permissions.can_send_polls change_info=not permissions.can_change_info if permissions.can_change_info is not None else not old_permissions.can_change_info @@ -118,6 +117,40 @@ async def set_chat_permissions( send_stickers=not permissions.can_send_stickers if permissions.can_send_stickers is not None else not old_permissions.can_send_stickers send_videos=not permissions.can_send_videos if permissions.can_send_videos is not None else not old_permissions.can_send_videos send_voices=not permissions.can_send_voices if permissions.can_send_voices is not None else not old_permissions.can_send_voices + if permissions.can_send_messages is not None: + if permissions.can_send_messages: + send_plain = False + else: + send_plain = True + if permissions.can_send_media_messages is None: + permissions.can_send_media_messages = old_permissions.can_send_media_messages + if permissions.can_send_media_messages is not None: + if permissions.can_send_media_messages: + embed_links = False + send_audios = False + send_docs = False + send_games = False + send_gifs = False + send_inline = False + send_photos = False + send_polls = False + send_roundvideos = False + send_stickers = False + send_videos = False + send_voices = False + else: + embed_links = True + send_audios = True + send_docs = True + send_games = True + send_gifs = True + send_inline = True + send_photos = True + send_polls = True + send_roundvideos = True + send_stickers = True + send_videos = True + send_voices = True r = await self.invoke( raw.functions.messages.EditChatDefaultBannedRights( diff --git a/pyrogram/types/user_and_chats/chat_permissions.py b/pyrogram/types/user_and_chats/chat_permissions.py index e53d9e9b6..1484e8718 100644 --- a/pyrogram/types/user_and_chats/chat_permissions.py +++ b/pyrogram/types/user_and_chats/chat_permissions.py @@ -139,7 +139,8 @@ def __init__( self.can_send_videos = can_send_videos self.can_send_voices = can_send_voices if ( - can_send_messages is None + all_perms is None + and can_send_messages is None and can_send_media_messages is None and can_send_polls is None and can_add_web_page_previews is None