mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +01:00
Make op/halfop/voice like de{op,halfop,voice}.
This commit is contained in:
parent
e3e896f014
commit
5969fbf990
@ -53,14 +53,17 @@ import callbacks
|
||||
|
||||
class Channel(callbacks.Privmsg):
|
||||
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
|
||||
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):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel.halfop capability, this will give you halfops.
|
||||
<channel> 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
|
||||
<nick>s you provide halfops. If you don't provide any <nick>s, this
|
||||
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:
|
||||
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):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel.voice capability, this will give you voice.
|
||||
<channel> 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
|
||||
<nick>s you provide. If you don't provide any <nick>s, this will
|
||||
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:
|
||||
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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user