ChatPermissions

class telegram.ChatPermissions(can_send_messages=None, can_send_media_messages=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, can_manage_topics=None, *, api_kwargs=None)[source]

Bases: telegram.TelegramObject

Describes actions that a non-administrator user is allowed to take in a chat.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their can_send_messages, can_send_media_messages, can_send_polls, can_send_other_messages, can_add_web_page_previews, can_change_info, can_invite_users, can_pin_messages, and can_manage_topics are equal.

Changed in version 20.0: can_manage_topics is considered as well when comparing objects of this type in terms of equality.

Note

Though not stated explicitly in the official docs, Telegram changes not only the permissions that are set, but also sets all the others to False. However, since not documented, this behavior may change unbeknown to PTB.

Parameters:
can_send_messages[source]

Optional. True, if the user is allowed to send text messages, contacts, locations and venues.

Type:

bool

can_send_media_messages[source]

Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.

Type:

bool

can_send_polls[source]

Optional. True, if the user is allowed to send polls, implies can_send_messages.

Type:

bool

can_send_other_messages[source]

Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages.

Type:

bool

can_add_web_page_previews[source]

Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages.

Type:

bool

can_change_info[source]

Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups.

Type:

bool

can_invite_users[source]

Optional. True, if the user is allowed to invite new users to the chat.

Type:

bool

can_pin_messages[source]

Optional. True, if the user is allowed to pin messages. Ignored in public supergroups.

Type:

bool

can_manage_topics[source]

Optional. True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages.

New in version 20.0.

Type:

bool

classmethod all_permissions()[source]

This method returns an ChatPermissions instance with all attributes set to True. This is e.g. useful when unrestricting a chat member with telegram.Bot.restrict_chat_member().

New in version 20.0.

classmethod no_permissions()[source]

This method returns an ChatPermissions instance with all attributes set to False.

New in version 20.0.