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
andnetwork
allow getting the most specific value. If neither is given, returns the generic value.If
value=False
, returns the variable itself (an instance ofsupybot.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¶
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.
CanonicalNameDict
(dict=None, key=None)[source]¶ Bases:
supybot.utils.gen.InsensitivePreservingDict
-
class
supybot.callbacks.
CanonicalNameSet
(iterable=())[source]¶ Bases:
supybot.utils.gen.NormalizingSet
-
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.
-
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.
-
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.
-
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.
-
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¶
-
-
exception
supybot.callbacks.
Error
[source]¶ Bases:
Exception
Generic class for errors in Privmsg callbacks.
-
supybot.callbacks.
IrcObjectProxy
¶
-
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
-
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.
-
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
= ()¶
-
classModule
= None¶
-
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
andnetwork
allow getting the most specific value. If neither is given, returns the generic value.If
value=False
, returns the variable itself (an instance ofsupybot.registry.Value
) instead of its value.
-
setRegistryValue
(name, value, channel=None, network=None)[source]¶ Sets a configuration variable. See
registryValue()
-
threaded
= False¶
-
-
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).
-
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.
-
replySuccess
(s='', **kwargs)[source]¶ Replies with a success message, configurable with
supybot.replies.success
or the Success plugin.Parameters: - s (str) – Text to append to the standard success message
- **kwargs – See
NestedCommandsIrcProxy.reply()
’s keyword arguments
-
-
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.