BaseHandler¶
-
class
pyrubrum.
BaseHandler
¶ Basic representation of an handler, which is an entity that manages the setup of a
Client
instance (i.e. the bot).The purpose of this class is to give a general interface for an handler, even if it already implements both a sample setup and a keyboard processing function.
Note
In order to create a subclass or to access this interface, you will need to implement the abstract method
get_menus
. Otherwise, you will get an error.This abstract method is intended to be implemented as a collector of all the menus which were defined while initializing this object.
- Returns
The set of the menus that were collected during the lookup process.
- Return type
Set[BaseMenu]
-
process_keyboard
(keyboard: List[List[pyrubrum.keyboard.button.Button]], callback_query_id: str, chat_id: int) → List[List[pyrogram.client.types.bots_and_keyboards.inline_keyboard_button.InlineKeyboardButton]]¶ Given a list which represents an inline keyboard, a unique identifier for the callback and one for the chat from which the query was called, generate a Pyrogram-compatible inline keyboard.
- Parameters
- Returns
The generated keyboard in a Pyrogram-compatible type.
- Return type
List[List[pyrogram.InlineKeyboardButton]]
-
setup
(client: pyrogram.client.client.Client)¶ Make all the defined menus reachable by the client by adding handlers that catch all their identifiers to it. It also calls
pass_handler
, which lets the callback functions get this handler as argument.- Parameters
client (Client) – The client which is being set up.
Warning
The functions the handlers make use of are not set up in the same way objects added using Pyrogram handlers are. Pyrubrum implements the following pattern:
callback(handler, client, context, parameters)