Added Channel.{deop,devoice,dehalfop}

This commit is contained in:
Jeremy Fincher 2003-12-03 20:27:42 +00:00
parent 7f3cafbfbd
commit 39ab2b78bf
3 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,5 @@
* Added Channel.{deop,devoice,dehalfop}.
* Added Http.size and Http.doctype and Http.headers to retrieve
various meta-information on URLs.

View File

@ -89,6 +89,42 @@ class Channel(callbacks.Privmsg):
else:
irc.error(msg, 'How can I voice you? I\'m not opped!')
voice = privmsgs.checkChannelCapability(voice, 'voice')
def deop(self, irc, msg, args, channel):
"""[<channel>] <nick> [<nick> ...]
If you have the #channel.op capability, this will remove operator
privileges from all the nicks given.
"""
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.deops(channel, args))
else:
irc.error(msg, 'How can I deop someone? I\'m not opped!')
deop = privmsgs.checkChannelCapability(deop, 'op')
def dehalfop(self, irc, msg, args, channel):
"""[<channel>] <nick> [<nick> ...]
If you have the #channel.op capability, this will remove half-operator
privileges from all the nicks given.
"""
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.dehalfops(channel, args))
else:
irc.error(msg, 'How can I deop someone? I\'m not opped!')
dehalfop = privmsgs.checkChannelCapability(dehalfop, 'op')
def devoice(self, irc, msg, args, channel):
"""[<channel>] <nick> [<nick> ...]
If you have the #channel.op capability, this will remove voice from all
the nicks given.
"""
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.devoices(channel, args))
else:
irc.error(msg, 'How can I deop someone? I\'m not opped!')
devoice = privmsgs.checkChannelCapability(devoice, 'op')
def cycle(self, irc, msg, args, channel):
"""[<channel>] [<key>]

View File

@ -48,6 +48,13 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertEqual(m.args, (self.channel, '-b', 'foo!bar@baz'))
self.assertNotError(' ')
def testErrorsWithoutOps(self):
for s in ['op', 'deop', 'voice', 'devoice', 'halfop', 'dehalfop']:
self.assertError(s)
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
self.assertNotError(s)
self.irc.feedMsg(ircmsgs.deop(self.channel, self.nick))
def testOp(self):
self.assertError('op')
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))