Actions

A generic action. Every action must inherit from this class and override its methods.

Process the payload and return a response.

Parameters

payload (Optional[dict]) – An incoming message payload.

Return type

Union[Message, Response]

Returns

A message or a response object.

Serialize the class instance to a dictionary.

Return type

dict

Returns

A serialized class instance.

Bases: navmenu.actions.Action

An action that returns a message.

Parameters

text (str) – The message text.

Process the payload and return a response.

Parameters

payload (Optional[dict]) – An incoming message payload.

Return type

Message

Returns

A message or a response object.

Serialize the class instance to a dictionary.

Return type

dict

Returns

A serialized class instance.

Bases: navmenu.actions.Action

An action that opens a submenu.

Parameters

menu_name (str) – The name of the menu to open.

Process the payload and return a response.

Parameters

payload (Optional[dict]) – An incoming message payload.

Return type

Response

Returns

A message or a response object.

Serialize the class instance to a dictionary.

Return type

dict

Returns

A serialized class instance.

Bases: navmenu.actions.Action

An action that returns user to the one of previous menus.

Parameters

count (int) – How many times to go back.

Process the payload and return a response.

Parameters

payload (Optional[dict]) – An incoming message payload.

Return type

Response

Returns

A message or a response object.

Serialize the class instance to a dictionary.

Return type

dict

Returns

A serialized class instance.

Bases: navmenu.actions.Action

An action that executes a code and optionally returns a message with the result.

Parameters
  • command (str) – The code to execute.

  • return_text (bool) – Whether to return result as a message with text.

Process the payload and return a response.

Parameters

payload (Optional[dict]) – An incoming message payload.

Return type

Optional[Message]

Returns

A message or a response object.

Serialize the class instance to a dictionary.

Return type

dict

Returns

A serialized class instance.

Bases: navmenu.actions.Action

An action that runs a function and optionally returns a response.

Parameters
  • function – The function to run.

  • templates (Optional[Dict[Any, Union[Message, Response]]]) – The response templates.

Process the payload and return a response.

Parameters

payload (Optional[dict]) – An incoming message payload.

Return type

Union[Message, Response]

Returns

A message or a response object.

Serialize the class instance to a dictionary.

Return type

dict

Returns

A serialized class instance.