diff --git a/ChangeLog b/ChangeLog index b4573f130..326b704dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ + * Added conf.supybot.plugins.Herald.defaultHerald, which provides + a default herald to use for unregistered users. Herald.default was + also added as a friendly interface to managing the defaultHerald. + * Added Weather.wunder, which uses wunderground.com to report the current weather status. diff --git a/plugins/Herald.py b/plugins/Herald.py index cbd4d4b83..6c2e561ca 100644 --- a/plugins/Herald.py +++ b/plugins/Herald.py @@ -38,6 +38,7 @@ __revision__ = "$Id$" import os import time +import getopt import log import conf @@ -70,6 +71,10 @@ conf.registerChannelValue(conf.supybot.plugins.Herald, 'heralding', conf.registerChannelValue(conf.supybot.plugins.Herald, 'throttleTime', registry.PositiveInteger(600, """Determines the minimum number of seconds between heralds.""")) +conf.registerChannelValue(conf.supybot.plugins.Herald, 'defaultHerald', + registry.String('', """Sets the default herald to use. If a user has a + personal herald specified, that will be used instead. If set to the empty + string, the default herald will be disabled.""")) conf.registerChannelValue(conf.supybot.plugins.Herald, 'throttleTimeAfterPart', registry.PositiveInteger(60, """Determines the minimum number of seconds after parting that the bot will not herald the person when he or she @@ -96,6 +101,9 @@ class Herald(callbacks.Privmsg): id = ircdb.users.getUserId(msg.prefix) herald = self.db[channel, id] except KeyError: + default = self.registryValue('defaultHerald', channel) + if default: + irc.queueMsg(ircmsgs.privmsg(msg.nick, default)) return now = time.time() throttle = self.registryValue('throttleTime', channel) @@ -126,6 +134,35 @@ class Herald(callbacks.Privmsg): raise KeyError return id + def default(self, irc, msg, args): + """[] [--remove|] + + If is given, sets the default herald to . A of "" + will remove the default herald. If is not given, returns the + current default herald. is only necessary if the message + isn't sent in the channel itself. + """ + channel = privmsgs.getChannel(msg, args) + (optlist, rest) = getopt.getopt(args, '', ['remove']) + if optlist and rest: + raise callbacks.ArgumentError + for (option, _) in optlist: + if option == '--remove': + conf.supybot.plugins.Herald.defaultHerald.set("") + irc.replySuccess() + return + msg = privmsgs.getArgs(rest, required=0, optional=1) + if not msg: + resp = self.registryValue('defaultHerald', channel) + if not resp: + irc.reply('I do not have a default herald set.') + return + else: + irc.reply(resp) + return + conf.supybot.plugins.Herald.defaultHerald.set(msg) + irc.replySuccess() + def get(self, irc, msg, args): """[]