Creating new commands

This document covers how to create a new command, which basically means that is it a guide on chatcommands.py.

1. The perfect function

Define a function that is the same name as the command you want. If you want a command called !!/createcommand, you would write a function like this:

@command()
def createcommand():
    return None

This command will do nothing. The function returns a string or None. If a string is returned, the string will be posted to chat. If None is returned, nothing will be posted to chat. You can put anything (read: the thing you want to do with this command) inside the function body.

2. Configuration of the @command()

To tweak the settings of your command, you have to edit the parameters inside @command()

3. Post something

To post data that is what you expected, simply execute return "your message here"

If you encounter an error, you can raise a CmdException with a string as the error message. The string will be sent to chat.

@command()
def somerandomcommand():
    if True:
        raise CmdException("Error: this error will be fixed in 6 to 8 weeks! HAHA")
    return None

If you want to send a message to all the rooms that Smokey is running in, use tell_rooms:

tell_rooms("A message")