mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
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:
parent
0a4e99b6f2
commit
7d99c28cf6
@ -1,6 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||||
# Copyright (c) 2009, James Vega
|
# Copyright (c) 2009-2012, James McCoy
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# 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')),
|
halfop = wrap(halfop, ['halfop', ('haveOp', _('halfop someone')),
|
||||||
any('nickInChannel')])
|
any('nickInChannel')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
def _voice(self, irc, msg, args, channel, nicks, fn):
|
||||||
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.
|
|
||||||
"""
|
|
||||||
if nicks:
|
if nicks:
|
||||||
if len(nicks) == 1 and msg.nick in nicks:
|
if len(nicks) == 1 and msg.nick in nicks:
|
||||||
capability = 'voice'
|
capability = 'voice'
|
||||||
@ -183,10 +175,20 @@ class Channel(callbacks.Plugin):
|
|||||||
capability = ircdb.makeChannelCapability(channel, capability)
|
capability = ircdb.makeChannelCapability(channel, capability)
|
||||||
if ircdb.checkCapability(msg.prefix, capability):
|
if ircdb.checkCapability(msg.prefix, capability):
|
||||||
def f(L):
|
def f(L):
|
||||||
return ircmsgs.voices(channel, L)
|
return fn(channel, L)
|
||||||
self._sendMsgs(irc, nicks, f)
|
self._sendMsgs(irc, nicks, f)
|
||||||
else:
|
else:
|
||||||
irc.errorNoCapability(capability)
|
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')),
|
voice = wrap(voice, ['channel', ('isGranted', _('voice someone')),
|
||||||
any('nickInChannel')])
|
any('nickInChannel')])
|
||||||
|
|
||||||
@ -242,22 +244,8 @@ class Channel(callbacks.Plugin):
|
|||||||
irc.error(_('I cowardly refuse to devoice myself. If you really '
|
irc.error(_('I cowardly refuse to devoice myself. If you really '
|
||||||
'want me devoiced, tell me to op you and then devoice '
|
'want me devoiced, tell me to op you and then devoice '
|
||||||
'me yourself.'), Raise=True)
|
'me yourself.'), Raise=True)
|
||||||
if nicks:
|
self._voice(irc, msg, args, channel, nicks, ircmsgs.devoices)
|
||||||
if len(nicks) == 1 and msg.nick in nicks:
|
devoice = wrap(devoice, ['channel', ('haveOp', 'devoice someone'),
|
||||||
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'),
|
|
||||||
any('nickInChannel')])
|
any('nickInChannel')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
Loading…
Reference in New Issue
Block a user