The file src/callbacks.py contains some useful utility methods, as well as the base classes for plugins. To use it in your plugin:
import supybot.callbacks as callbacks
addressed(nick, msg, kwargs)**
Check if the bot has been addressed by the message. Looks at start and/or end of message content, depending on configuration variables supybot.reply.whenAddressedBy.chars, supybot.reply.whenAddressedBy.nick, supybot.reply.whenAddressedBy.nick.atEnd, supybot.reply.whenAddressedBy.nicks.
nick should be the bot's nick, msg should be a [Msg_object]. *kwargs can include the following optional arguments (listed with their default values): prefixChars=None, nicks=None, prefixStrings=None, whenAddressedByNick=None, whenAddressedByNickAtEnd=None. If not None, these take precedence over their corresponding config values.
You might use it in your plugin if you want to check if a message was addressed to a bot, as follows:
if callbacks.addressed(irc.nick, msg): do_what_you_want()
Turn a command into its canonical form.
Currently, this makes everything lowercase and removes all dashes and underscores.
TODO: needs content
TODO: needs content
TODO: needs content
TODO: needs content
TODO: needs content
TODO: needs content
This function parses a command string into a list, (or for nested commands, nested list), in preparation for processing by the command dispatcher. One situation where you may want to use this function if you want to "simulate" a command being sent to the bot, in combination with plugin method Proxy.
Here's an example code snippet you might use in a plugin method, to have the bot execute an arbitrary command stored in commandstring:
tokens = callbacks.tokenize(commandstring) try: self.Proxy(irc.irc, msg, tokens) except Exception, e: log.exception('Uncaught exception in function:')
Plugin methods are documented in the [Plugin_object] documentation.
Wiki: Msg_object
Wiki: Plugin_object
Wiki: Supybot_Resources