From 772a04a32943149c92cdd6a6515d9ed05dcd734f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Thu, 23 Aug 2012 07:50:39 -0300 Subject: [PATCH] Don't deop after removing bans If bot fails to get op, and is opped later. --- Bantracker/plugin.py | 7 ++++--- Bantracker/test.py | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Bantracker/plugin.py b/Bantracker/plugin.py index cd43c4c..5492182 100644 --- a/Bantracker/plugin.py +++ b/Bantracker/plugin.py @@ -907,8 +907,9 @@ class Bantracker(callbacks.Plugin): def _getOpOK(self, channel): try: schedule.removeEvent('Bantracker_getop_%s' % channel) + return True except KeyError: - pass + return False def removeBans(self, irc, channel, modes, deop=False): # send unban messages, with 4 modes max each. @@ -1109,11 +1110,11 @@ class Bantracker(callbacks.Plugin): if ircutils.nickEqual(irc.nick, param[1]): opped = self.opped[channel] = mode[0] == '+' if opped == True: - self._getOpOK(channel) + opped_ok = self._getOpOK(channel) # check if we have bans to remove if channel in self.pendingBanremoval: modes = self.pendingBanremoval.pop(channel) - self.removeBans(irc, channel, modes, deop=True) + self.removeBans(irc, channel, modes, deop=opped_ok) continue # channel mask stuff diff --git a/Bantracker/test.py b/Bantracker/test.py index 6799e6e..3986f07 100644 --- a/Bantracker/test.py +++ b/Bantracker/test.py @@ -609,6 +609,9 @@ class BantrackerTestCase(ChannelPluginTestCase): msg = self.irc.takeMsg() # fail msg self.assertEqual(str(msg).strip(), "NOTICE #test :Failed to get op in #test") + self.op() + msg = self.irc.takeMsg() # unban msg + self.assertEqual(str(msg).strip(), "MODE #test -b :asd!*@*") finally: pluginConf.autoremove.notify.channels.set('')