2121
2222
2323class ChatPermissions (Object ):
24- """A chat default permissions and a single member permissions within a chat.
25-
26- Some permissions make sense depending on the context: default chat permissions, restricted/kicked member or
27- administrators in groups or channels.
28-
29- .. note::
30-
31- Pyrogram's chat permission are much more detailed. In particular, you can restrict sending stickers, animations,
32- games and inline bot results individually, allowing a finer control.
33-
34- If you wish to have the same permissions as seen in official apps or in bot API's *"can_send_other_messages"*
35- simply set these arguments to True: ``can_send_stickers``, ``can_send_animations``, ``can_send_games`` and
36- ``can_use_inline_bots``.
24+ """Describes actions that a non-administrator user is allowed to take in a chat.
3725
3826 Parameters:
3927 can_send_messages (``bool``, *optional*):
4028 True, if the user is allowed to send text messages, contacts, locations and venues.
4129
4230 can_send_media_messages (``bool``, *optional*):
43- True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies
44- can_send_messages.
31+ True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes.
32+ Implies * can_send_messages* .
4533
46- can_send_stickers (``bool``, *optional*):
47- True, if the user is allowed to send stickers, implies can_send_media_messages.
34+ can_send_other_messages (``bool``, *optional*):
35+ True, if the user is allowed to send animations, games, stickers and use inline bots.
36+ Implies *can_send_media_messages*.
4837
49- can_send_animations (``bool``, *optional*):
50- True, if the user is allowed to send animations (GIFs), implies can_send_media_messages.
51-
52- can_send_games (``bool``, *optional*):
53- True, if the user is allowed to send games, implies can_send_media_messages.
54-
55- can_use_inline_bots (``bool``, *optional*):
56- True, if the user is allowed to use inline bots, implies can_send_media_messages.
38+ can_send_polls (``bool``, *optional*):
39+ True, if the user is allowed to send polls.
40+ Implies can_send_messages
5741
5842 can_add_web_page_previews (``bool``, *optional*):
59- True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages.
60-
61- can_send_polls (``bool``, *optional*):
62- True, if the user is allowed to send polls, implies can_send_messages.
43+ True, if the user is allowed to add web page previews to their messages.
44+ Implies *can_send_media_messages*.
6345
6446 can_change_info (``bool``, *optional*):
6547 True, if the user is allowed to change the chat title, photo and other settings.
66- Ignored in public supergroups.
48+ Ignored in public supergroups
6749
6850 can_invite_users (``bool``, *optional*):
6951 True, if the user is allowed to invite new users to the chat.
@@ -77,13 +59,10 @@ def __init__(
7759 self ,
7860 * ,
7961 can_send_messages : bool = None , # Text, contacts, locations and venues
80- can_send_media_messages : bool = None , # Audios, documents, photos, videos, video notes and voice notes
81- can_send_stickers : bool = None ,
82- can_send_animations : bool = None ,
83- can_send_games : bool = None ,
84- can_use_inline_bots : bool = None ,
85- can_add_web_page_previews : bool = None ,
62+ can_send_media_messages : bool = None , # Audio files, documents, photos, videos, video notes and voice notes
63+ can_send_other_messages : bool = None , # Stickers, animations, games, inline bots
8664 can_send_polls : bool = None ,
65+ can_add_web_page_previews : bool = None ,
8766 can_change_info : bool = None ,
8867 can_invite_users : bool = None ,
8968 can_pin_messages : bool = None
@@ -92,12 +71,9 @@ def __init__(
9271
9372 self .can_send_messages = can_send_messages
9473 self .can_send_media_messages = can_send_media_messages
95- self .can_send_stickers = can_send_stickers
96- self .can_send_animations = can_send_animations
97- self .can_send_games = can_send_games
98- self .can_use_inline_bots = can_use_inline_bots
99- self .can_add_web_page_previews = can_add_web_page_previews
74+ self .can_send_other_messages = can_send_other_messages
10075 self .can_send_polls = can_send_polls
76+ self .can_add_web_page_previews = can_add_web_page_previews
10177 self .can_change_info = can_change_info
10278 self .can_invite_users = can_invite_users
10379 self .can_pin_messages = can_pin_messages
@@ -108,10 +84,12 @@ def _parse(denied_permissions: "raw.types.ChatBannedRights") -> "ChatPermissions
10884 return ChatPermissions (
10985 can_send_messages = not denied_permissions .send_messages ,
11086 can_send_media_messages = not denied_permissions .send_media ,
111- can_send_stickers = not denied_permissions .send_stickers ,
112- can_send_animations = not denied_permissions .send_gifs ,
113- can_send_games = not denied_permissions .send_games ,
114- can_use_inline_bots = not denied_permissions .send_inline ,
87+ can_send_other_messages = any ([
88+ not denied_permissions .send_stickers ,
89+ not denied_permissions .send_gifs ,
90+ not denied_permissions .send_games ,
91+ not denied_permissions .send_inline
92+ ]),
11593 can_add_web_page_previews = not denied_permissions .embed_links ,
11694 can_send_polls = not denied_permissions .send_polls ,
11795 can_change_info = not denied_permissions .change_info ,
0 commit comments