Channel: Perform proper capability checks in devoice.

Closes: Sf#3524393
Signed-off-by: James McCoy <jamessan@users.sourceforge.net>

Conflicts:

	plugins/Channel/plugin.py
This commit is contained in:
James McCoy 2012-05-20 20:57:13 -04:00 committed by Valentin Lorentz
parent 0a4e99b6f2
commit 7d99c28cf6

View File

@ -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
@ -163,15 +163,7 @@ class Channel(callbacks.Plugin):
halfop = wrap(halfop, ['halfop', ('haveOp', _('halfop someone')),
any('nickInChannel')])
@internationalizeDocstring
def voice(self, irc, msg, args, channel, nicks):
"""[<channel>] [<nick> ...]
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.
"""
def _voice(self, irc, msg, args, channel, nicks, fn):
if nicks:
if len(nicks) == 1 and msg.nick in nicks:
capability = 'voice'
@ -183,10 +175,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):
"""[<channel>] [<nick> ...]
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.
"""
self._voice(irc, msg, args, channel, nicks, ircmsgs.voices)
voice = wrap(voice, ['channel', ('isGranted', _('voice someone')),
any('nickInChannel')])
@ -242,22 +244,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 nicks:
if len(nicks) == 1 and msg.nick in nicks:
capability = 'voice'
else:
capability = 'op'
else:
nicks = [msg.nick]
capability = 'voice'
capability = ircdb.makeChannelCapability(channel, capability)
if ircdb.checkCapability(msg.prefix, capability):
def f(L):
return ircmsgs.devoices(channel, L)
self._sendMsgs(irc, nicks, f)
else:
irc.errorNoCapability(capability)
devoice = wrap(devoice, ['voice', ('isGranted', 'devoice someone'),
self._voice(irc, msg, args, channel, nicks, ircmsgs.devoices)
devoice = wrap(devoice, ['channel', ('haveOp', 'devoice someone'),
any('nickInChannel')])
@internationalizeDocstring