mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Aka: Change required capability for (un)locking channel-specific Akas from admin to #channel,op.
This commit is contained in:
parent
b2205bc66d
commit
d699ba18a7
@ -34,6 +34,7 @@ import sys
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
import supybot.ircdb as ircdb
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
@ -378,6 +379,15 @@ class Aka(callbacks.Plugin):
|
|||||||
'channel': 'somethingWithoutSpaces',
|
'channel': 'somethingWithoutSpaces',
|
||||||
}), 'commandName'])
|
}), 'commandName'])
|
||||||
|
|
||||||
|
def _checkManageCapabilities(self, irc, msg, channel):
|
||||||
|
"""Check if the user has any of the required capabilities to manage
|
||||||
|
the regexp database."""
|
||||||
|
if channel != 'global':
|
||||||
|
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||||
|
else:
|
||||||
|
capability = 'admin'
|
||||||
|
if not ircdb.checkCapability(msg.prefix, capability):
|
||||||
|
irc.errorNoCapability(capability, Raise=True)
|
||||||
|
|
||||||
def lock(self, irc, msg, args, optlist, user, name):
|
def lock(self, irc, msg, args, optlist, user, name):
|
||||||
"""[--channel <#channel>] <alias>
|
"""[--channel <#channel>] <alias>
|
||||||
@ -391,6 +401,7 @@ class Aka(callbacks.Plugin):
|
|||||||
irc.error(_('%r is not a valid channel.') % arg,
|
irc.error(_('%r is not a valid channel.') % arg,
|
||||||
Raise=True)
|
Raise=True)
|
||||||
channel = arg
|
channel = arg
|
||||||
|
self._checkManageCapabilities(irc, msg, channel)
|
||||||
try:
|
try:
|
||||||
self._db.lock_aka(channel, name, user.name)
|
self._db.lock_aka(channel, name, user.name)
|
||||||
except AkaError as e:
|
except AkaError as e:
|
||||||
@ -399,7 +410,7 @@ class Aka(callbacks.Plugin):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
lock = wrap(lock, [getopts({
|
lock = wrap(lock, [getopts({
|
||||||
'channel': 'somethingWithoutSpaces',
|
'channel': 'somethingWithoutSpaces',
|
||||||
}), 'admin', 'user', 'commandName'])
|
}), 'user', 'commandName'])
|
||||||
|
|
||||||
def unlock(self, irc, msg, args, optlist, user, name):
|
def unlock(self, irc, msg, args, optlist, user, name):
|
||||||
"""[--channel <#channel>] <alias>
|
"""[--channel <#channel>] <alias>
|
||||||
@ -413,6 +424,7 @@ class Aka(callbacks.Plugin):
|
|||||||
irc.error(_('%r is not a valid channel.') % arg,
|
irc.error(_('%r is not a valid channel.') % arg,
|
||||||
Raise=True)
|
Raise=True)
|
||||||
channel = arg
|
channel = arg
|
||||||
|
self._checkManageCapabilities(irc, msg, channel)
|
||||||
try:
|
try:
|
||||||
self._db.unlock_aka(channel, name, user.name)
|
self._db.unlock_aka(channel, name, user.name)
|
||||||
except AkaError as e:
|
except AkaError as e:
|
||||||
@ -421,7 +433,7 @@ class Aka(callbacks.Plugin):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
unlock = wrap(unlock, [getopts({
|
unlock = wrap(unlock, [getopts({
|
||||||
'channel': 'somethingWithoutSpaces',
|
'channel': 'somethingWithoutSpaces',
|
||||||
}), 'admin', 'user', 'commandName'])
|
}), 'user', 'commandName'])
|
||||||
|
|
||||||
Class = Aka
|
Class = Aka
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user