Make op/halfop/voice like de{op,halfop,voice}.

This commit is contained in:
Jeremy Fincher 2004-02-09 18:23:21 +00:00
parent e3e896f014
commit 5969fbf990
2 changed files with 39 additions and 12 deletions

View File

@ -53,14 +53,17 @@ import callbacks
class Channel(callbacks.Privmsg): class Channel(callbacks.Privmsg):
def op(self, irc, msg, args, channel): def op(self, irc, msg, args, channel):
"""[<channel>] """[<channel>] [<nick> ...]
If you have the #channel.op capability, this will give you ops. If you have the #channel.op capability, this will give all the <nick>s
you provide ops. If you don't provide any <nick>s, this will op you.
<channel> is only necessary if the message isn't sent in the channel <channel> is only necessary if the message isn't sent in the channel
itself. itself.
""" """
if not args:
args = [msg.nick]
if irc.nick in irc.state.channels[channel].ops: if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.op(channel, msg.nick)) irc.queueMsg(ircmsgs.ops(channel, args))
else: else:
irc.error('How can I op you? I\'m not opped!') irc.error('How can I op you? I\'m not opped!')
op = privmsgs.checkChannelCapability(op, 'op') op = privmsgs.checkChannelCapability(op, 'op')
@ -68,12 +71,15 @@ class Channel(callbacks.Privmsg):
def halfop(self, irc, msg, args, channel): def halfop(self, irc, msg, args, channel):
"""[<channel>] """[<channel>]
If you have the #channel.halfop capability, this will give you halfops. If you have the #channel.halfop capability, this will give all the
<channel> is only necessary if the message isn't sent in the channel <nick>s you provide halfops. If you don't provide any <nick>s, this
itself. will give you halfops. <channel> 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: if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.halfop(channel, msg.nick)) irc.queueMsg(ircmsgs.halfops(channel, args))
else: else:
irc.error('How can I halfop you? I\'m not opped!') irc.error('How can I halfop you? I\'m not opped!')
halfop = privmsgs.checkChannelCapability(halfop, 'halfop') halfop = privmsgs.checkChannelCapability(halfop, 'halfop')
@ -81,12 +87,15 @@ class Channel(callbacks.Privmsg):
def voice(self, irc, msg, args, channel): def voice(self, irc, msg, args, channel):
"""[<channel>] """[<channel>]
If you have the #channel.voice capability, this will give you voice. If you have the #channel.voice capability, this will voice all the
<channel> is only necessary if the message isn't sent in the channel <nick>s you provide. If you don't provide any <nick>s, this will
itself. voice you. <channel> 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: if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.voice(channel, msg.nick)) irc.queueMsg(ircmsgs.voices(channel, args))
else: else:
irc.error('How can I voice you? I\'m not opped!') irc.error('How can I voice you? I\'m not opped!')
voice = privmsgs.checkChannelCapability(voice, 'voice') 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', self.log.warning('%r tried to ban %r, but both have %s',
msg.prefix, bannedHostmask, capability) msg.prefix, bannedHostmask, capability)
irc.error('%s has %s too, you can\'t ban him/her/it.' % irc.error('%s has %s too, you can\'t ban him/her/it.' %
bannedNick, capability) (bannedNick, capability))
else: else:
doBan() doBan()
else: else:

View File

@ -81,16 +81,34 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertError('op') self.assertError('op')
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
self.assertNotError('op') 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): def testHalfOp(self):
self.assertError('halfop') self.assertError('halfop')
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
self.assertNotError('halfop') 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): def testVoice(self):
self.assertError('voice') self.assertError('voice')
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick)) self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
self.assertNotError('voice') 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): def assertBan(self, query, hostmask, **kwargs):
m = self.getMsg(query, **kwargs) m = self.getMsg(query, **kwargs)