Added an unban command.

This commit is contained in:
Jeremy Fincher 2003-10-15 04:46:19 +00:00
parent db720ce810
commit 6476e63f20
2 changed files with 27 additions and 0 deletions

View File

@ -37,6 +37,7 @@ to have the <channel>.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):
"""[<channel>] <hostmask>
Unbans <hostmask> on <channel>. Especially useful for unbanning
yourself when you get unexpectedly (or accidentally) banned from
the channel. <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):
"""[<channel>]

View File

@ -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))