supybot.callbacks

Plugin

class supybot.callbacks.Plugin(*args, **kwargs)[source]

Bases: supybot.callbacks.PluginMixin, supybot.callbacks.Commands

Proxy

alias of NestedCommandsIrcProxy

callPrecedence(*args, **kwargs)

Returns a pair of (callbacks to call before me, callbacks to call after me)

die(*args, **kwargs)

Makes the callback die. Called when the parent Irc object dies.

dispatchCommand(command)

Given a string ‘command’, dispatches to doCommand.

getCommandMethod(command)

Gets the given command from this plugin.

inFilter(*args, **kwargs)

Used for filtering/modifying messages as they’re entering.

ircmsgs.IrcMsg objects are immutable, so this method is expected to return another ircmsgs.IrcMsg object. Obviously the same IrcMsg can be returned.

isCommand(*args, **kwargs)

Convenience, backwards-compatibility, semi-deprecated.

isCommandMethod(name)

Returns whether a given method name is a command in this plugin.

name()

Returns the name of the callback.

outFilter(*args, **kwargs)

Used for filtering/modifying messages as they’re leaving.

As with inFilter, an IrcMsg is returned.

reset(*args, **kwargs)

Resets the callback. Called when reconnecting to the server.

PluginRegexp

class supybot.callbacks.PluginRegexp(*args, **kwargs)[source]

Bases: supybot.callbacks.Plugin

Same as Plugin, except allows the user to also include regexp-based callbacks. All regexp-based callbacks must be specified in the set (or list) attribute “regexps”, “addressedRegexps”, or “unaddressedRegexps” depending on whether they should always be triggered, triggered only when the bot is addressed, or triggered only when the bot isn’t addressed.

addressedRegexps = ()

