class pyrubrum.Button(name: str, menu_id: str, parameters: Optional[Dict[str, Any]] = None, element_id: Optional[str] = '', link: Optional[str] = None, same_menu: Optional[bool] = False, **kwargs)

Representation of a button which belongs to an inline keyboard and has got, by definition, a unique identifier, which actually represents the menu this object is referring to, an Element identifier (i.e. the identifier of the object that is carried by the button and is then passed to the menu it is referring to, if any), a name, which is displayed inside the text field of the inline button, and a dictionary of parameters.

The dictionary that is passed as argument for representing parameters is always deep copied, if not None.

  • name (str) – The name which is displayed inside the text field of the inline button this object will be converted to.

  • menu_id (str) – The unique identifier of the button, which is the same as the one of the menu the button is referring to.

  • parameters (Optional[Dict[str, Any]]) – The parameters that will be passed to the menu this button is referring to. Defaults to None (i.e. the handler does not support parameterization).

  • element_id (Optional[str]) – The unique identifier of the Element the button is carrying, if any. Defaults to an empty string.

  • link (Optional[str]) – The website this button is referring to, if any. If provided, all the other arguments are ignored and this button is set to represent a button which redirects to a certain URL, which is the provided string itself.

  • same_menu (Optional[bool]) – If the button is referring to the same menu by which it was initialized. Defaults to False.

  • **kwargs – Arbitrary keyword arguments which can be used as a way to define a new parameter (key=value) that will be added to the dictionary of parameters.


There is a special group of names which are not available for being used as keys for parameters (not for arguments!). These are from_chat_id, menu_id, element_id and same_menu. If provided, they will be overwritten. Keys starting with page_ should be avoided according to PageStyle.generate_page_id.