diff --git a/src/ChannelCommands.py b/src/ChannelCommands.py index 01f4b5add..3b2a6d2d4 100755 --- a/src/ChannelCommands.py +++ b/src/ChannelCommands.py @@ -37,6 +37,7 @@ to have the .op capability. This plugin is loaded by default. import time import conf +import debug import ircdb import ircmsgs import schedule @@ -128,6 +129,22 @@ class ChannelCommands(callbacks.Privmsg): else: irc.error(msg, conf.replyNoCapability % capability) + def unban(self, irc, msg, args, channel): + """[] + + Unbans on . Especially useful for unbanning + yourself when you get unexpectedly (or accidentally) banned from + the channel. is only necessary if the message isn't sent + in the channel itself. + """ + hostmask = privmsgs.getArgs(args) + if irc.nick in irc.state.channels[channel].ops: + irc.queueMsg(ircmsgs.unban(channel, hostmask)) + irc.reply(msg, conf.replySuccess) + else: + irc.error(msg, 'How can I unban someone? I\'m not opped.') + unban = privmsgs.checkChannelCapability(unban, 'op') + def lobotomize(self, irc, msg, args, channel): """[] diff --git a/test/test_ChannelCommands.py b/test/test_ChannelCommands.py index d5dbc6c4c..b5a36b2bb 100644 --- a/test/test_ChannelCommands.py +++ b/test/test_ChannelCommands.py @@ -37,6 +37,16 @@ import ircmsgs class ChannelCommandsTestCase(ChannelPluginTestCase, PluginDocumentation): plugins = ('ChannelCommands',) + def testUnban(self): + self.assertError('unban foo!bar@baz') + self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) + m = self.getMsg('unban foo!bar@baz') + print + debug.printf(m) + self.assertEqual(m.command, 'MODE') + self.assertEqual(m.args, (self.channel, '-b', 'foo!bar@baz')) + self.assertNotError(' ') + def testOp(self): self.assertError('op') self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))