From b0cb616709a8ef360ea7728b6a52331fb7672ab2 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 9 Feb 2005 07:04:04 +0000 Subject: [PATCH] Changed callbacks.Privmsg to be callbacks.Plugin, and callbacks.PrivmsgCommandAndRegexp to be callbacks.Plugin. --- plugins/Admin/plugin.py | 2 +- plugins/Alias/plugin.py | 2 +- plugins/Anonymous/plugin.py | 2 +- plugins/AutoMode/plugin.py | 2 +- plugins/Babelfish/plugin.py | 2 +- plugins/Channel/plugin.py | 2 +- plugins/ChannelLogger/plugin.py | 2 +- plugins/ChannelStats/plugin.py | 4 ++-- plugins/Config/plugin.py | 2 +- plugins/Ctcp/plugin.py | 2 +- plugins/Dict/plugin.py | 2 +- plugins/Filter/plugin.py | 2 +- plugins/Filter/test.py | 2 +- plugins/Format/plugin.py | 2 +- plugins/Games/plugin.py | 2 +- plugins/Google/plugin.py | 2 +- plugins/Herald/plugin.py | 2 +- plugins/Internet/plugin.py | 2 +- plugins/Karma/plugin.py | 2 +- plugins/Later/plugin.py | 2 +- plugins/Math/plugin.py | 2 +- plugins/Misc/plugin.py | 4 ++-- plugins/Network/plugin.py | 2 +- plugins/NickCapture/plugin.py | 4 ++-- plugins/Nickometer/plugin.py | 2 +- plugins/Note/plugin.py | 2 +- plugins/Owner/plugin.py | 2 +- plugins/Protector/plugin.py | 2 +- plugins/QuoteGrabs/plugin.py | 2 +- plugins/RSS/plugin.py | 2 +- plugins/Relay/plugin.py | 2 +- plugins/Reply/plugin.py | 2 +- plugins/Scheduler/plugin.py | 2 +- plugins/Seen/plugin.py | 2 +- plugins/Services/plugin.py | 2 +- plugins/ShrinkUrl/plugin.py | 2 +- plugins/Status/plugin.py | 14 +++++++------- plugins/String/plugin.py | 2 +- plugins/Time/plugin.py | 2 +- plugins/Topic/plugin.py | 2 +- plugins/URL/plugin.py | 2 +- plugins/User/plugin.py | 2 +- plugins/Utilities/plugin.py | 2 +- plugins/Weather/plugin.py | 2 +- plugins/Web/plugin.py | 2 +- src/callbacks.py | 8 +++++--- test/test_callbacks.py | 22 +++++++++++----------- 47 files changed, 70 insertions(+), 68 deletions(-) diff --git a/plugins/Admin/plugin.py b/plugins/Admin/plugin.py index 5d9d22467..a104b6ce5 100644 --- a/plugins/Admin/plugin.py +++ b/plugins/Admin/plugin.py @@ -39,7 +39,7 @@ import supybot.ircutils as ircutils import supybot.schedule as schedule import supybot.callbacks as callbacks -class Admin(callbacks.Privmsg): +class Admin(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Admin, self) self.__parent.__init__(irc) diff --git a/plugins/Alias/plugin.py b/plugins/Alias/plugin.py index 24b26de58..46c0eb723 100644 --- a/plugins/Alias/plugin.py +++ b/plugins/Alias/plugin.py @@ -162,7 +162,7 @@ def makeNewAlias(name, alias): f = utils.changeFunctionName(f, name, doc) return f -class Alias(callbacks.Privmsg): +class Alias(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Alias, self) self.__parent.__init__(irc) diff --git a/plugins/Anonymous/plugin.py b/plugins/Anonymous/plugin.py index ba6db380b..4910b653d 100644 --- a/plugins/Anonymous/plugin.py +++ b/plugins/Anonymous/plugin.py @@ -33,7 +33,7 @@ from supybot.commands import * import supybot.ircmsgs as ircmsgs 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' 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 diff --git a/plugins/AutoMode/plugin.py b/plugins/AutoMode/plugin.py index 195f53144..4af639350 100644 --- a/plugins/AutoMode/plugin.py +++ b/plugins/AutoMode/plugin.py @@ -38,7 +38,7 @@ import supybot.callbacks as callbacks class Continue(Exception): pass # Used below, look in the "do" function nested in doJoin. -class AutoMode(callbacks.Privmsg): +class AutoMode(callbacks.Plugin): def doJoin(self, irc, msg): channel = msg.args[0] if ircutils.strEqual(irc.nick, msg.nick): diff --git a/plugins/Babelfish/plugin.py b/plugins/Babelfish/plugin.py index 911ecbdd1..ce4bc07ea 100644 --- a/plugins/Babelfish/plugin.py +++ b/plugins/Babelfish/plugin.py @@ -34,7 +34,7 @@ import supybot.utils as utils from supybot.commands import * import supybot.callbacks as callbacks -class Babelfish(callbacks.Privmsg): +class Babelfish(callbacks.Plugin): threaded = True _abbrevs = utils.gen.abbrev(map(str.lower, babelfish.available_languages)) _abbrevs['de'] = 'german' diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index 4ca45ff2f..cafef94ad 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -38,7 +38,7 @@ import supybot.schedule as schedule import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class Channel(callbacks.Privmsg): +class Channel(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Channel, self) self.__parent.__init__(irc) diff --git a/plugins/ChannelLogger/plugin.py b/plugins/ChannelLogger/plugin.py index 0693e81dd..ee9277a18 100644 --- a/plugins/ChannelLogger/plugin.py +++ b/plugins/ChannelLogger/plugin.py @@ -47,7 +47,7 @@ class FakeLog(object): def write(self, s): return -class ChannelLogger(callbacks.Privmsg): +class ChannelLogger(callbacks.Plugin): noIgnore = True def __init__(self, irc): self.__parent = super(ChannelLogger, self) diff --git a/plugins/ChannelStats/plugin.py b/plugins/ChannelStats/plugin.py index 278c813a4..19ed184dd 100644 --- a/plugins/ChannelStats/plugin.py +++ b/plugins/ChannelStats/plugin.py @@ -149,7 +149,7 @@ class StatsDB(plugins.ChannelUserDB): return self[channel, id] filename = conf.supybot.directories.data.dirize('ChannelStats.db') -class ChannelStats(callbacks.Privmsg): +class ChannelStats(callbacks.Plugin): noIgnore = True def __init__(self, irc): self.__parent = super(ChannelStats, self) @@ -164,7 +164,7 @@ class ChannelStats(callbacks.Privmsg): def die(self): world.flushers.remove(self._flush) self.db.close() - callbacks.Privmsg.die(self) + self.__parent.die() def __call__(self, irc, msg): try: diff --git a/plugins/Config/plugin.py b/plugins/Config/plugin.py index d08ada03a..b23dd54ae 100644 --- a/plugins/Config/plugin.py +++ b/plugins/Config/plugin.py @@ -99,7 +99,7 @@ def getConfigVar(irc, msg, args, state): irc.errorInvalid('configuration variable', str(e)) addConverter('configVar', getConfigVar) -class Config(callbacks.Privmsg): +class Config(callbacks.Plugin): def callCommand(self, name, irc, msg, *L, **kwargs): try: super(Config, self).callCommand(name, irc, msg, *L, **kwargs) diff --git a/plugins/Ctcp/plugin.py b/plugins/Ctcp/plugin.py index 496c41bbe..31d6729e7 100644 --- a/plugins/Ctcp/plugin.py +++ b/plugins/Ctcp/plugin.py @@ -37,7 +37,7 @@ import supybot.ircutils as ircutils import supybot.schedule as schedule import supybot.callbacks as callbacks -class Ctcp(callbacks.PrivmsgCommandAndRegexp): +class Ctcp(callbacks.PluginRegexp): public = False regexps = ('ctcpPing', 'ctcpVersion', 'ctcpUserinfo', 'ctcpTime', 'ctcpFinger', 'ctcpSource') diff --git a/plugins/Dict/plugin.py b/plugins/Dict/plugin.py index b777c5fcd..b26166d6d 100644 --- a/plugins/Dict/plugin.py +++ b/plugins/Dict/plugin.py @@ -37,7 +37,7 @@ from supybot.commands import * import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class Dict(callbacks.Privmsg): +class Dict(callbacks.Plugin): threaded = True def dictionaries(self, irc, msg, args): """takes no arguments diff --git a/plugins/Filter/plugin.py b/plugins/Filter/plugin.py index eb9ddb033..47af3f0a8 100644 --- a/plugins/Filter/plugin.py +++ b/plugins/Filter/plugin.py @@ -43,7 +43,7 @@ class MyFilterProxy(object): def reply(self, s): self.s = s -class Filter(callbacks.Privmsg): +class Filter(callbacks.Plugin): """This plugin offers several commands which transform text in some way. 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 diff --git a/plugins/Filter/test.py b/plugins/Filter/test.py index a0bc02ccf..312b9c5c4 100644 --- a/plugins/Filter/test.py +++ b/plugins/Filter/test.py @@ -53,7 +53,7 @@ class FilterTest(ChannelPluginTestCase): self.assertNotError('outfilter rot13') finally: try: - callbacks.Privmsg._disabled.remove('rot13') + callbacks.Plugin._disabled.remove('rot13') except KeyError: pass diff --git a/plugins/Format/plugin.py b/plugins/Format/plugin.py index 433a1bf47..a1da45d9b 100644 --- a/plugins/Format/plugin.py +++ b/plugins/Format/plugin.py @@ -43,7 +43,7 @@ def configure(advanced): from supybot.questions import expect, anything, something, yn conf.registerPlugin('Format', True) -class Format(callbacks.Privmsg): +class Format(callbacks.Plugin): def bold(self, irc, msg, args, text): """ diff --git a/plugins/Games/plugin.py b/plugins/Games/plugin.py index a5f35c156..2fa78605e 100644 --- a/plugins/Games/plugin.py +++ b/plugins/Games/plugin.py @@ -37,7 +37,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class Games(callbacks.Privmsg): +class Games(callbacks.Plugin): def coin(self, irc, msg, args): """takes no arguments diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index c7c265673..9a98a3110 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -99,7 +99,7 @@ last24hours = structures.TimeoutQueue(86400) totalTime = conf.supybot.plugins.Google.state.time() searches = conf.supybot.plugins.Google.state.searches() -class Google(callbacks.PrivmsgCommandAndRegexp): +class Google(callbacks.PluginRegexp): threaded = True callBefore = ['URL'] regexps = ['googleSnarfer', 'googleGroups'] diff --git a/plugins/Herald/plugin.py b/plugins/Herald/plugin.py index 30bd109f0..f0723f006 100644 --- a/plugins/Herald/plugin.py +++ b/plugins/Herald/plugin.py @@ -52,7 +52,7 @@ class HeraldDB(plugins.ChannelUserDB): raise ValueError return L[0] -class Herald(callbacks.Privmsg): +class Herald(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Herald, self) self.__parent.__init__(irc) diff --git a/plugins/Internet/plugin.py b/plugins/Internet/plugin.py index 9fe0f5db2..047a682a8 100644 --- a/plugins/Internet/plugin.py +++ b/plugins/Internet/plugin.py @@ -36,7 +36,7 @@ from supybot.utils.iter import any import supybot.callbacks as callbacks -class Internet(callbacks.Privmsg): +class Internet(callbacks.Plugin): """Add the help for "@help Internet" here.""" threaded = True def dns(self, irc, msg, args, host): diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index bf90c5242..18bd196e3 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -208,7 +208,7 @@ class SqliteKarmaDB(object): KarmaDB = plugins.DB('Karma', {'sqlite': SqliteKarmaDB}) -class Karma(callbacks.Privmsg): +class Karma(callbacks.Plugin): callBefore = ('Factoids', 'MoobotFactoids', 'Infobot') def __init__(self, irc): self.__parent = super(Karma, self) diff --git a/plugins/Later/plugin.py b/plugins/Later/plugin.py index 44408c81c..f9dce22f5 100644 --- a/plugins/Later/plugin.py +++ b/plugins/Later/plugin.py @@ -38,7 +38,7 @@ import supybot.ircutils as ircutils 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 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 diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index 2c5ddeff4..ef932dc73 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -43,7 +43,7 @@ import convertcore baseArg = ('int', 'base', lambda i: i <= 36) -class Math(callbacks.Privmsg): +class Math(callbacks.Plugin): def base(self, irc, msg, args, frm, to, number): """ [] diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 776f6190e..89da0acc6 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -42,7 +42,7 @@ import supybot.callbacks as callbacks from supybot.utils.iter import ifilter -class Misc(callbacks.Privmsg): +class Misc(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Misc, self) self.__parent.__init__(irc) @@ -143,7 +143,7 @@ class Misc(callbacks.Privmsg): commands = {} L = [] for cb in irc.callbacks: - if isinstance(cb, callbacks.Privmsg): + if isinstance(cb, callbacks.Plugin): for attr in dir(cb): if s in attr and cb.isCommand(attr): if attr == callbacks.canonicalName(attr): diff --git a/plugins/Network/plugin.py b/plugins/Network/plugin.py index 4bd566507..2879a4e5c 100644 --- a/plugins/Network/plugin.py +++ b/plugins/Network/plugin.py @@ -38,7 +38,7 @@ import supybot.ircutils as ircutils import supybot.registry as registry import supybot.callbacks as callbacks -class Network(callbacks.Privmsg): +class Network(callbacks.Plugin): _whois = {} _latency = {} def _getIrc(self, network): diff --git a/plugins/NickCapture/plugin.py b/plugins/NickCapture/plugin.py index 0de2798ef..53dabc587 100644 --- a/plugins/NickCapture/plugin.py +++ b/plugins/NickCapture/plugin.py @@ -34,7 +34,7 @@ import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class NickCapture(callbacks.Privmsg): +class NickCapture(callbacks.Plugin): """This module constantly tries to take whatever nick is configured as supybot.nick. Just make sure that's set appropriately, and thus plugin will do the rest.""" @@ -55,7 +55,7 @@ class NickCapture(callbacks.Privmsg): # except on reconnects, which can cause trouble. # if nick not in irc.state.nicksToHostmasks: self._ison(irc, nick) - callbacks.Privmsg.__call__(self, irc, msg) + self.__parent.__call__(irc, msg) def _ison(self, irc, nick): if self.registryValue('ison'): diff --git a/plugins/Nickometer/plugin.py b/plugins/Nickometer/plugin.py index 3d627e192..03a2a454b 100644 --- a/plugins/Nickometer/plugin.py +++ b/plugins/Nickometer/plugin.py @@ -72,7 +72,7 @@ def numberShifts(s): s=re.sub('[0-9]+', 'n', s) return len(s)-1 -class Nickometer(callbacks.Privmsg): +class Nickometer(callbacks.Plugin): def punish(self, damage, reason): self.log.debug('%s lameness points awarded: %s' % (damage, reason)) return damage diff --git a/plugins/Note/plugin.py b/plugins/Note/plugin.py index c6525a14f..14077798d 100644 --- a/plugins/Note/plugin.py +++ b/plugins/Note/plugin.py @@ -124,7 +124,7 @@ class DbiNoteDB(dbi.DB): NoteDB = plugins.DB('Note', {'flat': DbiNoteDB}) -class Note(callbacks.Privmsg): +class Note(callbacks.Plugin): def __init__(self, irc): self.__parent= super(Note, self) self.__parent.__init__(irc) diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index 8fb0bbaf5..0629a5e76 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -119,7 +119,7 @@ class LogProxy(object): 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 # things will happen when adding callbacks. def __init__(self, irc=None): diff --git a/plugins/Protector/plugin.py b/plugins/Protector/plugin.py index f94e3b817..2e82f124f 100644 --- a/plugins/Protector/plugin.py +++ b/plugins/Protector/plugin.py @@ -33,7 +33,7 @@ import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class Protector(callbacks.Privmsg): +class Protector(callbacks.Plugin): def isImmune(self, irc, msg): if not ircutils.isUserHostmask(msg.prefix): self.log.debug('%q is immune, it\'s a server.', msg) diff --git a/plugins/QuoteGrabs/plugin.py b/plugins/QuoteGrabs/plugin.py index 4dc371b08..b26f07f53 100644 --- a/plugins/QuoteGrabs/plugin.py +++ b/plugins/QuoteGrabs/plugin.py @@ -183,7 +183,7 @@ class SqliteQuoteGrabsDB(object): QuoteGrabsDB = plugins.DB('QuoteGrabs', {'sqlite': SqliteQuoteGrabsDB}) -class QuoteGrabs(callbacks.Privmsg): +class QuoteGrabs(callbacks.Plugin): """Add the help for "@help QuoteGrabs" here.""" def __init__(self, irc): self.__parent = super(QuoteGrabs, self) diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index c79cb39ec..04a0a4edf 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -49,7 +49,7 @@ def getFeedName(irc, msg, args, state): state.args.append(callbacks.canonicalName(args.pop(0))) addConverter('feedName', getFeedName) -class RSS(callbacks.Privmsg): +class RSS(callbacks.Plugin): """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 the "add" command to add feeds to this plugin, and use the "announce" diff --git a/plugins/Relay/plugin.py b/plugins/Relay/plugin.py index ff296e6ea..af0fcfbdf 100644 --- a/plugins/Relay/plugin.py +++ b/plugins/Relay/plugin.py @@ -39,7 +39,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks from supybot.structures import MultiSet, TimeoutQueue -class Relay(callbacks.Privmsg): +class Relay(callbacks.Plugin): noIgnore = True def __init__(self, irc): self.__parent = super(Relay, self) diff --git a/plugins/Reply/plugin.py b/plugins/Reply/plugin.py index 1759a5d74..7d1dd3799 100644 --- a/plugins/Reply/plugin.py +++ b/plugins/Reply/plugin.py @@ -31,7 +31,7 @@ from supybot.commands import * import supybot.callbacks as callbacks -class Reply(callbacks.Privmsg): +class Reply(callbacks.Plugin): """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 can be easily abused. diff --git a/plugins/Scheduler/plugin.py b/plugins/Scheduler/plugin.py index f48d077b9..1d6187b7f 100644 --- a/plugins/Scheduler/plugin.py +++ b/plugins/Scheduler/plugin.py @@ -35,7 +35,7 @@ from supybot.commands import * import supybot.schedule as schedule import supybot.callbacks as callbacks -class Scheduler(callbacks.Privmsg): +class Scheduler(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Scheduler, self) self.__parent.__init__(irc) diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index e911a5819..8ce098067 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -89,7 +89,7 @@ class SeenDB(plugins.ChannelUserDB): filename = conf.supybot.directories.data.dirize('Seen.db') -class Seen(callbacks.Privmsg): +class Seen(callbacks.Plugin): noIgnore = True def __init__(self, irc): self.__parent = super(Seen, self) diff --git a/plugins/Services/plugin.py b/plugins/Services/plugin.py index bd6a2c5e2..4ccb67970 100644 --- a/plugins/Services/plugin.py +++ b/plugins/Services/plugin.py @@ -39,7 +39,7 @@ import supybot.ircutils as ircutils import supybot.schedule as schedule import supybot.callbacks as callbacks -class Services(callbacks.Privmsg): +class Services(callbacks.Plugin): """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 identify with and what password to use to identify with that nick. You can diff --git a/plugins/ShrinkUrl/plugin.py b/plugins/ShrinkUrl/plugin.py index 74e9fb08c..908685785 100644 --- a/plugins/ShrinkUrl/plugin.py +++ b/plugins/ShrinkUrl/plugin.py @@ -66,7 +66,7 @@ class CdbShrunkenUrlDB(object): ShrunkenUrlDB = plugins.DB('ShrinkUrl', {'cdb': CdbShrunkenUrlDB}) -class ShrinkUrl(callbacks.PrivmsgCommandAndRegexp): +class ShrinkUrl(callbacks.PluginRegexp): regexps = ['shrinkSnarfer'] def __init__(self, irc): self.__parent = super(ShrinkUrl, self) diff --git a/plugins/Status/plugin.py b/plugins/Status/plugin.py index f6fc6f111..5e69bef9c 100644 --- a/plugins/Status/plugin.py +++ b/plugins/Status/plugin.py @@ -38,7 +38,7 @@ import supybot.world as world from supybot.commands import * import supybot.callbacks as callbacks -class Status(callbacks.Privmsg): +class Status(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Status, self) self.__parent.__init__(irc) @@ -52,7 +52,7 @@ class Status(callbacks.Privmsg): def __call__(self, irc, msg): self.recvdMsgs += 1 self.recvdBytes += len(msg) - callbacks.Privmsg.__call__(self, irc, msg) + self.__parent.__call__(irc, msg) def outFilter(self, irc, msg): self.sentMsgs += 1 @@ -162,17 +162,17 @@ class Status(callbacks.Privmsg): Returns some interesting command-related statistics. """ commands = 0 - callbacksPrivmsg = 0 + callbacksPlugin = 0 for cb in irc.callbacks: - if isinstance(cb, callbacks.Privmsg) and cb.public: - callbacksPrivmsg += 1 + if isinstance(cb, callbacks.Plugin) and cb.public: + callbacksPlugin += 1 for attr in dir(cb): if cb.isCommand(attr) and \ attr == callbacks.canonicalName(attr): commands += 1 s = format('I offer a total of %n in %n. I have processed %n.', (commands, 'command'), - (callbacksPrivmsg, 'command-based', 'plugin'), + (callbacksPlugin, 'command-based', 'plugin'), (world.commandsProcessed, 'command')) irc.reply(s) cmd = wrap(cmd) @@ -184,7 +184,7 @@ class Status(callbacks.Privmsg): """ commands = set() 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): if cb.isCommand(attr) and \ attr == callbacks.canonicalName(attr): diff --git a/plugins/String/plugin.py b/plugins/String/plugin.py index f8c65c943..a5931481d 100644 --- a/plugins/String/plugin.py +++ b/plugins/String/plugin.py @@ -38,7 +38,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class String(callbacks.Privmsg): +class String(callbacks.Plugin): def ord(self, irc, msg, args, letter): """ diff --git a/plugins/Time/plugin.py b/plugins/Time/plugin.py index 23f9d8dc2..431cb1ac7 100644 --- a/plugins/Time/plugin.py +++ b/plugins/Time/plugin.py @@ -52,7 +52,7 @@ def parse(s): i = f(i) return i -class Time(callbacks.Privmsg): +class Time(callbacks.Plugin): def seconds(self, irc, msg, args): """[y] [w] [d] [h] [m] [s] diff --git a/plugins/Topic/plugin.py b/plugins/Topic/plugin.py index 6276d2ef0..128022de7 100644 --- a/plugins/Topic/plugin.py +++ b/plugins/Topic/plugin.py @@ -94,7 +94,7 @@ addConverter('canChangeTopic', canChangeTopic) def splitTopic(topic, separator): return filter(None, topic.split(separator)) -class Topic(callbacks.Privmsg): +class Topic(callbacks.Plugin): def __init__(self, irc): self.__parent = super(Topic, self) self.__parent.__init__(irc) diff --git a/plugins/URL/plugin.py b/plugins/URL/plugin.py index 2e3231c35..805aa5191 100644 --- a/plugins/URL/plugin.py +++ b/plugins/URL/plugin.py @@ -58,7 +58,7 @@ class DbiUrlDB(plugins.DbiChannelDB): URLDB = plugins.DB('URL', {'flat': DbiUrlDB}) -class URL(callbacks.Privmsg): +class URL(callbacks.Plugin): def __init__(self, irc): self.__parent = super(URL, self) self.__parent.__init__(irc) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 2f03749ba..dd95f4bbe 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -37,7 +37,7 @@ from supybot.commands import * import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class User(callbacks.Privmsg): +class User(callbacks.Plugin): def _checkNotChannel(self, irc, msg, password=' '): if password and irc.isChannel(msg.args[0]): raise callbacks.Error, conf.supybot.replies.requiresPrivacy() diff --git a/plugins/Utilities/plugin.py b/plugins/Utilities/plugin.py index d2ef5be7e..783e1c149 100644 --- a/plugins/Utilities/plugin.py +++ b/plugins/Utilities/plugin.py @@ -34,7 +34,7 @@ from supybot.commands import * import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class Utilities(callbacks.Privmsg): +class Utilities(callbacks.Plugin): # Yes, I really do mean "requires no arguments" below. "takes no # arguments" would probably lead people to think it was a useless command. def ignore(self, irc, msg, args): diff --git a/plugins/Weather/plugin.py b/plugins/Weather/plugin.py index 2744bb6d0..e51c1df8d 100644 --- a/plugins/Weather/plugin.py +++ b/plugins/Weather/plugin.py @@ -45,7 +45,7 @@ noLocationError = 'No such location could be found.' class NoLocation(callbacks.Error): pass -class Weather(callbacks.Privmsg): +class Weather(callbacks.Plugin): weatherCommands = ['wunder', 'cnn', 'ham'] threaded = True def __init__(self, irc): diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index 2659ad7a9..b6b3531c5 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -36,7 +36,7 @@ import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks -class Web(callbacks.PrivmsgCommandAndRegexp): +class Web(callbacks.PluginRegexp): """Add the help for "@help Web" here.""" regexps = ['titleSnarfer'] threaded = True diff --git a/src/callbacks.py b/src/callbacks.py index b5ede03cb..5b425b728 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -993,8 +993,7 @@ class DisabledCommands(object): if self.d[command] is not None: self.d[command].remove(plugin) -class Privmsg(irclib.IrcCallback): - """Base class for all Privmsg handlers.""" +class Plugin(irclib.IrcCallback): # For awhile, a comment stood here to say, "Eventually callCommand." But # that's wrong, because we can't do generic error handling in this # callCommand -- plugins need to be able to override callCommand and do @@ -1243,8 +1242,9 @@ class SimpleProxy(RichReplyMethods): def __getattr__(self, 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 callbacks. All regexp-based callbacks must be specified in a set (or list) attribute "regexps". @@ -1311,5 +1311,7 @@ class PrivmsgCommandAndRegexp(Privmsg): proxy = self.Proxy(irc, msg) self.callCommand(name, proxy, msg, m, catchErrors=True) +PrivmsgCommandAndRegexp = PluginRegexp + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 6bb545840..869bbe604 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -359,22 +359,22 @@ class PrivmsgTestCase(ChannelPluginTestCase): conf.supybot.reply.error.inPrivate.set(original) # Now for stuff not based on the plugins. - class First(callbacks.Privmsg): + class First(callbacks.Plugin): def firstcmd(self, irc, msg, args): """First""" irc.reply('foo') - class Second(callbacks.Privmsg): + class Second(callbacks.Plugin): def secondcmd(self, irc, msg, args): """Second""" irc.reply('bar') - class FirstRepeat(callbacks.Privmsg): + class FirstRepeat(callbacks.Plugin): def firstcmd(self, irc, msg, args): """FirstRepeat""" irc.reply('baz') - class Third(callbacks.Privmsg): + class Third(callbacks.Plugin): def third(self, irc, msg, args): """Third""" 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 firstrepeat firstcmd', 'FirstRepeat', 0) - class TwoRepliesFirstAction(callbacks.Privmsg): + class TwoRepliesFirstAction(callbacks.Plugin): def testactionreply(self, irc, msg, args): irc.reply('foo', action=True) irc.reply('bar') # We're going to check that this isn't an action. @@ -457,7 +457,7 @@ class PrivmsgTestCase(ChannelPluginTestCase): def testNoEscapingAttributeErrorFromTokenizeWithFirstElementList(self): self.assertError('[plugin list] list') - class InvalidCommand(callbacks.Privmsg): + class InvalidCommand(callbacks.Plugin): def invalidCommand(self, irc, msg, tokens): irc.reply('foo') @@ -472,7 +472,7 @@ class PrivmsgTestCase(ChannelPluginTestCase): finally: conf.supybot.reply.whenNotCommand.set(original) - class BadInvalidCommand(callbacks.Privmsg): + class BadInvalidCommand(callbacks.Plugin): def invalidCommand(self, irc, msg, tokens): s = 'This shouldn\'t keep Misc.invalidCommand from being called' raise Exception, s @@ -487,9 +487,9 @@ class PrivmsgTestCase(ChannelPluginTestCase): conf.supybot.reply.whenNotCommand.set(original) -class PrivmsgCommandAndRegexpTestCase(PluginTestCase): +class PluginRegexpTestCase(PluginTestCase): plugins = () - class PCAR(callbacks.PrivmsgCommandAndRegexp): + class PCAR(callbacks.PluginRegexp): def test(self, irc, msg, args): "" raise callbacks.ArgumentError @@ -499,7 +499,7 @@ class PrivmsgCommandAndRegexpTestCase(PluginTestCase): class RichReplyMethodsTestCase(PluginTestCase): plugins = () - class NoCapability(callbacks.Privmsg): + class NoCapability(callbacks.Plugin): def error(self, irc, msg, args): irc.errorNoCapability('admin') def testErrorNoCapability(self): @@ -509,7 +509,7 @@ class RichReplyMethodsTestCase(PluginTestCase): class WithPrivateNoticeTestCase(ChannelPluginTestCase): plugins = ('Utilities',) - class WithPrivateNotice(callbacks.Privmsg): + class WithPrivateNotice(callbacks.Plugin): def normal(self, irc, msg, args): irc.reply('should be with private notice') def explicit(self, irc, msg, args):