Hide navigation sidebar
Hide table of contents sidebar
PTB has undergone significant changes in v20. Please read the documentation carefully and also check out the transition guide in the wiki.
Back to top
Toggle table of contents sidebar

# BotCommandScope

class telegram.BotCommandScope(type, *, api_kwargs=None)

  Bases: `telegram.TelegramObject`

  Base class for objects that represent the scope to which bot commands are applied. Currently, the following 7 scopes are supported:

  - `telegram.BotCommandScopeDefault`

  - `telegram.BotCommandScopeAllPrivateChats`

  - `telegram.BotCommandScopeAllGroupChats`

  - `telegram.BotCommandScopeAllChatAdministrators`

  - `telegram.BotCommandScopeChat`

  - `telegram.BotCommandScopeChatAdministrators`

  - `telegram.BotCommandScopeChatMember`

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their `type` is equal. For subclasses with additional attributes, the notion of equality is overridden.

  Note

  Please see the official docs on how Telegram determines which commands to display.

  Use In

  - `telegram.Bot.delete_my_commands()`

  - `telegram.Bot.get_my_commands()`

  - `telegram.Bot.set_my_commands()`

  New in version 13.7.

  Parameters:

    type (`str`) – Scope type.

  type

    Scope type.

    Type:

      `str`

  ALL_CHAT_ADMINISTRATORS = 'all_chat_administrators'

    `telegram.constants.BotCommandScopeType.ALL_CHAT_ADMINISTRATORS`

  ALL_GROUP_CHATS = 'all_group_chats'

    `telegram.constants.BotCommandScopeType.ALL_GROUP_CHATS`

  ALL_PRIVATE_CHATS = 'all_private_chats'

    `telegram.constants.BotCommandScopeType.ALL_PRIVATE_CHATS`

  CHAT = 'chat'

    `telegram.constants.BotCommandScopeType.CHAT`

  CHAT_ADMINISTRATORS = 'chat_administrators'

    `telegram.constants.BotCommandScopeType.CHAT_ADMINISTRATORS`

  CHAT_MEMBER = 'chat_member'

    `telegram.constants.BotCommandScopeType.CHAT_MEMBER`

  DEFAULT = 'default'

    `telegram.constants.BotCommandScopeType.DEFAULT`

  classmethod de_json(data, bot)

    Converts JSON data to the appropriate `BotCommandScope` object, i.e. takes care of selecting the correct subclass.

    Parameters:

      - data (Dict[`str`, …]) – The JSON data.

      - bot (`telegram.Bot`) – The bot associated with this object.

    Returns:

      The Telegram object.