mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
Changed callbacks.Privmsg to be callbacks.Plugin, and callbacks.PrivmsgCommandAndRegexp to be callbacks.Plugin.
This commit is contained in:
parent
3c3b729ee7
commit
b0cb616709
@ -39,7 +39,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.schedule as schedule
|
import supybot.schedule as schedule
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Admin(callbacks.Privmsg):
|
class Admin(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Admin, self)
|
self.__parent = super(Admin, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -162,7 +162,7 @@ def makeNewAlias(name, alias):
|
|||||||
f = utils.changeFunctionName(f, name, doc)
|
f = utils.changeFunctionName(f, name, doc)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
class Alias(callbacks.Privmsg):
|
class Alias(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Alias, self)
|
self.__parent = super(Alias, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -33,7 +33,7 @@ from supybot.commands import *
|
|||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Anonymous(callbacks.Privmsg):
|
class Anonymous(callbacks.Plugin):
|
||||||
"""This plugin allows users to act through the bot anonymously. The 'do'
|
"""This plugin allows users to act through the bot anonymously. The 'do'
|
||||||
command has the bot perform an anonymous action in a given channel, and
|
command has the bot perform an anonymous action in a given channel, and
|
||||||
the 'say' command allows other people to speak through the bot. Since
|
the 'say' command allows other people to speak through the bot. Since
|
||||||
|
@ -38,7 +38,7 @@ import supybot.callbacks as callbacks
|
|||||||
class Continue(Exception):
|
class Continue(Exception):
|
||||||
pass # Used below, look in the "do" function nested in doJoin.
|
pass # Used below, look in the "do" function nested in doJoin.
|
||||||
|
|
||||||
class AutoMode(callbacks.Privmsg):
|
class AutoMode(callbacks.Plugin):
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if ircutils.strEqual(irc.nick, msg.nick):
|
if ircutils.strEqual(irc.nick, msg.nick):
|
||||||
|
@ -34,7 +34,7 @@ import supybot.utils as utils
|
|||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Babelfish(callbacks.Privmsg):
|
class Babelfish(callbacks.Plugin):
|
||||||
threaded = True
|
threaded = True
|
||||||
_abbrevs = utils.gen.abbrev(map(str.lower, babelfish.available_languages))
|
_abbrevs = utils.gen.abbrev(map(str.lower, babelfish.available_languages))
|
||||||
_abbrevs['de'] = 'german'
|
_abbrevs['de'] = 'german'
|
||||||
|
@ -38,7 +38,7 @@ import supybot.schedule as schedule
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Channel(callbacks.Privmsg):
|
class Channel(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Channel, self)
|
self.__parent = super(Channel, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -47,7 +47,7 @@ class FakeLog(object):
|
|||||||
def write(self, s):
|
def write(self, s):
|
||||||
return
|
return
|
||||||
|
|
||||||
class ChannelLogger(callbacks.Privmsg):
|
class ChannelLogger(callbacks.Plugin):
|
||||||
noIgnore = True
|
noIgnore = True
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(ChannelLogger, self)
|
self.__parent = super(ChannelLogger, self)
|
||||||
|
@ -149,7 +149,7 @@ class StatsDB(plugins.ChannelUserDB):
|
|||||||
return self[channel, id]
|
return self[channel, id]
|
||||||
|
|
||||||
filename = conf.supybot.directories.data.dirize('ChannelStats.db')
|
filename = conf.supybot.directories.data.dirize('ChannelStats.db')
|
||||||
class ChannelStats(callbacks.Privmsg):
|
class ChannelStats(callbacks.Plugin):
|
||||||
noIgnore = True
|
noIgnore = True
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(ChannelStats, self)
|
self.__parent = super(ChannelStats, self)
|
||||||
@ -164,7 +164,7 @@ class ChannelStats(callbacks.Privmsg):
|
|||||||
def die(self):
|
def die(self):
|
||||||
world.flushers.remove(self._flush)
|
world.flushers.remove(self._flush)
|
||||||
self.db.close()
|
self.db.close()
|
||||||
callbacks.Privmsg.die(self)
|
self.__parent.die()
|
||||||
|
|
||||||
def __call__(self, irc, msg):
|
def __call__(self, irc, msg):
|
||||||
try:
|
try:
|
||||||
|
@ -99,7 +99,7 @@ def getConfigVar(irc, msg, args, state):
|
|||||||
irc.errorInvalid('configuration variable', str(e))
|
irc.errorInvalid('configuration variable', str(e))
|
||||||
addConverter('configVar', getConfigVar)
|
addConverter('configVar', getConfigVar)
|
||||||
|
|
||||||
class Config(callbacks.Privmsg):
|
class Config(callbacks.Plugin):
|
||||||
def callCommand(self, name, irc, msg, *L, **kwargs):
|
def callCommand(self, name, irc, msg, *L, **kwargs):
|
||||||
try:
|
try:
|
||||||
super(Config, self).callCommand(name, irc, msg, *L, **kwargs)
|
super(Config, self).callCommand(name, irc, msg, *L, **kwargs)
|
||||||
|
@ -37,7 +37,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.schedule as schedule
|
import supybot.schedule as schedule
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Ctcp(callbacks.PrivmsgCommandAndRegexp):
|
class Ctcp(callbacks.PluginRegexp):
|
||||||
public = False
|
public = False
|
||||||
regexps = ('ctcpPing', 'ctcpVersion', 'ctcpUserinfo',
|
regexps = ('ctcpPing', 'ctcpVersion', 'ctcpUserinfo',
|
||||||
'ctcpTime', 'ctcpFinger', 'ctcpSource')
|
'ctcpTime', 'ctcpFinger', 'ctcpSource')
|
||||||
|
@ -37,7 +37,7 @@ from supybot.commands import *
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Dict(callbacks.Privmsg):
|
class Dict(callbacks.Plugin):
|
||||||
threaded = True
|
threaded = True
|
||||||
def dictionaries(self, irc, msg, args):
|
def dictionaries(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
@ -43,7 +43,7 @@ class MyFilterProxy(object):
|
|||||||
def reply(self, s):
|
def reply(self, s):
|
||||||
self.s = s
|
self.s = s
|
||||||
|
|
||||||
class Filter(callbacks.Privmsg):
|
class Filter(callbacks.Plugin):
|
||||||
"""This plugin offers several commands which transform text in some way.
|
"""This plugin offers several commands which transform text in some way.
|
||||||
It also provides the capability of using such commands to 'filter' the
|
It also provides the capability of using such commands to 'filter' the
|
||||||
output of the bot -- for instance, you could make everything the bot says
|
output of the bot -- for instance, you could make everything the bot says
|
||||||
|
@ -53,7 +53,7 @@ class FilterTest(ChannelPluginTestCase):
|
|||||||
self.assertNotError('outfilter rot13')
|
self.assertNotError('outfilter rot13')
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
callbacks.Privmsg._disabled.remove('rot13')
|
callbacks.Plugin._disabled.remove('rot13')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ def configure(advanced):
|
|||||||
from supybot.questions import expect, anything, something, yn
|
from supybot.questions import expect, anything, something, yn
|
||||||
conf.registerPlugin('Format', True)
|
conf.registerPlugin('Format', True)
|
||||||
|
|
||||||
class Format(callbacks.Privmsg):
|
class Format(callbacks.Plugin):
|
||||||
def bold(self, irc, msg, args, text):
|
def bold(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
class Games(callbacks.Privmsg):
|
class Games(callbacks.Plugin):
|
||||||
def coin(self, irc, msg, args):
|
def coin(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ last24hours = structures.TimeoutQueue(86400)
|
|||||||
totalTime = conf.supybot.plugins.Google.state.time()
|
totalTime = conf.supybot.plugins.Google.state.time()
|
||||||
searches = conf.supybot.plugins.Google.state.searches()
|
searches = conf.supybot.plugins.Google.state.searches()
|
||||||
|
|
||||||
class Google(callbacks.PrivmsgCommandAndRegexp):
|
class Google(callbacks.PluginRegexp):
|
||||||
threaded = True
|
threaded = True
|
||||||
callBefore = ['URL']
|
callBefore = ['URL']
|
||||||
regexps = ['googleSnarfer', 'googleGroups']
|
regexps = ['googleSnarfer', 'googleGroups']
|
||||||
|
@ -52,7 +52,7 @@ class HeraldDB(plugins.ChannelUserDB):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
return L[0]
|
return L[0]
|
||||||
|
|
||||||
class Herald(callbacks.Privmsg):
|
class Herald(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Herald, self)
|
self.__parent = super(Herald, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -36,7 +36,7 @@ from supybot.utils.iter import any
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
class Internet(callbacks.Privmsg):
|
class Internet(callbacks.Plugin):
|
||||||
"""Add the help for "@help Internet" here."""
|
"""Add the help for "@help Internet" here."""
|
||||||
threaded = True
|
threaded = True
|
||||||
def dns(self, irc, msg, args, host):
|
def dns(self, irc, msg, args, host):
|
||||||
|
@ -208,7 +208,7 @@ class SqliteKarmaDB(object):
|
|||||||
KarmaDB = plugins.DB('Karma',
|
KarmaDB = plugins.DB('Karma',
|
||||||
{'sqlite': SqliteKarmaDB})
|
{'sqlite': SqliteKarmaDB})
|
||||||
|
|
||||||
class Karma(callbacks.Privmsg):
|
class Karma(callbacks.Plugin):
|
||||||
callBefore = ('Factoids', 'MoobotFactoids', 'Infobot')
|
callBefore = ('Factoids', 'MoobotFactoids', 'Infobot')
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Karma, self)
|
self.__parent = super(Karma, self)
|
||||||
|
@ -38,7 +38,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
class Later(callbacks.Privmsg):
|
class Later(callbacks.Plugin):
|
||||||
"""Used to do things later; currently, it only allows the sending of
|
"""Used to do things later; currently, it only allows the sending of
|
||||||
nick-based notes. Do note (haha!) that these notes are *not* private
|
nick-based notes. Do note (haha!) that these notes are *not* private
|
||||||
and don't even pretend to be; if you want such features, consider using the
|
and don't even pretend to be; if you want such features, consider using the
|
||||||
|
@ -43,7 +43,7 @@ import convertcore
|
|||||||
|
|
||||||
baseArg = ('int', 'base', lambda i: i <= 36)
|
baseArg = ('int', 'base', lambda i: i <= 36)
|
||||||
|
|
||||||
class Math(callbacks.Privmsg):
|
class Math(callbacks.Plugin):
|
||||||
def base(self, irc, msg, args, frm, to, number):
|
def base(self, irc, msg, args, frm, to, number):
|
||||||
"""<fromBase> [<toBase>] <number>
|
"""<fromBase> [<toBase>] <number>
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import supybot.callbacks as callbacks
|
|||||||
|
|
||||||
from supybot.utils.iter import ifilter
|
from supybot.utils.iter import ifilter
|
||||||
|
|
||||||
class Misc(callbacks.Privmsg):
|
class Misc(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Misc, self)
|
self.__parent = super(Misc, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
@ -143,7 +143,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
commands = {}
|
commands = {}
|
||||||
L = []
|
L = []
|
||||||
for cb in irc.callbacks:
|
for cb in irc.callbacks:
|
||||||
if isinstance(cb, callbacks.Privmsg):
|
if isinstance(cb, callbacks.Plugin):
|
||||||
for attr in dir(cb):
|
for attr in dir(cb):
|
||||||
if s in attr and cb.isCommand(attr):
|
if s in attr and cb.isCommand(attr):
|
||||||
if attr == callbacks.canonicalName(attr):
|
if attr == callbacks.canonicalName(attr):
|
||||||
|
@ -38,7 +38,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Network(callbacks.Privmsg):
|
class Network(callbacks.Plugin):
|
||||||
_whois = {}
|
_whois = {}
|
||||||
_latency = {}
|
_latency = {}
|
||||||
def _getIrc(self, network):
|
def _getIrc(self, network):
|
||||||
|
@ -34,7 +34,7 @@ import supybot.ircmsgs as ircmsgs
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class NickCapture(callbacks.Privmsg):
|
class NickCapture(callbacks.Plugin):
|
||||||
"""This module constantly tries to take whatever nick is configured as
|
"""This module constantly tries to take whatever nick is configured as
|
||||||
supybot.nick. Just make sure that's set appropriately, and thus plugin
|
supybot.nick. Just make sure that's set appropriately, and thus plugin
|
||||||
will do the rest."""
|
will do the rest."""
|
||||||
@ -55,7 +55,7 @@ class NickCapture(callbacks.Privmsg):
|
|||||||
# except on reconnects, which can cause trouble.
|
# except on reconnects, which can cause trouble.
|
||||||
# if nick not in irc.state.nicksToHostmasks:
|
# if nick not in irc.state.nicksToHostmasks:
|
||||||
self._ison(irc, nick)
|
self._ison(irc, nick)
|
||||||
callbacks.Privmsg.__call__(self, irc, msg)
|
self.__parent.__call__(irc, msg)
|
||||||
|
|
||||||
def _ison(self, irc, nick):
|
def _ison(self, irc, nick):
|
||||||
if self.registryValue('ison'):
|
if self.registryValue('ison'):
|
||||||
|
@ -72,7 +72,7 @@ def numberShifts(s):
|
|||||||
s=re.sub('[0-9]+', 'n', s)
|
s=re.sub('[0-9]+', 'n', s)
|
||||||
return len(s)-1
|
return len(s)-1
|
||||||
|
|
||||||
class Nickometer(callbacks.Privmsg):
|
class Nickometer(callbacks.Plugin):
|
||||||
def punish(self, damage, reason):
|
def punish(self, damage, reason):
|
||||||
self.log.debug('%s lameness points awarded: %s' % (damage, reason))
|
self.log.debug('%s lameness points awarded: %s' % (damage, reason))
|
||||||
return damage
|
return damage
|
||||||
|
@ -124,7 +124,7 @@ class DbiNoteDB(dbi.DB):
|
|||||||
|
|
||||||
NoteDB = plugins.DB('Note', {'flat': DbiNoteDB})
|
NoteDB = plugins.DB('Note', {'flat': DbiNoteDB})
|
||||||
|
|
||||||
class Note(callbacks.Privmsg):
|
class Note(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent= super(Note, self)
|
self.__parent= super(Note, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -119,7 +119,7 @@ class LogProxy(object):
|
|||||||
return getattr(self.log, attr)
|
return getattr(self.log, attr)
|
||||||
|
|
||||||
|
|
||||||
class Owner(callbacks.Privmsg):
|
class Owner(callbacks.Plugin):
|
||||||
# This plugin must be first; its priority must be lowest; otherwise odd
|
# This plugin must be first; its priority must be lowest; otherwise odd
|
||||||
# things will happen when adding callbacks.
|
# things will happen when adding callbacks.
|
||||||
def __init__(self, irc=None):
|
def __init__(self, irc=None):
|
||||||
|
@ -33,7 +33,7 @@ import supybot.ircmsgs as ircmsgs
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Protector(callbacks.Privmsg):
|
class Protector(callbacks.Plugin):
|
||||||
def isImmune(self, irc, msg):
|
def isImmune(self, irc, msg):
|
||||||
if not ircutils.isUserHostmask(msg.prefix):
|
if not ircutils.isUserHostmask(msg.prefix):
|
||||||
self.log.debug('%q is immune, it\'s a server.', msg)
|
self.log.debug('%q is immune, it\'s a server.', msg)
|
||||||
|
@ -183,7 +183,7 @@ class SqliteQuoteGrabsDB(object):
|
|||||||
|
|
||||||
QuoteGrabsDB = plugins.DB('QuoteGrabs', {'sqlite': SqliteQuoteGrabsDB})
|
QuoteGrabsDB = plugins.DB('QuoteGrabs', {'sqlite': SqliteQuoteGrabsDB})
|
||||||
|
|
||||||
class QuoteGrabs(callbacks.Privmsg):
|
class QuoteGrabs(callbacks.Plugin):
|
||||||
"""Add the help for "@help QuoteGrabs" here."""
|
"""Add the help for "@help QuoteGrabs" here."""
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(QuoteGrabs, self)
|
self.__parent = super(QuoteGrabs, self)
|
||||||
|
@ -49,7 +49,7 @@ def getFeedName(irc, msg, args, state):
|
|||||||
state.args.append(callbacks.canonicalName(args.pop(0)))
|
state.args.append(callbacks.canonicalName(args.pop(0)))
|
||||||
addConverter('feedName', getFeedName)
|
addConverter('feedName', getFeedName)
|
||||||
|
|
||||||
class RSS(callbacks.Privmsg):
|
class RSS(callbacks.Plugin):
|
||||||
"""This plugin is useful both for announcing updates to RSS feeds in a
|
"""This plugin is useful both for announcing updates to RSS feeds in a
|
||||||
channel, and for retrieving the headlines of RSS feeds via command. Use
|
channel, and for retrieving the headlines of RSS feeds via command. Use
|
||||||
the "add" command to add feeds to this plugin, and use the "announce"
|
the "add" command to add feeds to this plugin, and use the "announce"
|
||||||
|
@ -39,7 +39,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
from supybot.structures import MultiSet, TimeoutQueue
|
from supybot.structures import MultiSet, TimeoutQueue
|
||||||
|
|
||||||
class Relay(callbacks.Privmsg):
|
class Relay(callbacks.Plugin):
|
||||||
noIgnore = True
|
noIgnore = True
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Relay, self)
|
self.__parent = super(Relay, self)
|
||||||
|
@ -31,7 +31,7 @@ from supybot.commands import *
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
class Reply(callbacks.Privmsg):
|
class Reply(callbacks.Plugin):
|
||||||
"""This plugins contains a few commands that construct various types of
|
"""This plugins contains a few commands that construct various types of
|
||||||
replies. Some bot owners would be wise to not load this plugin because it
|
replies. Some bot owners would be wise to not load this plugin because it
|
||||||
can be easily abused.
|
can be easily abused.
|
||||||
|
@ -35,7 +35,7 @@ from supybot.commands import *
|
|||||||
import supybot.schedule as schedule
|
import supybot.schedule as schedule
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Scheduler(callbacks.Privmsg):
|
class Scheduler(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Scheduler, self)
|
self.__parent = super(Scheduler, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -89,7 +89,7 @@ class SeenDB(plugins.ChannelUserDB):
|
|||||||
|
|
||||||
filename = conf.supybot.directories.data.dirize('Seen.db')
|
filename = conf.supybot.directories.data.dirize('Seen.db')
|
||||||
|
|
||||||
class Seen(callbacks.Privmsg):
|
class Seen(callbacks.Plugin):
|
||||||
noIgnore = True
|
noIgnore = True
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Seen, self)
|
self.__parent = super(Seen, self)
|
||||||
|
@ -39,7 +39,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.schedule as schedule
|
import supybot.schedule as schedule
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Services(callbacks.Privmsg):
|
class Services(callbacks.Plugin):
|
||||||
"""This plugin handles dealing with Services on networks that provide them.
|
"""This plugin handles dealing with Services on networks that provide them.
|
||||||
Basically, you should use the "password" command to tell the bot a nick to
|
Basically, you should use the "password" command to tell the bot a nick to
|
||||||
identify with and what password to use to identify with that nick. You can
|
identify with and what password to use to identify with that nick. You can
|
||||||
|
@ -66,7 +66,7 @@ class CdbShrunkenUrlDB(object):
|
|||||||
|
|
||||||
ShrunkenUrlDB = plugins.DB('ShrinkUrl', {'cdb': CdbShrunkenUrlDB})
|
ShrunkenUrlDB = plugins.DB('ShrinkUrl', {'cdb': CdbShrunkenUrlDB})
|
||||||
|
|
||||||
class ShrinkUrl(callbacks.PrivmsgCommandAndRegexp):
|
class ShrinkUrl(callbacks.PluginRegexp):
|
||||||
regexps = ['shrinkSnarfer']
|
regexps = ['shrinkSnarfer']
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(ShrinkUrl, self)
|
self.__parent = super(ShrinkUrl, self)
|
||||||
|
@ -38,7 +38,7 @@ import supybot.world as world
|
|||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Status(callbacks.Privmsg):
|
class Status(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Status, self)
|
self.__parent = super(Status, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
@ -52,7 +52,7 @@ class Status(callbacks.Privmsg):
|
|||||||
def __call__(self, irc, msg):
|
def __call__(self, irc, msg):
|
||||||
self.recvdMsgs += 1
|
self.recvdMsgs += 1
|
||||||
self.recvdBytes += len(msg)
|
self.recvdBytes += len(msg)
|
||||||
callbacks.Privmsg.__call__(self, irc, msg)
|
self.__parent.__call__(irc, msg)
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
self.sentMsgs += 1
|
self.sentMsgs += 1
|
||||||
@ -162,17 +162,17 @@ class Status(callbacks.Privmsg):
|
|||||||
Returns some interesting command-related statistics.
|
Returns some interesting command-related statistics.
|
||||||
"""
|
"""
|
||||||
commands = 0
|
commands = 0
|
||||||
callbacksPrivmsg = 0
|
callbacksPlugin = 0
|
||||||
for cb in irc.callbacks:
|
for cb in irc.callbacks:
|
||||||
if isinstance(cb, callbacks.Privmsg) and cb.public:
|
if isinstance(cb, callbacks.Plugin) and cb.public:
|
||||||
callbacksPrivmsg += 1
|
callbacksPlugin += 1
|
||||||
for attr in dir(cb):
|
for attr in dir(cb):
|
||||||
if cb.isCommand(attr) and \
|
if cb.isCommand(attr) and \
|
||||||
attr == callbacks.canonicalName(attr):
|
attr == callbacks.canonicalName(attr):
|
||||||
commands += 1
|
commands += 1
|
||||||
s = format('I offer a total of %n in %n. I have processed %n.',
|
s = format('I offer a total of %n in %n. I have processed %n.',
|
||||||
(commands, 'command'),
|
(commands, 'command'),
|
||||||
(callbacksPrivmsg, 'command-based', 'plugin'),
|
(callbacksPlugin, 'command-based', 'plugin'),
|
||||||
(world.commandsProcessed, 'command'))
|
(world.commandsProcessed, 'command'))
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
cmd = wrap(cmd)
|
cmd = wrap(cmd)
|
||||||
@ -184,7 +184,7 @@ class Status(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
commands = set()
|
commands = set()
|
||||||
for cb in irc.callbacks:
|
for cb in irc.callbacks:
|
||||||
if isinstance(cb, callbacks.Privmsg) and cb.public:
|
if isinstance(cb, callbacks.Plugin) and cb.public:
|
||||||
for attr in dir(cb):
|
for attr in dir(cb):
|
||||||
if cb.isCommand(attr) and \
|
if cb.isCommand(attr) and \
|
||||||
attr == callbacks.canonicalName(attr):
|
attr == callbacks.canonicalName(attr):
|
||||||
|
@ -38,7 +38,7 @@ import supybot.ircutils as ircutils
|
|||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
|
|
||||||
class String(callbacks.Privmsg):
|
class String(callbacks.Plugin):
|
||||||
def ord(self, irc, msg, args, letter):
|
def ord(self, irc, msg, args, letter):
|
||||||
"""<letter>
|
"""<letter>
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ def parse(s):
|
|||||||
i = f(i)
|
i = f(i)
|
||||||
return i
|
return i
|
||||||
|
|
||||||
class Time(callbacks.Privmsg):
|
class Time(callbacks.Plugin):
|
||||||
def seconds(self, irc, msg, args):
|
def seconds(self, irc, msg, args):
|
||||||
"""[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s]
|
"""[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s]
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ addConverter('canChangeTopic', canChangeTopic)
|
|||||||
def splitTopic(topic, separator):
|
def splitTopic(topic, separator):
|
||||||
return filter(None, topic.split(separator))
|
return filter(None, topic.split(separator))
|
||||||
|
|
||||||
class Topic(callbacks.Privmsg):
|
class Topic(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(Topic, self)
|
self.__parent = super(Topic, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -58,7 +58,7 @@ class DbiUrlDB(plugins.DbiChannelDB):
|
|||||||
|
|
||||||
URLDB = plugins.DB('URL', {'flat': DbiUrlDB})
|
URLDB = plugins.DB('URL', {'flat': DbiUrlDB})
|
||||||
|
|
||||||
class URL(callbacks.Privmsg):
|
class URL(callbacks.Plugin):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(URL, self)
|
self.__parent = super(URL, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
|
@ -37,7 +37,7 @@ from supybot.commands import *
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class User(callbacks.Privmsg):
|
class User(callbacks.Plugin):
|
||||||
def _checkNotChannel(self, irc, msg, password=' '):
|
def _checkNotChannel(self, irc, msg, password=' '):
|
||||||
if password and irc.isChannel(msg.args[0]):
|
if password and irc.isChannel(msg.args[0]):
|
||||||
raise callbacks.Error, conf.supybot.replies.requiresPrivacy()
|
raise callbacks.Error, conf.supybot.replies.requiresPrivacy()
|
||||||
|
@ -34,7 +34,7 @@ from supybot.commands import *
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Utilities(callbacks.Privmsg):
|
class Utilities(callbacks.Plugin):
|
||||||
# Yes, I really do mean "requires no arguments" below. "takes no
|
# Yes, I really do mean "requires no arguments" below. "takes no
|
||||||
# arguments" would probably lead people to think it was a useless command.
|
# arguments" would probably lead people to think it was a useless command.
|
||||||
def ignore(self, irc, msg, args):
|
def ignore(self, irc, msg, args):
|
||||||
|
@ -45,7 +45,7 @@ noLocationError = 'No such location could be found.'
|
|||||||
class NoLocation(callbacks.Error):
|
class NoLocation(callbacks.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class Weather(callbacks.Privmsg):
|
class Weather(callbacks.Plugin):
|
||||||
weatherCommands = ['wunder', 'cnn', 'ham']
|
weatherCommands = ['wunder', 'cnn', 'ham']
|
||||||
threaded = True
|
threaded = True
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
|
@ -36,7 +36,7 @@ import supybot.plugins as plugins
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class Web(callbacks.PrivmsgCommandAndRegexp):
|
class Web(callbacks.PluginRegexp):
|
||||||
"""Add the help for "@help Web" here."""
|
"""Add the help for "@help Web" here."""
|
||||||
regexps = ['titleSnarfer']
|
regexps = ['titleSnarfer']
|
||||||
threaded = True
|
threaded = True
|
||||||
|
@ -993,8 +993,7 @@ class DisabledCommands(object):
|
|||||||
if self.d[command] is not None:
|
if self.d[command] is not None:
|
||||||
self.d[command].remove(plugin)
|
self.d[command].remove(plugin)
|
||||||
|
|
||||||
class Privmsg(irclib.IrcCallback):
|
class Plugin(irclib.IrcCallback):
|
||||||
"""Base class for all Privmsg handlers."""
|
|
||||||
# For awhile, a comment stood here to say, "Eventually callCommand." But
|
# For awhile, a comment stood here to say, "Eventually callCommand." But
|
||||||
# that's wrong, because we can't do generic error handling in this
|
# that's wrong, because we can't do generic error handling in this
|
||||||
# callCommand -- plugins need to be able to override callCommand and do
|
# callCommand -- plugins need to be able to override callCommand and do
|
||||||
@ -1243,8 +1242,9 @@ class SimpleProxy(RichReplyMethods):
|
|||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return getattr(self.irc, attr)
|
return getattr(self.irc, attr)
|
||||||
|
|
||||||
|
Privmsg = Plugin # Backwards compatibility.
|
||||||
|
|
||||||
class PrivmsgCommandAndRegexp(Privmsg):
|
class PluginRegexp(Plugin):
|
||||||
"""Same as Privmsg, except allows the user to also include regexp-based
|
"""Same as Privmsg, except allows the user to also include regexp-based
|
||||||
callbacks. All regexp-based callbacks must be specified in a set
|
callbacks. All regexp-based callbacks must be specified in a set
|
||||||
(or list) attribute "regexps".
|
(or list) attribute "regexps".
|
||||||
@ -1311,5 +1311,7 @@ class PrivmsgCommandAndRegexp(Privmsg):
|
|||||||
proxy = self.Proxy(irc, msg)
|
proxy = self.Proxy(irc, msg)
|
||||||
self.callCommand(name, proxy, msg, m, catchErrors=True)
|
self.callCommand(name, proxy, msg, m, catchErrors=True)
|
||||||
|
|
||||||
|
PrivmsgCommandAndRegexp = PluginRegexp
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -359,22 +359,22 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
conf.supybot.reply.error.inPrivate.set(original)
|
conf.supybot.reply.error.inPrivate.set(original)
|
||||||
|
|
||||||
# Now for stuff not based on the plugins.
|
# Now for stuff not based on the plugins.
|
||||||
class First(callbacks.Privmsg):
|
class First(callbacks.Plugin):
|
||||||
def firstcmd(self, irc, msg, args):
|
def firstcmd(self, irc, msg, args):
|
||||||
"""First"""
|
"""First"""
|
||||||
irc.reply('foo')
|
irc.reply('foo')
|
||||||
|
|
||||||
class Second(callbacks.Privmsg):
|
class Second(callbacks.Plugin):
|
||||||
def secondcmd(self, irc, msg, args):
|
def secondcmd(self, irc, msg, args):
|
||||||
"""Second"""
|
"""Second"""
|
||||||
irc.reply('bar')
|
irc.reply('bar')
|
||||||
|
|
||||||
class FirstRepeat(callbacks.Privmsg):
|
class FirstRepeat(callbacks.Plugin):
|
||||||
def firstcmd(self, irc, msg, args):
|
def firstcmd(self, irc, msg, args):
|
||||||
"""FirstRepeat"""
|
"""FirstRepeat"""
|
||||||
irc.reply('baz')
|
irc.reply('baz')
|
||||||
|
|
||||||
class Third(callbacks.Privmsg):
|
class Third(callbacks.Plugin):
|
||||||
def third(self, irc, msg, args):
|
def third(self, irc, msg, args):
|
||||||
"""Third"""
|
"""Third"""
|
||||||
irc.reply(' '.join(args))
|
irc.reply(' '.join(args))
|
||||||
@ -420,7 +420,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
self.assertRegexp('help first firstcmd', 'First', 0) # no re.I flag.
|
self.assertRegexp('help first firstcmd', 'First', 0) # no re.I flag.
|
||||||
self.assertRegexp('help firstrepeat firstcmd', 'FirstRepeat', 0)
|
self.assertRegexp('help firstrepeat firstcmd', 'FirstRepeat', 0)
|
||||||
|
|
||||||
class TwoRepliesFirstAction(callbacks.Privmsg):
|
class TwoRepliesFirstAction(callbacks.Plugin):
|
||||||
def testactionreply(self, irc, msg, args):
|
def testactionreply(self, irc, msg, args):
|
||||||
irc.reply('foo', action=True)
|
irc.reply('foo', action=True)
|
||||||
irc.reply('bar') # We're going to check that this isn't an action.
|
irc.reply('bar') # We're going to check that this isn't an action.
|
||||||
@ -457,7 +457,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
def testNoEscapingAttributeErrorFromTokenizeWithFirstElementList(self):
|
def testNoEscapingAttributeErrorFromTokenizeWithFirstElementList(self):
|
||||||
self.assertError('[plugin list] list')
|
self.assertError('[plugin list] list')
|
||||||
|
|
||||||
class InvalidCommand(callbacks.Privmsg):
|
class InvalidCommand(callbacks.Plugin):
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
irc.reply('foo')
|
irc.reply('foo')
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
finally:
|
finally:
|
||||||
conf.supybot.reply.whenNotCommand.set(original)
|
conf.supybot.reply.whenNotCommand.set(original)
|
||||||
|
|
||||||
class BadInvalidCommand(callbacks.Privmsg):
|
class BadInvalidCommand(callbacks.Plugin):
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
s = 'This shouldn\'t keep Misc.invalidCommand from being called'
|
s = 'This shouldn\'t keep Misc.invalidCommand from being called'
|
||||||
raise Exception, s
|
raise Exception, s
|
||||||
@ -487,9 +487,9 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
conf.supybot.reply.whenNotCommand.set(original)
|
conf.supybot.reply.whenNotCommand.set(original)
|
||||||
|
|
||||||
|
|
||||||
class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
class PluginRegexpTestCase(PluginTestCase):
|
||||||
plugins = ()
|
plugins = ()
|
||||||
class PCAR(callbacks.PrivmsgCommandAndRegexp):
|
class PCAR(callbacks.PluginRegexp):
|
||||||
def test(self, irc, msg, args):
|
def test(self, irc, msg, args):
|
||||||
"<foo>"
|
"<foo>"
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
@ -499,7 +499,7 @@ class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
|||||||
|
|
||||||
class RichReplyMethodsTestCase(PluginTestCase):
|
class RichReplyMethodsTestCase(PluginTestCase):
|
||||||
plugins = ()
|
plugins = ()
|
||||||
class NoCapability(callbacks.Privmsg):
|
class NoCapability(callbacks.Plugin):
|
||||||
def error(self, irc, msg, args):
|
def error(self, irc, msg, args):
|
||||||
irc.errorNoCapability('admin')
|
irc.errorNoCapability('admin')
|
||||||
def testErrorNoCapability(self):
|
def testErrorNoCapability(self):
|
||||||
@ -509,7 +509,7 @@ class RichReplyMethodsTestCase(PluginTestCase):
|
|||||||
|
|
||||||
class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||||
plugins = ('Utilities',)
|
plugins = ('Utilities',)
|
||||||
class WithPrivateNotice(callbacks.Privmsg):
|
class WithPrivateNotice(callbacks.Plugin):
|
||||||
def normal(self, irc, msg, args):
|
def normal(self, irc, msg, args):
|
||||||
irc.reply('should be with private notice')
|
irc.reply('should be with private notice')
|
||||||
def explicit(self, irc, msg, args):
|
def explicit(self, irc, msg, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user