From 144291b933d2f64bd1ba8ace43621a294a3eecee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Mon, 15 Mar 2010 20:51:32 -0300 Subject: [PATCH] In the case of quiets done by Chanserv, it would be nice to still remind the op to comment on it, like sending a notice to #ubuntu-ops. So two new options for this: forwardRequest: list of nicks for which the request will be redirected forwardChannels: list of channels where the redirected request will be send --- Bantracker/config.py | 16 ++++++++++++++-- Bantracker/plugin.py | 28 ++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Bantracker/config.py b/Bantracker/config.py index df5ac91..be86a81 100644 --- a/Bantracker/config.py +++ b/Bantracker/config.py @@ -28,5 +28,17 @@ conf.registerGlobalValue(conf.supybot.plugins.Bantracker, 'bansite', conf.registerChannelValue(Bantracker, 'dontRequestComment', registry.SpaceSeparatedListOfStrings([], - "List of nicks for which the bot won't request to comment a ban/quiet/removal. "\ - "Is case insensible and wildcards * ? are accepted.")) + "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, 'forwardRequest', + registry.SpaceSeparatedListOfStrings([], + "List of nicks for which the bot will forward the comment request to"\ + " the channels/nicks defined in forwardChannel option."\ + " Is case insensible and wildcards * ? are accepted.")) + +conf.registerChannelValue(Bantracker, 'forwardChannels', + registry.SpaceSeparatedListOfStrings([], + "List of channels/nicks to forward comment request if the op that set the ban/quiet"\ + " is in the forwardRequest list.")) + diff --git a/Bantracker/plugin.py b/Bantracker/plugin.py index a8d5031..9f551d3 100644 --- a/Bantracker/plugin.py +++ b/Bantracker/plugin.py @@ -91,6 +91,16 @@ def hostmaskPatternEqual(pattern, hostmask): pattern = pattern[1:] return ircutils.hostmaskPatternEqual(pattern, hostmask) +def nickMatch(nick, pattern): + """Checks if a given nick matches a pattern or in a list of patterns.""" + if isinstance(pattern, str): + pattern = [pattern] + nick = nick.lower() + for s in pattern: + if fnmatch(nick, s): + return True + return False + def dequeue(parent, irc): global queue queue.dequeue(parent, irc) @@ -329,9 +339,7 @@ class Bantracker(callbacks.Plugin): def requestComment(self, irc, channel, ban, type=None): # check if we should request a comment - opnick = ban.who.lower() - for pattern in self.registryValue('dontRequestComment', channel=channel): - if fnmatch(opnick, pattern): + if nickMatch(ban.who, self.registryValue('dontRequestComment', channel=channel)): return # check the type of the action taken mask = ban.mask @@ -344,8 +352,20 @@ class Bantracker(callbacks.Plugin): else: type = 'removal' # send msg + prefix = conf.supybot.reply.whenAddressedBy.chars()[0] + # check to who send the request + if nickMatch(ban.who, self.registryValue('forwardRequest', channel=channel)): + channels = self.registryValue('forwardChannels', channel=channel) + if channels: + s = "Please comment on the %s of %s in %s done by %s, use: %scomment %s " \ + %(type, mask, channel, ban.who, prefix, ban.id) + for chan in channels: + msg = ircmsgs.notice(chan, s) + irc.queueMsg(msg) + return + # send to op s = "Please comment on the %s of %s in %s, use: %scomment %s " \ - %(type, mask, channel, conf.supybot.reply.whenAddressedBy.chars()[0], ban.id) + %(type, mask, channel, prefix, ban.id) irc.reply(s, to=ban.who, private=True) def doLog(self, irc, channel, s):