list the ids of bans set to expire if no id is given to @baninfo

This commit is contained in:
Elián Hanisch 2012-07-27 16:03:15 -03:00
parent e979e864db
commit 44cd80515d
2 changed files with 20 additions and 3 deletions

View File

@ -1599,10 +1599,18 @@ class Bantracker(callbacks.Plugin):
banremove = wrap(banremove, ['something', 'text'])
def baninfo(self, irc, msg, args, id):
"""<id>
"""[<id>]
Show ban information.
Show ban information. If <id> is not given shows the ids of bans set to
expire.
"""
if id is None:
count = len(self.managedBans)
L = [ str(item.ban.id) for item in self.managedBans ]
irc.reply("%s bans set to expire: %s" % (count, ', '.join(L)))
return
L = self.db_run("SELECT mask, channel, removal FROM bans WHERE id = %s",
id, expect_result=True)
if not L:
@ -1639,7 +1647,7 @@ class Bantracker(callbacks.Plugin):
irc.reply("[%s] %s - %s - %s" % (id, type, mask, channel))
baninfo = wrap(baninfo, ['id'])
baninfo = wrap(baninfo, [optional('id')])
def banlink(self, irc, msg, args, id, highlight):
"""<id> [<highlight>]

View File

@ -509,4 +509,13 @@ class BantrackerTestCase(ChannelPluginTestCase):
'op!user@host.net'))
self.assertResponse('baninfo 1', '[1] ban - asd!*@* - #test - not active')
def testBaninfoGeneral(self):
cb = self.getCallback()
self.feedBan('asd!*@*')
self.feedBan('qwe!*@*')
self.assertNotError('banremove 1 1d')
self.assertResponse('baninfo', "1 bans set to expire: 1")
self.assertNotError('banremove 2 1d')
self.assertResponse('baninfo', "2 bans set to expire: 1, 2")