From 39ab2b78bfdc4cb46fc4602f8d610e6e55900309 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 3 Dec 2003 20:27:42 +0000 Subject: [PATCH] Added Channel.{deop,devoice,dehalfop} --- ChangeLog | 2 ++ src/Channel.py | 36 ++++++++++++++++++++++++++++++++++++ test/test_Channel.py | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1cec4c063..053ab37c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/src/Channel.py b/src/Channel.py index 6e251234d..520f81737 100755 --- a/src/Channel.py +++ b/src/Channel.py @@ -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): + """[] [ ...] + + 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): + """[] [ ...] + + 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): + """[] [ ...] + + 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): """[] [] diff --git a/test/test_Channel.py b/test/test_Channel.py index bbfbcb6cf..5352a2ba2 100644 --- a/test/test_Channel.py +++ b/test/test_Channel.py @@ -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))