Skip to content
Back to top
View this page

# 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()`

  Added 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=None)

    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`, optional) –

        The bot associated with this object. Defaults to `None`, in which case shortcut methods will not be available.

        Changed in version 21.4: `bot` is now optional and defaults to `None`

    Returns:

      The Telegram object.