mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Core & Channel & Topic: Add the isGranted converter. Closes GH-39.
This commit is contained in:
parent
d4693ebb69
commit
41514bafdd
@ -73,7 +73,7 @@ class Channel(callbacks.Plugin):
|
|||||||
itself.
|
itself.
|
||||||
"""
|
"""
|
||||||
self._sendMsg(irc, ircmsgs.mode(channel, modes))
|
self._sendMsg(irc, ircmsgs.mode(channel, modes))
|
||||||
mode = wrap(mode, ['op', ('haveOp', _('change the mode')), many('something')])
|
mode = wrap(mode, ['op', ('isGranted', _('change the mode')), many('something')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def limit(self, irc, msg, args, channel, limit):
|
def limit(self, irc, msg, args, channel, limit):
|
||||||
@ -99,7 +99,7 @@ class Channel(callbacks.Plugin):
|
|||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
self._sendMsg(irc, ircmsgs.mode(channel, ['+m']))
|
self._sendMsg(irc, ircmsgs.mode(channel, ['+m']))
|
||||||
moderate = wrap(moderate, ['op', ('haveOp', _('moderate the channel'))])
|
moderate = wrap(moderate, ['op', ('isGranted', _('moderate the channel'))])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def unmoderate(self, irc, msg, args, channel):
|
def unmoderate(self, irc, msg, args, channel):
|
||||||
@ -110,7 +110,7 @@ class Channel(callbacks.Plugin):
|
|||||||
message isn't sent in the channel itself.
|
message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
self._sendMsg(irc, ircmsgs.mode(channel, ['-m']))
|
self._sendMsg(irc, ircmsgs.mode(channel, ['-m']))
|
||||||
unmoderate = wrap(unmoderate, ['op', ('haveOp',
|
unmoderate = wrap(unmoderate, ['op', ('isGranted',
|
||||||
_('unmoderate the channel'))])
|
_('unmoderate the channel'))])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
@ -127,7 +127,7 @@ class Channel(callbacks.Plugin):
|
|||||||
self._sendMsg(irc, ircmsgs.mode(channel, ['+k', key]))
|
self._sendMsg(irc, ircmsgs.mode(channel, ['+k', key]))
|
||||||
else:
|
else:
|
||||||
self._sendMsg(irc, ircmsgs.mode(channel, ['-k']))
|
self._sendMsg(irc, ircmsgs.mode(channel, ['-k']))
|
||||||
key = wrap(key, ['op', ('haveOp', _('change the keyword')),
|
key = wrap(key, ['op', ('isGranted', _('change the keyword')),
|
||||||
additional('somethingWithoutSpaces', '')])
|
additional('somethingWithoutSpaces', '')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
@ -187,7 +187,7 @@ class Channel(callbacks.Plugin):
|
|||||||
self._sendMsgs(irc, nicks, f)
|
self._sendMsgs(irc, nicks, f)
|
||||||
else:
|
else:
|
||||||
irc.errorNoCapability(capability)
|
irc.errorNoCapability(capability)
|
||||||
voice = wrap(voice, ['channel', ('haveOp', _('voice someone')),
|
voice = wrap(voice, ['channel', ('isGranted', _('voice someone')),
|
||||||
any('nickInChannel')])
|
any('nickInChannel')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
@ -247,7 +247,7 @@ class Channel(callbacks.Plugin):
|
|||||||
def f(L):
|
def f(L):
|
||||||
return ircmsgs.devoices(channel, L)
|
return ircmsgs.devoices(channel, L)
|
||||||
self._sendMsgs(irc, nicks, f)
|
self._sendMsgs(irc, nicks, f)
|
||||||
devoice = wrap(devoice, ['voice', ('haveOp', 'devoice someone'),
|
devoice = wrap(devoice, ['voice', ('isGranted', 'devoice someone'),
|
||||||
any('nickInChannel')])
|
any('nickInChannel')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
@ -283,7 +283,7 @@ class Channel(callbacks.Plugin):
|
|||||||
Raise=True)
|
Raise=True)
|
||||||
for nick in nicks:
|
for nick in nicks:
|
||||||
self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
|
self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
|
||||||
kick = wrap(kick, ['op', ('haveOp', _('kick someone')),
|
kick = wrap(kick, ['op', ('isGranted', _('kick someone')),
|
||||||
commalist('nickInChannel'), additional('text')])
|
commalist('nickInChannel'), additional('text')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
@ -361,7 +361,7 @@ class Channel(callbacks.Plugin):
|
|||||||
kban = wrap(kban,
|
kban = wrap(kban,
|
||||||
['op',
|
['op',
|
||||||
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
|
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
|
||||||
('haveOp', _('kick or ban someone')),
|
('isGranted', _('kick or ban someone')),
|
||||||
'nickInChannel',
|
'nickInChannel',
|
||||||
optional('expiry', 0),
|
optional('expiry', 0),
|
||||||
additional('text')])
|
additional('text')])
|
||||||
@ -392,7 +392,7 @@ class Channel(callbacks.Plugin):
|
|||||||
irc.error(_('No bans matching %s were found on %s.') %
|
irc.error(_('No bans matching %s were found on %s.') %
|
||||||
(msg.prefix, channel))
|
(msg.prefix, channel))
|
||||||
unban = wrap(unban, ['op',
|
unban = wrap(unban, ['op',
|
||||||
('haveOp', _('unban someone')),
|
('isGranted', _('unban someone')),
|
||||||
additional('hostmask')])
|
additional('hostmask')])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
@ -406,7 +406,7 @@ class Channel(callbacks.Plugin):
|
|||||||
nick = nick or msg.nick
|
nick = nick or msg.nick
|
||||||
self._sendMsg(irc, ircmsgs.invite(nick, channel))
|
self._sendMsg(irc, ircmsgs.invite(nick, channel))
|
||||||
self.invites[(irc.getRealIrc(), ircutils.toLower(nick))] = irc
|
self.invites[(irc.getRealIrc(), ircutils.toLower(nick))] = irc
|
||||||
invite = wrap(invite, ['op', ('haveOp', _('invite someone')),
|
invite = wrap(invite, ['op', ('isGranted', _('invite someone')),
|
||||||
additional('nick')])
|
additional('nick')])
|
||||||
|
|
||||||
def do341(self, irc, msg):
|
def do341(self, irc, msg):
|
||||||
|
@ -479,7 +479,7 @@ class Topic(callbacks.Plugin):
|
|||||||
irc.errorNoCapability(capabilities, Raise=True)
|
irc.errorNoCapability(capabilities, Raise=True)
|
||||||
irc.queueMsg(ircmsgs.mode(channel, '+t'))
|
irc.queueMsg(ircmsgs.mode(channel, '+t'))
|
||||||
irc.noReply()
|
irc.noReply()
|
||||||
lock = wrap(lock, ['channel', ('haveOp', _('lock the topic'))])
|
lock = wrap(lock, ['channel', ('isGranted', _('lock the topic'))])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def unlock(self, irc, msg, args, channel):
|
def unlock(self, irc, msg, args, channel):
|
||||||
@ -493,7 +493,7 @@ class Topic(callbacks.Plugin):
|
|||||||
irc.errorNoCapability(capabilities, Raise=True)
|
irc.errorNoCapability(capabilities, Raise=True)
|
||||||
irc.queueMsg(ircmsgs.mode(channel, '-t'))
|
irc.queueMsg(ircmsgs.mode(channel, '-t'))
|
||||||
irc.noReply()
|
irc.noReply()
|
||||||
unlock = wrap(unlock, ['channel', ('haveOp', _('unlock the topic'))])
|
unlock = wrap(unlock, ['channel', ('isGranted', _('unlock the topic'))])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def restore(self, irc, msg, args, channel):
|
def restore(self, irc, msg, args, channel):
|
||||||
|
@ -252,6 +252,22 @@ def getNetworkIrc(irc, msg, args, state, errorIfNoMatch=False):
|
|||||||
else:
|
else:
|
||||||
state.args.append(irc)
|
state.args.append(irc)
|
||||||
|
|
||||||
|
def getHaveVoice(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].isVoice(irc.nick):
|
||||||
|
state.error(_('I need to be voiced to %s.') % action, Raise=True)
|
||||||
|
|
||||||
|
def getHaveHalfop(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].isHalfop(irc.nick):
|
||||||
|
state.error(_('I need to be halfopped to %s.') % action, Raise=True)
|
||||||
|
|
||||||
def getHaveOp(irc, msg, args, state, action=_('do that')):
|
def getHaveOp(irc, msg, args, state, action=_('do that')):
|
||||||
if not state.channel:
|
if not state.channel:
|
||||||
getChannel(irc, msg, args, state)
|
getChannel(irc, msg, args, state)
|
||||||
@ -260,6 +276,17 @@ def getHaveOp(irc, msg, args, state, action=_('do that')):
|
|||||||
if not irc.state.channels[state.channel].isOp(irc.nick):
|
if not irc.state.channels[state.channel].isOp(irc.nick):
|
||||||
state.error(_('I need to be opped to %s.') % action, Raise=True)
|
state.error(_('I need to be opped to %s.') % action, Raise=True)
|
||||||
|
|
||||||
|
def getIsGranted(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):
|
||||||
|
# isOp includes owners and protected users
|
||||||
|
state.error(_('I need to be at least halfopped to %s.') % action,
|
||||||
|
Raise=True)
|
||||||
|
|
||||||
def validChannel(irc, msg, args, state):
|
def validChannel(irc, msg, args, state):
|
||||||
if irc.isChannel(args[0]):
|
if irc.isChannel(args[0]):
|
||||||
state.args.append(args.pop(0))
|
state.args.append(args.pop(0))
|
||||||
@ -591,6 +618,8 @@ wrappers = ircutils.IrcDict({
|
|||||||
'banmask': getBanmask,
|
'banmask': getBanmask,
|
||||||
'boolean': getBoolean,
|
'boolean': getBoolean,
|
||||||
'callerInGivenChannel': callerInGivenChannel,
|
'callerInGivenChannel': callerInGivenChannel,
|
||||||
|
'isGranted': getIsGranted, # I know this name sucks, but I can't find
|
||||||
|
# something better
|
||||||
'capability': getSomethingNoSpaces,
|
'capability': getSomethingNoSpaces,
|
||||||
'channel': getChannel,
|
'channel': getChannel,
|
||||||
'channelDb': getChannelDb,
|
'channelDb': getChannelDb,
|
||||||
@ -605,7 +634,9 @@ wrappers = ircutils.IrcDict({
|
|||||||
'float': getFloat,
|
'float': getFloat,
|
||||||
'glob': getGlob,
|
'glob': getGlob,
|
||||||
'halfop': getHalfop,
|
'halfop': getHalfop,
|
||||||
|
'haveHalfop': getHaveHalfop
|
||||||
'haveOp': getHaveOp,
|
'haveOp': getHaveOp,
|
||||||
|
'haveVoice': getHaveVoice
|
||||||
'hostmask': getHostmask,
|
'hostmask': getHostmask,
|
||||||
'httpUrl': getHttpUrl,
|
'httpUrl': getHttpUrl,
|
||||||
'id': getId,
|
'id': getId,
|
||||||
|
Loading…
Reference in New Issue
Block a user