mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-01 05:04:51 +00:00
Pyrofork: Add separated media permissions
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
b5955f18b3
commit
7af2b07be3
4 changed files with 92 additions and 23 deletions
|
|
@ -88,7 +88,8 @@ class BanChatMember:
|
|||
send_gifs=True,
|
||||
send_games=True,
|
||||
send_inline=True,
|
||||
embed_links=True
|
||||
embed_links=True,
|
||||
manage_topics=True,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -84,16 +84,23 @@ class RestrictChatMember:
|
|||
until_date=utils.datetime_to_timestamp(until_date),
|
||||
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,
|
||||
manage_topics=not permissions.can_manage_topics,
|
||||
send_audios=not permissions.can_send_audios,
|
||||
send_docs=not permissions.can_send_docs,
|
||||
send_games=not permissions.can_send_games,
|
||||
send_gifs=not permissions.can_send_gifs,
|
||||
send_inline=not permissions.can_send_inline,
|
||||
send_photos=not permissions.can_send_photos,
|
||||
send_plain=not permissions.can_send_plain,
|
||||
send_roundvideos=not permissions.can_send_roundvideos,
|
||||
send_stickers=not permissions.can_send_stickers,
|
||||
send_videos=not permissions.can_send_videos,
|
||||
send_voices=not permissions.can_send_voices
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -72,16 +72,23 @@ class SetChatPermissions:
|
|||
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,
|
||||
manage_topics=not permissions.can_manage_topics,
|
||||
send_audios=not permissions.can_send_audios,
|
||||
send_docs=not permissions.can_send_docs,
|
||||
send_games=not permissions.can_send_games,
|
||||
send_gifs=not permissions.can_send_gifs,
|
||||
send_inline=not permissions.can_send_inline,
|
||||
send_photos=not permissions.can_send_photos,
|
||||
send_plain=not permissions.can_send_plain,
|
||||
send_roundvideos=not permissions.can_send_roundvideos,
|
||||
send_stickers=not permissions.can_send_stickers,
|
||||
send_videos=not permissions.can_send_videos,
|
||||
send_voices=not permissions.can_send_voices
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ class ChatPermissions(Object):
|
|||
True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes.
|
||||
Implies *can_send_messages*.
|
||||
|
||||
can_send_other_messages (``bool``, *optional*):
|
||||
True, if the user is allowed to send animations, games, stickers and use inline bots.
|
||||
Implies *can_send_media_messages*.
|
||||
|
||||
can_send_polls (``bool``, *optional*):
|
||||
True, if the user is allowed to send polls.
|
||||
Implies can_send_messages
|
||||
|
|
@ -58,6 +54,39 @@ class ChatPermissions(Object):
|
|||
can_manage_topics (``bool``, *optional*):
|
||||
True, if the user is allowed to create, rename, close, and reopen forum topics.
|
||||
supergroups only.
|
||||
|
||||
can_send_audios (``bool``, *optional*):
|
||||
True, if the user is allowed to send audios.
|
||||
|
||||
can_send_docs (``bool``, *optional*):
|
||||
True, if the user is allowed to send documents.
|
||||
|
||||
can_send_games (``bool``, *optional*):
|
||||
True, if the user is allowed to send games.
|
||||
|
||||
can_send_gifs (``bool``, *optional*):
|
||||
True, if the user is allowed to send gifs.
|
||||
|
||||
can_send_inline (``bool``, *optional*):
|
||||
True, if the user is allowed to send bot inline.
|
||||
|
||||
can_send_photos (``bool``, *optional*):
|
||||
True, if the user is allowed to send photos.
|
||||
|
||||
can_send_plain (``bool``, *optional*):
|
||||
True, if the user is allowed to send plain texts.
|
||||
|
||||
can_send_roundvideos (``bool``, *optional*):
|
||||
True, if the user is allowed to send rounded videos.
|
||||
|
||||
can_send_stickers (``bool``, *optional*):
|
||||
True, if the user is allowed to send stickers.
|
||||
|
||||
can_send_videos (``bool``, *optional*):
|
||||
True, if the user is allowed to send videos.
|
||||
|
||||
can_send_voices (``bool``, *optional*):
|
||||
True, if the user is allowed to send voices.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
|
@ -65,25 +94,45 @@ class ChatPermissions(Object):
|
|||
*,
|
||||
can_send_messages: bool = None, # Text, contacts, locations and venues
|
||||
can_send_media_messages: bool = None, # Audio files, documents, photos, videos, video notes and voice notes
|
||||
can_send_other_messages: bool = None, # Stickers, animations, games, inline bots
|
||||
can_send_polls: bool = None,
|
||||
can_add_web_page_previews: bool = None,
|
||||
can_change_info: bool = None,
|
||||
can_invite_users: bool = None,
|
||||
can_pin_messages: bool = None,
|
||||
can_manage_topics: bool = None
|
||||
can_manage_topics: bool = None,
|
||||
can_send_audios: bool = None,
|
||||
can_send_docs: bool = None,
|
||||
can_send_games: bool = None,
|
||||
can_send_gifs: bool = None,
|
||||
can_send_inline: bool = None,
|
||||
can_send_photos: bool = None,
|
||||
can_send_plain: bool = None,
|
||||
can_send_roundvideos: bool = None,
|
||||
can_send_stickers: bool = None,
|
||||
can_send_videos: bool = None,
|
||||
can_send_voices: bool = None
|
||||
):
|
||||
super().__init__(None)
|
||||
|
||||
self.can_send_messages = can_send_messages
|
||||
self.can_send_media_messages = can_send_media_messages
|
||||
self.can_send_other_messages = can_send_other_messages
|
||||
self.can_send_polls = can_send_polls
|
||||
self.can_add_web_page_previews = can_add_web_page_previews
|
||||
self.can_change_info = can_change_info
|
||||
self.can_invite_users = can_invite_users
|
||||
self.can_pin_messages = can_pin_messages
|
||||
self.can_manage_topics = can_manage_topics
|
||||
self.can_send_audios = can_send_audios
|
||||
self.can_send_docs = can_send_docs
|
||||
self.can_send_games = can_send_games
|
||||
self.can_send_gifs = can_send_gifs
|
||||
self.can_send_inline = can_send_inline
|
||||
self.can_send_photos = can_send_photos
|
||||
self.can_send_plain = can_send_plain
|
||||
self.can_send_roundvideos = can_send_roundvideos
|
||||
self.can_send_stickers = can_send_stickers
|
||||
self.can_send_videos = can_send_videos
|
||||
self.can_send_voices = can_send_voices
|
||||
|
||||
@staticmethod
|
||||
def _parse(denied_permissions: "raw.base.ChatBannedRights") -> "ChatPermissions":
|
||||
|
|
@ -91,16 +140,21 @@ class ChatPermissions(Object):
|
|||
return ChatPermissions(
|
||||
can_send_messages=not denied_permissions.send_messages,
|
||||
can_send_media_messages=not denied_permissions.send_media,
|
||||
can_send_other_messages=any([
|
||||
not denied_permissions.send_stickers,
|
||||
not denied_permissions.send_gifs,
|
||||
not denied_permissions.send_games,
|
||||
not denied_permissions.send_inline
|
||||
]),
|
||||
can_add_web_page_previews=not denied_permissions.embed_links,
|
||||
can_send_polls=not denied_permissions.send_polls,
|
||||
can_change_info=not denied_permissions.change_info,
|
||||
can_invite_users=not denied_permissions.invite_users,
|
||||
can_pin_messages=not denied_permissions.pin_messages,
|
||||
can_manage_topics=not denied_permissions.manage_topics
|
||||
can_manage_topics=not denied_permissions.manage_topics,
|
||||
can_send_audios=not denied_permissions.send_audios,
|
||||
can_send_docs=not denied_permissions.send_docs,
|
||||
can_send_games=not denied_permissions.send_games,
|
||||
can_send_gifs=not denied_permissions.send_gifs,
|
||||
can_send_inline=not denied_permissions.send_inline,
|
||||
can_send_photos=not denied_permissions.send_photos,
|
||||
can_send_plain=not denied_permissions.send_plain,
|
||||
can_send_roundvideos=not denied_permissions.send_roundvideos,
|
||||
can_send_stickers=not denied_permissions.send_stickers,
|
||||
can_send_videos=not denied_permissions.send_videos,
|
||||
can_send_voices=not denied_permissions.send_voices
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue