commands Package

commands Package

class earwigbot.commands.Command(bot)[source]

EarwigBot: Base IRC Command

This package provides built-in IRC “commands” used by the bot’s front-end component. Additional commands can be installed as plugins in the bot’s working directory.

This class (import with from earwigbot.commands import Command), can be subclassed to create custom IRC commands.

This docstring is reported to the user when they type "!help <command>".

check(data)[source]

Return whether this command should be called in response to data.

Given a Data instance, return True if we should respond to this activity, or False if we should ignore it and move on. Be aware that since this is called for each message sent on IRC, it should be cheap to execute and unlikely to throw exceptions.

Most commands return True only if data.command == self.name, or data.command is in self.commands if that list is overriden. This is the default behavior; you should only override it if you wish to change that.

commands = []
hooks = ['msg']
name = None
process(data)[source]

Main entry point for doing a command.

Handle an activity (usually a message) on IRC. At this point, thanks to check() which is called automatically by the command handler, we know this is something we should respond to. Place your command’s body here.

setup()[source]

Hook called immediately after the command is loaded.

Does nothing by default; feel free to override.

unload()[source]

Hook called immediately before a command is unloaded.

Does nothing by default; feel free to override.

Table Of Contents

Previous topic

earwigbot Package

Next topic

config Package

This Page