BaseMenu¶
-
class
pyrubrum.BaseMenu(name: str, menu_id: str, is_link: Optional[bool] = False)¶ Basic represention of a menu, which is an entity that has got by definition at least a name, a unique identifier and an associated button, which can be arbitrarily generated.
A menu can represent a link as well (see
BaseMenu.is_link), although it doesn’t by default.The purpose of this class is to give a general interface for a menu, as it doesn’t implement anything except for the generation of both buttons and hashes.
- Parameters
name (str) – The name you give to the menu, which will be used as the text of callback button, if needed.
menu_id (str) – The unique identifier given to the menu, which will refer unequivocally to this entity. The hash for this class is generated relying on the content of this field. Avoid using
0as it is used for buttons whose purpose is only related to design (i.e. they do not point to any menu, see Null-pointer button).is_link (Optional[bool]) – If this menu represents a link.
Warning
Avoid using the same identifier for other entities, as it will result in ambiguity.
-
button(handler: pyrubrum.handlers.base_handler.BaseHandler, client: pyrogram.client.client.Client, context: Any, parameters: Optional[Dict[str, Any]] = None) → pyrubrum.keyboard.button.Button¶ Create an inline button which refers to this menu, using
nameas the content of the text field andmenu_idas the unique identifier of theButtonobject.- Parameters
handler (BaseHandler) – The handler which coordinates the management of the menus.
client (Client) – The client which is linked to the handler.
context (Union[CallbackQuery, Message]) – The context for which button is generated for.
parameters (Optional[Dict[str, Any]]) – The parameters which were passed to the handler. Defaults to
None.
- Returns
The generated button.
- Return type