From 5969fbf990d6d76a296ef2f7e76b508860f409af Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 9 Feb 2004 18:23:21 +0000 Subject: [PATCH] Make op/halfop/voice like de{op,halfop,voice}. --- src/Channel.py | 33 +++++++++++++++++++++------------ test/test_Channel.py | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/Channel.py b/src/Channel.py index 3f911918c..972c7b922 100755 --- a/src/Channel.py +++ b/src/Channel.py @@ -53,14 +53,17 @@ import callbacks class Channel(callbacks.Privmsg): def op(self, irc, msg, args, channel): - """[] + """[] [ ...] - If you have the #channel.op capability, this will give you ops. + If you have the #channel.op capability, this will give all the s + you provide ops. If you don't provide any s, this will op you. is only necessary if the message isn't sent in the channel itself. """ + if not args: + args = [msg.nick] if irc.nick in irc.state.channels[channel].ops: - irc.queueMsg(ircmsgs.op(channel, msg.nick)) + irc.queueMsg(ircmsgs.ops(channel, args)) else: irc.error('How can I op you? I\'m not opped!') op = privmsgs.checkChannelCapability(op, 'op') @@ -68,12 +71,15 @@ class Channel(callbacks.Privmsg): def halfop(self, irc, msg, args, channel): """[] - If you have the #channel.halfop capability, this will give you halfops. - is only necessary if the message isn't sent in the channel - itself. + If you have the #channel.halfop capability, this will give all the + s you provide halfops. If you don't provide any s, this + will give you halfops. is only necessary if the message isn't + sent in the channel itself. """ + if not args: + args = [msg.nick] if irc.nick in irc.state.channels[channel].ops: - irc.queueMsg(ircmsgs.halfop(channel, msg.nick)) + irc.queueMsg(ircmsgs.halfops(channel, args)) else: irc.error('How can I halfop you? I\'m not opped!') halfop = privmsgs.checkChannelCapability(halfop, 'halfop') @@ -81,12 +87,15 @@ class Channel(callbacks.Privmsg): def voice(self, irc, msg, args, channel): """[] - If you have the #channel.voice capability, this will give you voice. - is only necessary if the message isn't sent in the channel - itself. + If you have the #channel.voice capability, this will voice all the + s you provide. If you don't provide any s, this will + voice you. is only necessary if the message isn't sent in the + channel itself. """ + if not args: + args = [msg.nick] if irc.nick in irc.state.channels[channel].ops: - irc.queueMsg(ircmsgs.voice(channel, msg.nick)) + irc.queueMsg(ircmsgs.voices(channel, args)) else: irc.error('How can I voice you? I\'m not opped!') voice = privmsgs.checkChannelCapability(voice, 'voice') @@ -263,7 +272,7 @@ class Channel(callbacks.Privmsg): self.log.warning('%r tried to ban %r, but both have %s', msg.prefix, bannedHostmask, capability) irc.error('%s has %s too, you can\'t ban him/her/it.' % - bannedNick, capability) + (bannedNick, capability)) else: doBan() else: diff --git a/test/test_Channel.py b/test/test_Channel.py index 461ab9e75..85f1f8b43 100644 --- a/test/test_Channel.py +++ b/test/test_Channel.py @@ -81,16 +81,34 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation): self.assertError('op') self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.assertNotError('op') + m = self.getMsg('op foo') + self.failUnless(m.command == 'MODE' and + m.args == (self.channel, '+o', 'foo')) + m = self.getMsg('op foo bar') + self.failUnless(m.command == 'MODE' and + m.args == (self.channel, '+oo', 'foo', 'bar')) def testHalfOp(self): self.assertError('halfop') self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.assertNotError('halfop') + m = self.getMsg('halfop foo') + self.failUnless(m.command == 'MODE' and + m.args == (self.channel, '+h', 'foo')) + m = self.getMsg('halfop foo bar') + self.failUnless(m.command == 'MODE' and + m.args == (self.channel, '+hh', 'foo', 'bar')) def testVoice(self): self.assertError('voice') self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.assertNotError('voice') + m = self.getMsg('voice foo') + self.failUnless(m.command == 'MODE' and + m.args == (self.channel, '+v', 'foo')) + m = self.getMsg('voice foo bar') + self.failUnless(m.command == 'MODE' and + m.args == (self.channel, '+vv', 'foo', 'bar')) def assertBan(self, query, hostmask, **kwargs): m = self.getMsg(query, **kwargs)