supybot.callbacks

Plugin

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

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

Proxy

alias of NestedCommandsIrcProxy

callCommand(*args, **kwargs)

Given a command name, gets the method with getCommandMethod() and calls it.

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, args=None)

Given a string ‘command’, dispatches to doCommand.

getCommand(args, stripOwnName=True)

Among all the commands in this Commands object, recursively searches for the command whose name is the longst substring of args, and returns its name, splitted on spaces.

getCommandHelp(command, simpleSyntax=None)

Returns the help string of the given command, using getCommandMethod().

getCommandMethod(command)

Gets the given command from this plugin, using getCommand(). Plugins only need to implement this if they have a dynamic set of commands.

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. Plugins only need to implement this if they have a dynamic set of commands.

isDisabled(command)

Returns whether the given command is disabled.

listCommands(pluginCommands=[])

List all the commands in this Commands object. Plugins only need to implement this if they have a dynamic set of commands.

name()

Returns the name of this Commands object (usually the plugin name).

outFilter(*args, **kwargs)

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

As with inFilter, an IrcMsg is returned.

postTransition(*args, **kwargs)

Called when the state of the IRC connection changes.

msg is the message that triggered the transition, if any.

registryValue(name, channel=None, network=None, *, value=True)

Returns the value of a configuration variable specified by name.

If the configuration variable has a channel- or network-specific variable (ie. if its value can change across channels or networks), channel and network allow getting the most specific value. If neither is given, returns the generic value.

If value=False, returns the variable itself (an instance of supybot.registry.Value) instead of its value.

reset(*args, **kwargs)

Resets the callback. Called when reconnecting to the server.

setRegistryValue(name, value, channel=None, network=None)

Sets a configuration variable. See registryValue()

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, network=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)

Given a command name, gets the method with getCommandMethod() and calls it.

canonicalName()[source]

Same as name(), but normalized.

commandArgs = ['self', 'irc', 'msg', 'args']
getCommand(args, stripOwnName=True)[source]

Among all the commands in this Commands object, recursively searches for the command whose name is the longst substring of args, and returns its name, splitted on spaces.

getCommandHelp(command, simpleSyntax=None)[source]

Returns the help string of the given command, using getCommandMethod().

getCommandMethod(command)[source]

Gets the given command from this plugin, using getCommand(). Plugins only need to implement this if they have a dynamic set of commands.

isCommand(*args, **kwargs)

Convenience, backwards-compatibility, semi-deprecated.

isCommandMethod(name)[source]

Returns whether a given method name is a command in this plugin. Plugins only need to implement this if they have a dynamic set of commands.

isDisabled(command)[source]

Returns whether the given command is disabled.

listCommands(pluginCommands=[])[source]

List all the commands in this Commands object. Plugins only need to implement this if they have a dynamic set of commands.

name()[source]

Returns the name of this Commands object (usually the plugin name).

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: 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]

Replies with an error.

Parameters:
  • s (str) – The error message
  • Raise (bool) – If True, this will raise Error that will propagate so that the caller of this function immediately terminates
  • **kwargs – See NestedCommandsIrcProxy.reply()’s keyword arguments
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:

Parameters:
  • noLengthCheck (bool) – True if the length shouldn’t be checked (used for ‘more’ handling)
  • prefixNick (bool) – False if the nick shouldn’t be prefixed to the reply.
  • action (bool) – True if the reply should be an action.
  • private (bool) – True if the reply should be in private.
  • notice (bool) – True if the reply should be noticed when the bot is configured to do so.
  • to (str) – The nick or channel the reply should go to. Defaults to msg.args[0] (or msg.nick if private)
  • sendImmediately (bool) – 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, network=None, *, value=True)[source]

Returns the value of a configuration variable specified by name.

If the configuration variable has a channel- or network-specific variable (ie. if its value can change across channels or networks), channel and network allow getting the most specific value. If neither is given, returns the generic value.

If value=False, returns the variable itself (an instance of supybot.registry.Value) instead of its value.

setRegistryValue(name, value, channel=None, network=None)[source]

Sets a configuration variable. See registryValue()

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.

queueMultilineBatches(msgs, target, targetNick, concat, allowedLength=0, sendImmediately=False)[source]

Queues the msgs passed as argument in batches using draft/multiline batches.

This errors if experimentalExtensions is disabled or draft/multiline was not negotiated.

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

Keyword arguments:

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

Replies with a success message, configurable with supybot.replies.success or the Success plugin.

Parameters:
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(irc, 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(*args, **kwargs)[source]
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(*args, **kwargs)[source]