Made sure the pluralized power commands don't get run with no arguments.

This commit is contained in:
Jeremy Fincher 2003-12-03 20:49:51 +00:00
parent e4d9f6ded2
commit 4726fdf223
2 changed files with 22 additions and 2 deletions

View File

@ -96,6 +96,8 @@ class Channel(callbacks.Privmsg):
If you have the #channel.op capability, this will remove operator
privileges from all the nicks given.
"""
if not args:
raise callbacks.ArgumentError
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.deops(channel, args))
else:
@ -108,6 +110,8 @@ class Channel(callbacks.Privmsg):
If you have the #channel.op capability, this will remove half-operator
privileges from all the nicks given.
"""
if not args:
raise callbacks.ArgumentError
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.dehalfops(channel, args))
else:
@ -120,6 +124,8 @@ class Channel(callbacks.Privmsg):
If you have the #channel.op capability, this will remove voice from all
the nicks given.
"""
if not args:
raise callbacks.ArgumentError
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.devoices(channel, args))
else:
@ -141,6 +147,20 @@ class Channel(callbacks.Privmsg):
irc.queueMsg(ircmsgs.join(channel, key))
cycle = privmsgs.checkChannelCapability(cycle, 'op')
def kick(self, irc, msg, args, channel):
"""[<channel>] <nick> [<reason>]
Kicks <nick> from <channel> for <reason>. If <reason> isn't given,
uses the nick of the person making the command as the reason.
<channel> is only necessary if the message isn't sent in the channel
itself.
"""
(nick, reason) = privmsgs.getArgs(args, optional=1)
if not reason:
reason = msg.nick
irc.queueMsg(ircmsgs.kick(channel, nick, reason))
kick = privmsgs.checkChannelCapability(kick, 'op')
def kban(self, irc, msg, args):
"""[<channel>] <nick> [<number of seconds to ban>]

View File

@ -50,9 +50,9 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
def testErrorsWithoutOps(self):
for s in ['op', 'deop', 'voice', 'devoice', 'halfop', 'dehalfop']:
self.assertError(s)
self.assertError('%s foo' % s)
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
self.assertNotError(s)
self.assertNotError('%s foo' % s)
self.irc.feedMsg(ircmsgs.deop(self.channel, self.nick))
def testOp(self):