-
Notifications
You must be signed in to change notification settings - Fork 1
Documentation
Never hesitate to take a look at the sources in case of confusion ! ๐
ย
ย
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.
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. |
ย
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. |
ย
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 can 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.
ย
Link a list of pages to the current page as a parent. This method is used to construct the tree, in order to set specific parent for some pages.
parent_of(pages, parent_reaction='๐')
Argument | Type | Default | Description |
---|---|---|---|
pages |
list of Page or Page
|
Given pages will have the current page as a parent. | |
parent_reaction |
str or list of str
|
๐ |
Emoji to use for the pages to go back to their parent : the current page. Please use this only for advanced customization. To go even further, you can specify a list of string, where each string is the emoji to use for each page of the list of pages given. |
Throws :
-
ValueError
: The number of parent reactions given does not match the number of child pages.
ย
Link a list of pages to the current page as root. This method is used to construct the tree, in order to set the root for some pages.
root_of(pages, parent_reaction='๐')
Argument | Type | Default | Description |
---|---|---|---|
pages |
list of Page or Page
|
Given pages will have the current page as root. | |
root_reaction |
str or list of str
|
'๐' | Emoji to use for the pages to go back to the root : the current page. Please use this only for advanced customization. To go even further, you can specify a list of string, where each string is the emoji to use for each page of the list of pages given. |
Throws :
-
ValueError
: The number of root reactions given does not match the number of pages given.
ย
Method used by the Help, to display the content of a Page. This method construct the message to send to user as a string and return it. The string contain the message of the page, as well as the message describing each Link of the Page.
content()
Returns :
-
str
: The content of the message to send to the user when displaying the current page.
ย
Method used by the Help, to retrieve the list of reactions that the user can use when visualizing the current page, to interact with the Help.
reactions()
Returns :
-
list of str
: List of reactions that the user can use for this page.
ย
Method used by the Help to know if a user can input something when using this page, or should only use reactions.
need_user_input()
Returns :
-
bool
: ReturnTrue
if a MsgLink is associated to this page,False
otherwise.
ย
Method used by the Help to access the next Link based on the reaction given. If the reaction is None
, retrieve the MsgLink. If the reaction is not valid (no link associated to this reaction), None
is returned.
next_link(reaction=None)
Argument | Type | Default | Description |
---|---|---|---|
reaction |
str |
None |
Reaction chosen by the user, representing a Link. If None , the link returned is a MsgLink. |
Returns :
-
Link
: The next Link to display, based on the reaction of the user, orNone
if the choice of the user is not valid.