Skip to content

Documentation

Astariul edited this page May 22, 2019 · 48 revisions

Never hesitate to take a look at the code in case of confusion ! 😉

 


Page

Class representing a page of the help system. A page is displayed to the user, and the user can navigate through pages using reactions or messages.

Attributes

Name Type Description
msg str Message to send to the user when displaying the page.
links list of Link List of links associated to this page. These are the possible path to navigate to another page.
msg_link MsgLink MsgLink if there is one. It's not part of the link list because there can't be several MsgLink associated to a given page.
parent Link Link to the parent page.
root Link Link to the root page.
sep str String used to separate the message and the links description. Used only for formatting messages to send to user.
links_sep str String used to separate each link description. Used only for formatting messages to send to user.

 

Page()

Constructor. All links are set to None or empty list.

__init__(msg='', sep='\n\n', links_sep='\n')
Argument Type Default Description
msg str '' Message to send to user when displaying this page.
sep str '\n\n' String used to separate the message and the links description while formatting the message to send.
links_sep str '\n' String used to separate each links description while formatting the message to send.

 

link()

Create a link between the current page and the given page(s). This method is used to construct the tree.

link(pages, reaction=None, description=None, callbacks=[], user_input=False, is_parent=True, parent_reaction='🔙')
Argument Type Default Description
pages list of Page or Page Pages to associate to this link.
reaction str None Reaction emoji needed by the user to take that link. If None is given, use a default reaction (digits 1 ~ 9).
description str None Description of the link, to explain to user where this link will bring him.
callbacks list [] List of functions to call when taking this link.
user_input bool False Boolean indicating if this is a MsgLink. If True, a MsgLink is created, ignoring the reaction parameter.
is_parent bool True Boolean indicating if the current page should be the parent of the linked pages. If True a link will be created between pages to the current page as a parent link.
parent_reaction str or list of str 🔙 Emoji to use for the pages to go back to their parent : the current page. Used only if is_parent is True. Please use this only for advanced customization. To go even further, you specify a list of string, where each string is the emoji to use for each page of the list of pages given.

Throws :

  • IndexError : Only the 9 first links are provided with default reactions (digit 1 ~ 9). If you try to create more link with default reaction, this exception will be thrown.
  • ValueError : The number of parent reactions given does not match the number of child pages.

 

Clone this wiki locally