commands.py: Rename 'isGranted' to 'haveHalfop+' and add 'haveVoice+'.

This commit is contained in:
Valentin Lorentz 2013-05-17 17:36:11 +02:00
parent f42023bf19
commit ed62c9efb1
3 changed files with 37 additions and 23 deletions

View File

@ -73,7 +73,7 @@ class Channel(callbacks.Plugin):
itself.
"""
self._sendMsg(irc, ircmsgs.mode(channel, modes))
mode = wrap(mode, ['op', ('isGranted', _('change the mode')), many('something')])
mode = wrap(mode, ['op', ('haveHalfop+', _('change the mode')), many('something')])
@internationalizeDocstring
def limit(self, irc, msg, args, channel, limit):
@ -99,7 +99,7 @@ class Channel(callbacks.Plugin):
message isn't sent in the channel itself.
"""
self._sendMsg(irc, ircmsgs.mode(channel, ['+m']))
moderate = wrap(moderate, ['op', ('isGranted', _('moderate the channel'))])
moderate = wrap(moderate, ['op', ('haveHalfop+', _('moderate the channel'))])
@internationalizeDocstring
def unmoderate(self, irc, msg, args, channel):
@ -110,7 +110,7 @@ class Channel(callbacks.Plugin):
message isn't sent in the channel itself.
"""
self._sendMsg(irc, ircmsgs.mode(channel, ['-m']))
unmoderate = wrap(unmoderate, ['op', ('isGranted',
unmoderate = wrap(unmoderate, ['op', ('haveHalfop+',
_('unmoderate the channel'))])
@internationalizeDocstring
@ -127,7 +127,7 @@ class Channel(callbacks.Plugin):
self._sendMsg(irc, ircmsgs.mode(channel, ['+k', key]))
else:
self._sendMsg(irc, ircmsgs.mode(channel, ['-k']))
key = wrap(key, ['op', ('isGranted', _('change the keyword')),
key = wrap(key, ['op', ('haveHalfop+', _('change the keyword')),
additional('somethingWithoutSpaces', '')])
@internationalizeDocstring
@ -189,7 +189,7 @@ class Channel(callbacks.Plugin):
channel itself.
"""
self._voice(irc, msg, args, channel, nicks, ircmsgs.voices)
voice = wrap(voice, ['channel', ('isGranted', _('voice someone')),
voice = wrap(voice, ['channel', ('haveHalfop+', _('voice someone')),
any('nickInChannel')])
@internationalizeDocstring
@ -281,7 +281,7 @@ class Channel(callbacks.Plugin):
Raise=True)
for nick in nicks:
self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
kick = wrap(kick, ['op', ('isGranted', _('kick someone')),
kick = wrap(kick, ['op', ('haveHalfop+', _('kick someone')),
commalist('nickInChannel'), additional('text')])
@internationalizeDocstring
@ -304,7 +304,7 @@ class Channel(callbacks.Plugin):
kban = wrap(kban,
['op',
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
('isGranted', _('kick or ban someone')),
('haveHalfop+', _('kick or ban someone')),
'nickInChannel',
optional('expiry', 0),
additional('text')])
@ -328,7 +328,7 @@ class Channel(callbacks.Plugin):
iban = wrap(iban,
['op',
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
('isGranted', _('ban someone')),
('haveHalfop+', _('ban someone')),
first('nick', 'hostmask'),
optional('expiry', 0)])
@ -434,7 +434,7 @@ class Channel(callbacks.Plugin):
irc.error(_('No bans matching %s were found on %s.') %
(msg.prefix, channel))
unban = wrap(unban, ['op',
('isGranted', _('unban someone')),
('haveHalfop+', _('unban someone')),
additional(
first('hostmask',
('literal', '--all')))])
@ -459,7 +459,7 @@ class Channel(callbacks.Plugin):
nick = nick or msg.nick
self._sendMsg(irc, ircmsgs.invite(nick, channel))
self.invites[(irc.getRealIrc(), ircutils.toLower(nick))] = irc
invite = wrap(invite, ['op', ('isGranted', _('invite someone')),
invite = wrap(invite, ['op', ('haveHalfop+', _('invite someone')),
additional('nick')])
def do341(self, irc, msg):

View File

@ -481,7 +481,7 @@ class Topic(callbacks.Plugin):
irc.errorNoCapability(capabilities, Raise=True)
irc.queueMsg(ircmsgs.mode(channel, '+t'))
irc.noReply()
lock = wrap(lock, ['channel', ('isGranted', _('lock the topic'))])
lock = wrap(lock, ['channel', ('haveHalfop+', _('lock the topic'))])
@internationalizeDocstring
def unlock(self, irc, msg, args, channel):
@ -495,7 +495,7 @@ class Topic(callbacks.Plugin):
irc.errorNoCapability(capabilities, Raise=True)
irc.queueMsg(ircmsgs.mode(channel, '-t'))
irc.noReply()
unlock = wrap(unlock, ['channel', ('isGranted', _('unlock the topic'))])
unlock = wrap(unlock, ['channel', ('haveHalfop+', _('unlock the topic'))])
@internationalizeDocstring
def restore(self, irc, msg, args, channel):

View File

@ -325,6 +325,18 @@ def getHaveVoice(irc, msg, args, state, action=_('do that')):
if not irc.state.channels[state.channel].isVoice(irc.nick):
state.error(_('I need to be voiced to %s.') % action, Raise=True)
def getHaveVoicePlus(irc, msg, args, state, action=_('do that')):
if not state.channel:
getChannel(irc, msg, args, state)
if state.channel not in irc.state.channels:
state.error(_('I\'m not even in %s.') % state.channel, Raise=True)
if not irc.state.channels[state.channel].isOp(irc.nick) and \
not irc.state.channels[state.channel].isHalfop(irc.nick) and \
not irc.state.channels[state.channel].isVoice(irc.nick):
# isOp includes owners and protected users
state.error(_('I need to be at least voiced to %s.') % action,
Raise=True)
def getHaveHalfop(irc, msg, args, state, action=_('do that')):
if not state.channel:
getChannel(irc, msg, args, state)
@ -333,15 +345,7 @@ def getHaveHalfop(irc, msg, args, state, action=_('do that')):
if not irc.state.channels[state.channel].isHalfop(irc.nick):
state.error(_('I need to be halfopped to %s.') % action, Raise=True)
def getHaveOp(irc, msg, args, state, action=_('do that')):
if not state.channel:
getChannel(irc, msg, args, state)
if state.channel not in irc.state.channels:
state.error(_('I\'m not even in %s.') % state.channel, Raise=True)
if not irc.state.channels[state.channel].isOp(irc.nick):
state.error(_('I need to be opped to %s.') % action, Raise=True)
def getIsGranted(irc, msg, args, state, action=_('do that')):
def getHaveHalfopPlus(irc, msg, args, state, action=_('do that')):
if not state.channel:
getChannel(irc, msg, args, state)
if state.channel not in irc.state.channels:
@ -352,6 +356,14 @@ def getIsGranted(irc, msg, args, state, action=_('do that')):
state.error(_('I need to be at least halfopped to %s.') % action,
Raise=True)
def getHaveOp(irc, msg, args, state, action=_('do that')):
if not state.channel:
getChannel(irc, msg, args, state)
if state.channel not in irc.state.channels:
state.error(_('I\'m not even in %s.') % state.channel, Raise=True)
if not irc.state.channels[state.channel].isOp(irc.nick):
state.error(_('I need to be opped to %s.') % action, Raise=True)
def validChannel(irc, msg, args, state):
if irc.isChannel(args[0]):
state.args.append(args.pop(0))
@ -700,8 +712,7 @@ wrappers = ircutils.IrcDict({
'banmask': getBanmask,
'boolean': getBoolean,
'callerInGivenChannel': callerInGivenChannel,
'isGranted': getIsGranted, # I know this name sucks, but I can't find
# something better
'isGranted': getHaveHalfopPlus, # Backward compatibility
'capability': getSomethingNoSpaces,
'channel': getChannel,
'channelOrGlobal': getChannelOrGlobal,
@ -718,8 +729,11 @@ wrappers = ircutils.IrcDict({
'glob': getGlob,
'halfop': getHalfop,
'haveHalfop': getHaveHalfop,
'haveHalfop+': getHaveHalfopPlus,
'haveOp': getHaveOp,
'haveOp+': getHaveOp, # We don't handle modes greater than op.
'haveVoice': getHaveVoice,
'haveVoice+': getHaveVoicePlus,
'hostmask': getHostmask,
'httpUrl': getHttpUrl,
'id': getId,