Herald.default & conf.supybot.plugins.Herald.defaultHerald

This commit is contained in:
James Vega 2004-06-18 18:32:05 +00:00
parent 6f336f297e
commit b9598abfb8
2 changed files with 41 additions and 0 deletions

View File

@ -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 * Added Weather.wunder, which uses wunderground.com to report the
current weather status. current weather status.

View File

@ -38,6 +38,7 @@ __revision__ = "$Id$"
import os import os
import time import time
import getopt
import log import log
import conf import conf
@ -70,6 +71,10 @@ conf.registerChannelValue(conf.supybot.plugins.Herald, 'heralding',
conf.registerChannelValue(conf.supybot.plugins.Herald, 'throttleTime', conf.registerChannelValue(conf.supybot.plugins.Herald, 'throttleTime',
registry.PositiveInteger(600, """Determines the minimum number of seconds registry.PositiveInteger(600, """Determines the minimum number of seconds
between heralds.""")) 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', conf.registerChannelValue(conf.supybot.plugins.Herald, 'throttleTimeAfterPart',
registry.PositiveInteger(60, """Determines the minimum number of seconds registry.PositiveInteger(60, """Determines the minimum number of seconds
after parting that the bot will not herald the person when he or she 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) id = ircdb.users.getUserId(msg.prefix)
herald = self.db[channel, id] herald = self.db[channel, id]
except KeyError: except KeyError:
default = self.registryValue('defaultHerald', channel)
if default:
irc.queueMsg(ircmsgs.privmsg(msg.nick, default))
return return
now = time.time() now = time.time()
throttle = self.registryValue('throttleTime', channel) throttle = self.registryValue('throttleTime', channel)
@ -126,6 +134,35 @@ class Herald(callbacks.Privmsg):
raise KeyError raise KeyError
return id return id
def default(self, irc, msg, args):
"""[<channel>] [--remove|<msg>]
If <msg> is given, sets the default herald to <msg>. A <msg> of ""
will remove the default herald. If <msg> is not given, returns the
current default herald. <channel> 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): def get(self, irc, msg, args):
"""[<channel>] <user|nick|hostmask> """[<channel>] <user|nick|hostmask>