pyrubrum Logo
latest

Quickstart

  • Installation
  • Writing your first bot

Examples

  • Environment variables
  • Café Bot
  • Calendar Bot
  • Hitchhiker Bot
  • Sample Bot

API Reference

  • Database
  • Database Errors
  • Handlers
  • Keyboard
  • Menus
    • BaseMenu
    • DeepLinkMenu
    • LinkMenu
    • Menu
    • PageMenu
  • Objects
  • Styles
  • Tree
  • Types

Meta

  • Assets
  • Changelog
  • Code of Conduct
  • Contributing
  • Flowchart guidelines
  • Glossary
  • License
  • Read me
  • Security Policy
pyrubrum
  • Docs »
  • Menus »
  • PageMenu
  • Edit on GitHub

PageMenu¶

class pyrubrum.PageMenu(name: str, menu_id: str, content: Union[pyrogram.client.types.input_media.input_media.InputMedia, str], items: Union[List[pyrubrum.keyboard.element.Element], Callable[[ParameterizedHandler, pyrogram.client.client.Client, Any, Dict[str, Any]], List[pyrubrum.keyboard.element.Element]]], deep_link: Optional[bool] = False, default: Optional[bool] = False, message_filter: Optional[pyrogram.client.filters.filter.Filter] = None, preliminary: Optional[Union[Callable[[Handler, pyrogram.client.client.Client, Any, Dict[str, Any]], None], List[Callable[[Handler, pyrogram.client.client.Client, Any, Dict[str, Any]], None]]]] = None, style: pyrubrum.menus.styles.base_style.BaseStyle = <pyrubrum.menus.styles.page_style.PageStyle object>)¶

Implementation of a menu which automatically, given a list of items, manages paging and the setting of parameters. It has got, by definition, all the parameters defined in Menu plus a list of items that will be displayed to the user.

See also

For understanding how the keyboard is being generated, see PageStyle.

Parameters
  • name (str) – The name you give to the menu, which will be used as the text of callback button, if needed. See BaseMenu for more information.

  • 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 0 as 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). See BaseMenu for more information.

  • content (Types.Content) –

    What will be displayed whenever a user accesses this menu. Both text and media can be provided. A function can be provided as well and must follow the following arguments pattern:

    func(handler, client, context, parameters)
    

    See Menu for more information.

  • items (types.Items) – The list of elements the menu is compounded of or a function which returns such type of value.

  • deep_link (Optional[bool]) – If this menu shall be reached by a deep-link whose payload is the identifier of this instance. Defaults to False.

  • default (Optional[bool]) – If this menu shall be displayed if no other top-level menu has been matched. It works only if this menu is a top-level one.

  • message_filter (Optional[Filter]) –

    A filter for telling Pyrogram when a message should be associated to this menu. It works only for top-level menus (see Handler.setup). Defaults to None, which automatically makes this menu reachable when the user texts a message that follows this pattern:

    /[MENU_ID]
    

  • preliminary (Types.Preliminary) – A function which is executed each time before doing anything else in on_callback and on_message. You can provide a list of such functions as well, which will be executed following the same order as the one of the list. Defaults to None, which means that no function is going to be executed.

  • style (BaseStyle) – The class which generates the keyboard for this function following a certain style. Defaults to PageStyle().

Warning

This implementation is not compatible with a non-parameterized handler. An handler that supports parameterization is required.

Next Previous

© Copyright 2020, Hearot Revision 2539f70e.

Built with Sphinx using a theme provided by Read the Docs.