Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# MenuButton

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

  Bases: `telegram.TelegramObject`

  This object describes the bot’s menu button in a private chat. It should be one of

  - `telegram.MenuButtonCommands`

  - `telegram.MenuButtonWebApp`

  - `telegram.MenuButtonDefault`

  If a menu button other than `telegram.MenuButtonDefault` is set for a private chat, then it is applied in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot commands.

  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.

  Use In

  `telegram.Bot.set_chat_menu_button()`

  Returned In

  `telegram.Bot.get_chat_menu_button()`

  Added in version 20.0.

  Parameters:

    type (`str`) – Type of menu button that the instance represents.

  type

    Type of menu button that the instance represents.

    Type:

      `str`

  COMMANDS = 'commands'

    `telegram.constants.MenuButtonType.COMMANDS`

  DEFAULT = 'default'

    `telegram.constants.MenuButtonType.DEFAULT`

  WEB_APP = 'web_app'

    `telegram.constants.MenuButtonType.WEB_APP`

  classmethod de_json(data, bot=None)

    Converts JSON data to the appropriate `MenuButton` 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.