Skip to content
module

tgintegration.containers.inline_keyboard

Classes
  • InlineKeyboard Represents an inline keyboard attached to a message in the Telegram UI and allows to click those buttons.</>
class

tgintegration.containers.inline_keyboard.InlineKeyboard(controller, chat_id, message_id, button_rows)

Represents an inline keyboard attached to a message in the Telegram UI and allows to click those buttons.

Methods
  • click(pattern, index) (Response) Uses find_button with the given pattern or index, clicks the button if found, and waits for the bot to react in the same chat.</>
  • find_button(pattern, index) (InlineKeyboardButton, optional) Attempts to retrieve a clickable button anywhere in the underlying rows by matching the button captions with the given pattern or its global index. If no button could be found, this method raises NoButtonFound.</>
method

find_button(pattern=None, index=None)

Attempts to retrieve a clickable button anywhere in the underlying rows by matching the button captions with the given pattern or its global index. If no button could be found, this method raises NoButtonFound.

The pattern and index arguments are mutually exclusive.

Parameters
  • pattern (pattern, optional) The button caption to look for (by re.match).
  • index (int, optional) The index of the button, couting from top left to bottom right and starting at 0.
Returns (InlineKeyboardButton, optional)

The InlineKeyboardButton if found.

method

click(pattern=None, index=None)

Uses find_button with the given pattern or index, clicks the button if found, and waits for the bot to react in the same chat.

If not button could be found, NoButtonFound will be raised.

Parameters
  • pattern (pattern or str, optional) The button caption to look for (by re.match).
  • index (int, optional) The index of the button, couting from top left to bottom right and starting at 0.
Returns (Response)

The bot's Response.