From 06832d6e3abba0acb6941a59b11d591e312264a8 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 16 Apr 2012 07:56:20 +0000 Subject: [PATCH] Channel: Add capability checks in @voice --- plugins/Channel/plugin.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/Channel/plugin.py b/plugins/Channel/plugin.py index a1f6b0705..59f2aea38 100644 --- a/plugins/Channel/plugin.py +++ b/plugins/Channel/plugin.py @@ -242,11 +242,21 @@ 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: + if nicks: + if len(nicks) == 1 and msg.nick in nicks: + capability = 'voice' + else: + capability = 'op' + else: nicks = [msg.nick] - def f(L): - return ircmsgs.devoices(channel, L) - self._sendMsgs(irc, nicks, f) + 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'), any('nickInChannel')])