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
This commit is contained in:
Elián Hanisch 2010-03-15 20:51:32 -03:00
parent bf737d510f
commit 144291b933
2 changed files with 38 additions and 6 deletions

View File

@ -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."))

View File

@ -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 <comment>" \
%(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 <comment>" \
%(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):