From b0b823fef150d8822fd54ecaf459195540928328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Fri, 2 Apr 2010 23:43:26 -0300 Subject: [PATCH] config rename: Bantracker.commetRequest => Bantracker.request Bantracker.reviewAfterTime => Bantracker.request.review --- Bantracker/config.py | 19 +++++++++---------- Bantracker/plugin.py | 29 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Bantracker/config.py b/Bantracker/config.py index 7d97520..a5c081c 100644 --- a/Bantracker/config.py +++ b/Bantracker/config.py @@ -34,26 +34,25 @@ conf.registerGlobalValue(Bantracker, 'database', conf.registerGlobalValue(Bantracker, 'bansite', registry.String('', "Web site for the bantracker, without the 'bans.cgi' appended", private=True)) -conf.registerGroup(Bantracker, 'commentRequest') -conf.registerChannelValue(Bantracker.commentRequest, 'type', +conf.registerGroup(Bantracker, 'request') +conf.registerChannelValue(Bantracker.request, 'type', SpaceSeparatedListOfTypes(['removal', 'ban', 'quiet'], "List of events for which the bot should request a comment.")) -conf.registerChannelValue(Bantracker.commentRequest, 'ignore', - registry.SpaceSeparatedListOfStrings([], +conf.registerChannelValue(Bantracker.request, 'ignore', + registry.SpaceSeparatedListOfStrings(['FloodBot?', 'FloodBotK?', 'ChanServ'], "List of nicks for which the bot won't request to comment a ban/quiet/removal."\ " Is case insensible and wildcards * ? are accepted.")) -conf.registerChannelValue(Bantracker.commentRequest, 'forward', +conf.registerChannelValue(Bantracker.request, 'forward', registry.SpaceSeparatedListOfStrings([], "List of nicks for which the bot will forward the request to"\ " the channels/nicks defined in forwards.channels option."\ " Is case insensible and wildcards * ? are accepted.")) -conf.registerChannelValue(Bantracker.commentRequest.forward, 'channels', +conf.registerChannelValue(Bantracker.request.forward, 'channels', registry.SpaceSeparatedListOfStrings([], "List of channels/nicks to forward the request if the op that set the ban/quiet"\ " is in the forward list.")) - - -# temp config -conf.registerGlobalValue(Bantracker, 'reviewAfterTime', +conf.registerChannelValue(Bantracker.request, 'review', registry.Float(7, "Days after which the bot will request for review a ban. Can be an integer or decimal value.")) + + diff --git a/Bantracker/plugin.py b/Bantracker/plugin.py index b0cb8a8..a9ee452 100644 --- a/Bantracker/plugin.py +++ b/Bantracker/plugin.py @@ -212,7 +212,6 @@ class PersistentCache(dict): return (host, nick, command, channel, text) - class Bantracker(callbacks.Plugin): """Plugin to manage bans. See '@list Bantracker' and '@help ' for commands""" @@ -409,7 +408,7 @@ class Bantracker(callbacks.Plugin): def requestComment(self, irc, channel, ban, type=None): # check if we should request a comment - if nickMatch(ban.who, self.registryValue('commentRequest.ignore', channel=channel)): + if nickMatch(ban.who, self.registryValue('request.ignore', channel=channel)): return # check the type of the action taken mask = ban.mask @@ -418,7 +417,7 @@ class Bantracker(callbacks.Plugin): if type == 'quiet': mask = mask[1:] # check if type is enabled - if type not in self.registryValue('commentRequest.type', channel=channel): + if type not in self.registryValue('request.type', channel=channel): return # send msg prefix = conf.supybot.reply.whenAddressedBy.chars()[0] # prefix char for commands @@ -427,8 +426,8 @@ class Bantracker(callbacks.Plugin): op = ircutils.nickFromHostmask(ban.who) except: op = ban.who - if nickMatch(op, self.registryValue('commentRequest.forward', channel=channel)): - channels = self.registryValue('commentRequest.forward.channels', channel=channel) + if nickMatch(op, self.registryValue('request.forward', channel=channel)): + channels = self.registryValue('request.forward.channels', channel=channel) if channels: s = "Please somebody comment on the %s of %s in %s done by %s, use:"\ " %scomment %s " %(type, mask, channel, op, prefix, ban.id) @@ -441,25 +440,25 @@ class Bantracker(callbacks.Plugin): s = "Please comment on the %s of %s in %s, use: %scomment %s " \ %(type, mask, channel, prefix, ban.id) self.log.info('SENDING: %s %s' %(op, s)) - #irc.reply(s, to=op, private=True) + irc.reply(s, to=op, private=True) def reviewBans(self): try: - reviewAfterTime = int(self.registryValue('reviewAfterTime') * 86400) - if not reviewAfterTime: - # time is zero, do nothing - return self.log.debug('Checking for bans that need review ...') now = time.mktime(time.gmtime()) lastreview = self.pendingReviews.time bansite = self.registryValue('bansite') if not lastreview: # initialize last time reviewed timestamp - lastreview = now - reviewAfterTime + lastreview = now - self.registryValue('request.review') for channel, bans in self.bans.iteritems(): - ignore = self.registryValue('commentRequest.ignore', channel=channel) - forward = self.registryValue('commentRequest.forward', channel=channel) - fchannels = self.registryValue('commentRequest.forward.channels', channel=channel) + reviewAfterTime = int(self.registryValue('request.review', channel=channel) * 86400) + if not reviewAfterTime: + # time is zero, do nothing + continue + ignore = self.registryValue('request.ignore', channel=channel) + forward = self.registryValue('request.forward', channel=channel) + fchannels = self.registryValue('request.forward.channels', channel=channel) for ban in bans: type = guessBanType(ban.mask) if type in ('quiet', 'removal'): @@ -521,7 +520,7 @@ class Bantracker(callbacks.Plugin): irc.queueMsg(msg) else: m = ircmsgs.privmsg(op, msg.args[1]) - #irc.queueMsg(m) + irc.queueMsg(m) del self.pendingReviews[host] def doLog(self, irc, channel, s):