Skip to content

Commit

Permalink
Pyrofork: fix can_send_messages and can_send_media_messages ChatPermi…
Browse files Browse the repository at this point in the history
…ssions

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Oct 23, 2023
1 parent 2150030 commit 83a6c45
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
39 changes: 36 additions & 3 deletions pyrogram/methods/chats/set_chat_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/types/user_and_chats/chat_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 83a6c45

Please sign in to comment.