From 800a228d9276adfd6be2f9d683bc5554f0ea19aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Thu, 5 Jul 2012 19:12:38 -0300 Subject: [PATCH] banremove should only work with bans or quiets. --- Bantracker/plugin.py | 6 ++++++ Bantracker/test.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Bantracker/plugin.py b/Bantracker/plugin.py index b555a29..dcf5e0b 100644 --- a/Bantracker/plugin.py +++ b/Bantracker/plugin.py @@ -1469,8 +1469,14 @@ class Bantracker(callbacks.Plugin): irc.reply("Ban '%s' isn't active in %s." % (mask, channel)) return + if ban.type not in ('ban', 'quiet'): + irc.reply("Id %s is a %s, only bans or quiets can be autoremoved." \ + % (id, ban.type)) + return + self.managedBans.add(BanRemoval(ban, seconds)) irc.replySuccess() + banremove = wrap(banremove, ['id', 'text']) def banlink(self, irc, msg, args, id, highlight): diff --git a/Bantracker/test.py b/Bantracker/test.py index 94cb60f..4e5f37a 100644 --- a/Bantracker/test.py +++ b/Bantracker/test.py @@ -371,6 +371,11 @@ class BantrackerTestCase(ChannelPluginTestCase): msg = self.irc.takeMsg() # unban msg self.assertEqual(str(msg).strip(), "MODE #test -q :asd!*@*") + def testBanremoveBadType(self): + self.feedBan('nick', mode='k') + self.assertResponse('banremove 1 0', + "Id 1 is a removal, only bans or quiets can be autoremoved.") + def testBanremoveBadId(self): self.assertResponse('banremove 1 0', "I don't know any ban with that id.")