mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
Pyrofork: check if all ChatPermissions parameters is None
also fix derp Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
1936e1e6bd
commit
c11dc29a0d
2 changed files with 23 additions and 2 deletions
|
|
@ -98,6 +98,7 @@ class SetChatPermissions:
|
|||
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
|
||||
|
|
@ -118,8 +119,6 @@ class SetChatPermissions:
|
|||
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),
|
||||
|
|
|
|||
|
|
@ -138,6 +138,28 @@ class ChatPermissions(Object):
|
|||
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":
|
||||
|
|
|
|||
Loading…
Reference in a new issue