Skip to content

Package: commands

Josh Chandler edited this page Oct 2, 2018 · 2 revisions

commands

commands contains all custom command classes. You should never have to instantiate or import anything from this module outside of commandcenter. It is used by commander to automatically load commands.

How to create a new command

See creating a new command.

Attributes

self.name : The name of the command. This should be written exactly as you would write the command in chat when you call it. Be sure to include a dollar sign.

self.help : The command's help string as shown when the $help command is quried. It should follow this format:
$<command name> | <command purpose> | <usage instructions>
Example:
$info | Display info about a command. | Usage: $info <command (including the dollar sign)>

self.author : The author of the command as shown when the $info command is queried.

self.last_updated : The date that the command was last updated as shown when the $info command is queried.

Methods

__init__()

Simple constructor in which you should set the above attributes.

run(event_pack: EventPackage)

This is where you define what your custom command does. This method must return a string, which is what gets sent to the room. event_pack contains information about the event that triggered this command such as the message body and the message sender. See Package: eventpackage.

Usage:

To create a new command, all that needs to be done is the creation of a class that follows this structure. The commander module will handle the rest and automatically load your command.

See template.py for an example command.