add a simple @baninfo command for check when a ban expires.
This commit is contained in:
parent
bf93f42503
commit
c283e6b924
|
@ -1490,6 +1490,41 @@ class Bantracker(callbacks.Plugin):
|
||||||
|
|
||||||
banremove = wrap(banremove, ['id', 'text'])
|
banremove = wrap(banremove, ['id', 'text'])
|
||||||
|
|
||||||
|
def baninfo(self, irc, msg, args, id):
|
||||||
|
"""<id>
|
||||||
|
|
||||||
|
Show ban information.
|
||||||
|
"""
|
||||||
|
L = self.db_run("SELECT mask, channel, removal FROM bans WHERE id = %s",
|
||||||
|
id, expect_result=True)
|
||||||
|
if not L:
|
||||||
|
irc.reply("I don't know any ban with that id.")
|
||||||
|
return
|
||||||
|
|
||||||
|
mask, channel, removal = L[0]
|
||||||
|
type = guessBanType(mask)
|
||||||
|
if type == 'quiet':
|
||||||
|
mask = mask[1:]
|
||||||
|
for br in self.managedBans:
|
||||||
|
if br.ban.id == id:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
br = None
|
||||||
|
|
||||||
|
if br:
|
||||||
|
irc.reply("[%s] %s - %s - %s - expires in %s" \
|
||||||
|
% (id, type, mask, channel,
|
||||||
|
(br.ban.when + br.expires) - nowSeconds()))
|
||||||
|
else:
|
||||||
|
if type in ('quiet', 'ban'):
|
||||||
|
irc.reply("[%s] %s - %s - %s - never expires" \
|
||||||
|
% (id, type, mask, channel))
|
||||||
|
else:
|
||||||
|
irc.reply("[%s] %s - %s - %s" % (id, type, mask, channel))
|
||||||
|
|
||||||
|
|
||||||
|
baninfo = wrap(baninfo, ['id'])
|
||||||
|
|
||||||
def banlink(self, irc, msg, args, id, highlight):
|
def banlink(self, irc, msg, args, id, highlight):
|
||||||
"""<id> [<highlight>]
|
"""<id> [<highlight>]
|
||||||
|
|
||||||
|
|
|
@ -447,5 +447,11 @@ class BantrackerTestCase(ChannelPluginTestCase):
|
||||||
self.assertEqual(L[i].ban.mask, n)
|
self.assertEqual(L[i].ban.mask, n)
|
||||||
self.assertEqual(L[0].ban.channel, '#test')
|
self.assertEqual(L[0].ban.channel, '#test')
|
||||||
|
|
||||||
|
def testBaninfo(self):
|
||||||
|
cb = self.getCallback()
|
||||||
|
self.feedBan('asd!*@*')
|
||||||
|
self.assertResponse('baninfo 1', '[1] ban - asd!*@* - #test - never expires')
|
||||||
|
self.assertNotError('banremove 1 10')
|
||||||
|
self.assertResponse('baninfo 1', '[1] ban - asd!*@* - #test - expires in 10.0')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue