added configuration options:

* supybot.plugins.Bantracker.autoremove
* supybot.plugins.Bantracker.autoremove.notify
* supybot.plugins.Bantracker.autoremove.notify.channels
This commit is contained in:
Elián Hanisch 2012-07-04 22:12:55 -03:00
parent 87f61b1654
commit e3f6aacdf5
3 changed files with 41 additions and 14 deletions

View File

@ -225,4 +225,15 @@ conf.registerChannelValue(Bantracker.review.forward, 'channels',
registry.SpaceSeparatedListOfStrings([],
"List of channels/nicks to forward the request if the op is in the forward list."))
conf.registerChannelValue(Bantracker, 'autoremove',
registry.Boolean(True,
"""Enable/disable autoremoval of bans."""))
conf.registerChannelValue(Bantracker.autoremove, 'notify',
registry.Boolean(True,
"""Enable/disable notifications of removal of bans."""))
conf.registerChannelValue(Bantracker.autoremove.notify, 'channels',
registry.SpaceSeparatedListOfStrings([],
"""List of channels/nicks to notify about automatic removal of bans."""))

View File

@ -775,6 +775,9 @@ class Bantracker(callbacks.Plugin):
modedict = { 'quiet': '-q', 'ban': '-b' }
for ban in self.managedBans.popExpired():
channel, mask, type = ban.ban.channel, ban.ban.mask, ban.ban.type
if not self.registryValue('autoremove', channel):
continue
self.log.info("%s [%s] %s in %s expired", type,
ban.ban.id,
mask,
@ -787,9 +790,18 @@ class Bantracker(callbacks.Plugin):
for ban in self.managedBans.getExpired(600):
if ban.notified:
continue
id, channel, mask, type = ban.ban.id, ban.ban.channel, ban.ban.mask, ban.ban.type
notice = ircmsgs.notice('#test', "%s [%s] %s in %s will expire in a few minutes." \
% (type, id, mask, channel))
channel = ban.ban.channel
if not self.registryValue('autoremove', channel) \
or not self.registryValue('autoremove.notify', channel):
continue
for c in self.registryValue('autoremove.notify.channels', channel):
notice = ircmsgs.notice(c, "%s [%s] %s in %s will expire in a few minutes." \
% (ban.ban.type,
ban.ban.id,
ban.ban.mask,
channel))
irc.queueMsg(notice)
ban.notified = True

View File

@ -394,6 +394,8 @@ class BantrackerTestCase(ChannelPluginTestCase):
cb = self.getCallback()
self.feedBan('asd!*@*')
self.assertNotError('banremove 1 300')
pluginConf.autoremove.notify.channels().append('#test')
try:
cb.autoRemoveBans(self.irc)
msg = self.irc.takeMsg()
self.assertEqual(str(msg).strip(),
@ -401,6 +403,8 @@ class BantrackerTestCase(ChannelPluginTestCase):
# don't send the notice again.
cb.autoRemoveBans(self.irc)
self.assertFalse(self.irc.takeMsg())
finally:
del pluginConf.autoremove.notify.channels()[:]