Skip to content

Commit

Permalink
Pyrofork: check if all ChatPermissions parameters is None
Browse files Browse the repository at this point in the history
also fix derp

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Oct 23, 2023
1 parent 3813027 commit 2150030
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pyrogram/methods/chats/set_chat_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ async def set_chat_permissions(
manage_topics=True
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
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
Expand All @@ -118,8 +119,6 @@ async def set_chat_permissions(
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

old_permissions = (await self.get_chat(chat_id)).permissions

r = await self.invoke(
raw.functions.messages.EditChatDefaultBannedRights(
peer=await self.resolve_peer(chat_id),
Expand Down
22 changes: 22 additions & 0 deletions pyrogram/types/user_and_chats/chat_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,28 @@ def __init__(
self.can_send_stickers = can_send_stickers
self.can_send_videos = can_send_videos
self.can_send_voices = can_send_voices
if (
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
and can_change_info is None
and can_invite_users is None
and can_pin_messages is None
and can_manage_topics is None
and can_send_audios is None
and can_send_docs is None
and can_send_games is None
and can_send_gifs is None
and can_send_inline is None
and can_send_photos is None
and can_send_plain is None
and can_send_roundvideos is None
and can_send_stickers is None
and can_send_videos is None
and can_send_voices is None
):
self.all_perms = False

@staticmethod
def _parse(denied_permissions: "raw.base.ChatBannedRights") -> "ChatPermissions":
Expand Down

0 comments on commit 2150030

Please sign in to comment.