mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-04 08:34:11 +01:00
Add support for (anti)capabilities for multi-words commands. Closes GH-1140.
This commit is contained in:
parent
4498548cb3
commit
a99e674b88
@ -380,7 +380,8 @@ def formatCommand(command):
|
|||||||
return ' '.join(command)
|
return ' '.join(command)
|
||||||
|
|
||||||
def checkCommandCapability(msg, cb, commandName):
|
def checkCommandCapability(msg, cb, commandName):
|
||||||
assert isinstance(commandName, minisix.string_types), commandName
|
if not isinstance(commandName, minisix.string_types):
|
||||||
|
commandName = '.'.join(commandName)
|
||||||
plugin = cb.name().lower()
|
plugin = cb.name().lower()
|
||||||
pluginCommand = '%s.%s' % (plugin, commandName)
|
pluginCommand = '%s.%s' % (plugin, commandName)
|
||||||
def checkCapability(capability):
|
def checkCapability(capability):
|
||||||
@ -493,7 +494,6 @@ class RichReplyMethods(object):
|
|||||||
def errorNoCapability(self, capability, s='', **kwargs):
|
def errorNoCapability(self, capability, s='', **kwargs):
|
||||||
if 'Raise' not in kwargs:
|
if 'Raise' not in kwargs:
|
||||||
kwargs['Raise'] = True
|
kwargs['Raise'] = True
|
||||||
if isinstance(capability, minisix.string_types): # checkCommandCapability!
|
|
||||||
log.warning('Denying %s for lacking %q capability.',
|
log.warning('Denying %s for lacking %q capability.',
|
||||||
self.msg.prefix, capability)
|
self.msg.prefix, capability)
|
||||||
# noCapability means "don't send a specific capability error
|
# noCapability means "don't send a specific capability error
|
||||||
@ -511,11 +511,6 @@ class RichReplyMethods(object):
|
|||||||
s = self.__makeReply(v, s)
|
s = self.__makeReply(v, s)
|
||||||
if s:
|
if s:
|
||||||
return self._error(s, **kwargs)
|
return self._error(s, **kwargs)
|
||||||
else:
|
|
||||||
log.warning('Denying %s for some unspecified capability '
|
|
||||||
'(or a default).', self.msg.prefix)
|
|
||||||
v = self._getConfig(conf.supybot.replies.genericNoCapability)
|
|
||||||
return self._error(self.__makeReply(v, s), **kwargs)
|
|
||||||
|
|
||||||
def errorPossibleBug(self, s='', **kwargs):
|
def errorPossibleBug(self, s='', **kwargs):
|
||||||
v = self._getConfig(conf.supybot.replies.possibleBug)
|
v = self._getConfig(conf.supybot.replies.possibleBug)
|
||||||
@ -1261,6 +1256,10 @@ class Commands(BasePlugin, SynchronizedAndFirewalled):
|
|||||||
# XXX I'm being extra-special-careful here, but we need to refactor
|
# XXX I'm being extra-special-careful here, but we need to refactor
|
||||||
# this.
|
# this.
|
||||||
try:
|
try:
|
||||||
|
cap = checkCommandCapability(msg, self, command)
|
||||||
|
if cap:
|
||||||
|
irc.errorNoCapability(cap)
|
||||||
|
return
|
||||||
for name in command:
|
for name in command:
|
||||||
cap = checkCommandCapability(msg, self, name)
|
cap = checkCommandCapability(msg, self, name)
|
||||||
if cap:
|
if cap:
|
||||||
|
Loading…
Reference in New Issue
Block a user