‘addressedRegexps’ methods are called only when the message is addressed, and then, only with the payload (i.e., what is returned from the ‘addressed’ function.

regexps = ()

‘regexps’ methods are called whether the message is addressed or not.

unaddressedRegexps = ()

‘unaddressedRegexps’ methods are called only when the message is not addressed.

tokenize

supybot.callbacks.tokenize(s, channel=None)[source]

A utility function to create a Tokenizer and tokenize a string.

Other classes

This module contains the basic callbacks for handling PRIVMSGs.

exception supybot.callbacks.ArgumentError[source]

Bases: supybot.callbacks.Error

The bot replies with a help message when this is raised.

class supybot.callbacks.BasePlugin(*args, **kwargs)[source]

Bases: object

class supybot.callbacks.CanonicalNameDict(dict=None, key=None)[source]

Bases: supybot.utils.gen.InsensitivePreservingDict

key(s)[source]

Override this if you wish.

class supybot.callbacks.CanonicalNameSet(iterable=())[source]

Bases: supybot.utils.gen.NormalizingSet

normalize(s)[source]
class supybot.callbacks.CanonicalString(default, *args, **kwargs)[source]

Bases: supybot.registry.NormalizedString

normalize(s)[source]
class supybot.callbacks.CommandProcess(target=None, args=(), kwargs={})[source]

Bases: supybot.world.SupyProcess

Just does some extra logging and error-recovery for commands that need to run in processes.

run()[source]

Method to be run in sub-process; can be overridden in sub-class

class supybot.callbacks.CommandThread(target=None, args=(), kwargs={})[source]

Bases: supybot.world.SupyThread

Just does some extra logging and error-recovery for commands that need to run in threads.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

class supybot.callbacks.Commands(*args, **kwargs)[source]

Bases: supybot.callbacks.BasePlugin, supybot.utils.python.SynchronizedAndFirewalled

callCommand(*args, **kwargs)
canonicalName()[source]
commandArgs = ['self', 'irc', 'msg', 'args']
getCommand(args, stripOwnName=True)[source]
getCommandHelp(command, simpleSyntax=None)[source]
getCommandMethod(command)[source]

Gets the given command from this plugin.

isCommand(*args, **kwargs)

Convenience, backwards-compatibility, semi-deprecated.

isCommandMethod(name)[source]

Returns whether a given method name is a command in this plugin.

isDisabled(command)[source]
listCommands(pluginCommands=[])[source]
name()[source]
pre_command_callbacks = []
class supybot.callbacks.Disabled(default, help, setDefault=True, showDefault=True, **kwargs)[source]

Bases: supybot.registry.SpaceSeparatedListOf

List

alias of CanonicalNameSet

Value

alias of CanonicalString

sorted = True
class supybot.callbacks.DisabledCommands[source]

Bases: object

add(command, plugin=None)[source]
disabled(command, plugin=None)[source]
remove(command, plugin=None)[source]
exception supybot.callbacks.Error[source]

Bases: exceptions.Exception

Generic class for errors in Privmsg callbacks.

supybot.callbacks.IrcObjectProxy

alias of supybot.callbacks.NestedCommandsIrcProxy

class supybot.callbacks.MetaSynchronizedAndFirewalled[source]

Bases: supybot.log.MetaFirewall, supybot.utils.python.MetaSynchronized

class supybot.callbacks.NestedCommandsIrcProxy(irc, msg, args, nested=0)[source]

Bases: supybot.callbacks.ReplyIrcProxy

A proxy object to allow proper nesting of commands (even threaded ones).

error(s='', Raise=False, **kwargs)[source]
evalArgs(withClass=None)[source]
finalEval()[source]
findCallbacksForArgs(args)[source]

Returns a two-tuple of (command, plugins) that has the command (a list of strings) and the plugins for which it was a command.

noReply(msg=None)[source]
replies(L, prefixer=None, joiner=None, onlyPrefixFirst=False, to=None, oneToOne=None, **kwargs)[source]
reply(s, noLengthCheck=False, prefixNick=None, action=None, private=None, notice=None, to=None, msg=None, sendImmediately=False, stripCtcp=True)[source]

Keyword arguments:

  • noLengthCheck=False: True if the length shouldn’t be checked
    (used for ‘more’ handling)
  • prefixNick=True: False if the nick shouldn’t be prefixed to the
    reply.
  • action=False: True if the reply should be an action.
  • private=False: True if the reply should be in private.
  • notice=False: True if the reply should be noticed when the
    bot is configured to do so.
  • to=<nick|channel>: The nick or channel the reply should go to.
    Defaults to msg.args[0] (or msg.nick if private)
  • sendImmediately=False: True if the reply should use sendMsg() which
    bypasses conf.supybot.protocols.irc.throttleTime and gets sent before any queued messages
class supybot.callbacks.PluginMixin(irc)[source]

Bases: supybot.callbacks.BasePlugin, supybot.irclib.IrcCallback

Proxy

alias of NestedCommandsIrcProxy

alwaysCall = ()
canonicalName()[source]
classModule = None
getPluginHelp()[source]
noIgnore = False
public = True
registryValue(name, channel=None, value=True)[source]
setRegistryValue(name, value, channel=None)[source]
setUserValue(name, prefixOrName, value, ignoreNoUser=True, setValue=True)[source]
threaded = False
userValue(name, prefixOrName, default=None)[source]
supybot.callbacks.Privmsg

alias of supybot.callbacks.Plugin

supybot.callbacks.PrivmsgCommandAndRegexp

alias of supybot.callbacks.PluginRegexp

class supybot.callbacks.ReplyIrcProxy(irc, msg)[source]

Bases: supybot.callbacks.RichReplyMethods

This class is a thin wrapper around an irclib.Irc object that gives it the reply() and error() methods (as well as everything in RichReplyMethods, based on those two).

error(s, msg=None, **kwargs)[source]
getRealIrc()[source]

Returns the real irclib.Irc object underlying this proxy chain.

reply(s, msg=None, **kwargs)[source]
class supybot.callbacks.RichReplyMethods[source]

Bases: object

This is a mixin so these replies need only be defined once. It operates under several assumptions, including the fact that ‘self’ is an Irc object of some sort and there is a self.msg that is an IrcMsg.

errorInvalid(what, given=None, s='', repr=True, **kwargs)[source]
errorNoCapability(capability, s='', **kwargs)[source]
errorNoUser(s='', name='that user', **kwargs)[source]
errorNotRegistered(s='', **kwargs)[source]
errorPossibleBug(s='', **kwargs)[source]
errorRequiresPrivacy(s='', **kwargs)[source]
noReply(msg=None)[source]
replies(L, prefixer=None, joiner=None, onlyPrefixFirst=False, oneToOne=None, **kwargs)[source]
replyError(s='', **kwargs)[source]
replySuccess(s='', **kwargs)[source]
exception supybot.callbacks.SilentError[source]

Bases: supybot.callbacks.Error

An error that we should not notify the user.

supybot.callbacks.SimpleProxy

alias of supybot.callbacks.ReplyIrcProxy

class supybot.callbacks.Tokenizer(brackets='', pipe=False, quotes='"')[source]

Bases: object

separators = '\x00\r\n \t'
supybot.callbacks.addressed(nick, msg, **kwargs)[source]

If msg is addressed to ‘name’, returns the portion after the address. Otherwise returns the empty string.

supybot.callbacks.canonicalName(command, preserve_spaces=False)[source]

Turn a command into its canonical form.

Currently, this makes everything lowercase and removes all dashes and underscores.

supybot.callbacks.checkCommandCapability(msg, cb, commandName)[source]
supybot.callbacks.error(msg, s, **kwargs)[source]

Makes an error reply to msg with the appropriate error payload.

supybot.callbacks.formatCommand(command)[source]
supybot.callbacks.getHelp(method, name=None, doc=None)[source]
supybot.callbacks.getSyntax(method, name=None, doc=None)[source]
supybot.callbacks.reply(msg, s, prefixNick=None, private=None, notice=None, to=None, action=None, error=False, stripCtcp=True)[source]