From 66ac089a535159ab9df7f7df8c845aef15eac2d9 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 20 May 2012 20:57:13 -0400 Subject: [PATCH] Channel: Perform proper capability checks in devoice. Closes: Sf#3524393 Signed-off-by: James McCoy --- plugins/Channel/plugin.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index b89647478..bc1bf2d14 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher -# Copyright (c) 2009, James Vega +# Copyright (c) 2009-2012, James McCoy # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -153,14 +153,7 @@ class Channel(callbacks.Plugin): halfop = wrap(halfop, ['halfop', ('haveOp', 'halfop someone'), any('nickInChannel')]) - def voice(self, irc, msg, args, channel, nicks): - """[] [ ...] - - 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. - """ + def _voice(self, irc, msg, args, channel, nicks, fn): if nicks: if len(nicks) == 1 and msg.nick in nicks: capability = 'voice' @@ -172,10 +165,20 @@ class Channel(callbacks.Plugin): capability = ircdb.makeChannelCapability(channel, capability) if ircdb.checkCapability(msg.prefix, capability): def f(L): - return ircmsgs.voices(channel, L) + return fn(channel, L) self._sendMsgs(irc, nicks, f) else: irc.errorNoCapability(capability) + + def voice(self, irc, msg, args, channel, nicks): + """[] [ ...] + + 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. + """ + self._voice(irc, msg, args, channel, nicks, ircmsgs.voices) voice = wrap(voice, ['channel', ('haveOp', 'voice someone'), any('nickInChannel')]) @@ -228,12 +231,8 @@ class Channel(callbacks.Plugin): irc.error('I cowardly refuse to devoice myself. If you really ' 'want me devoiced, tell me to op you and then devoice ' 'me yourself.', Raise=True) - if not nicks: - nicks = [msg.nick] - def f(L): - return ircmsgs.devoices(channel, L) - self._sendMsgs(irc, nicks, f) - devoice = wrap(devoice, ['voice', ('haveOp', 'devoice someone'), + self._voice(irc, msg, args, channel, nicks, ircmsgs.devoices) + devoice = wrap(devoice, ['channel', ('haveOp', 'devoice someone'), any('nickInChannel')]) def cycle(self, irc, msg, args, channel):