mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 12:12:54 +01:00
Add class attribute callbacks.Commands.pre_command_callbacks.
This commit is contained in:
parent
ebde072f39
commit
3a5c4c3ddd
@ -1150,6 +1150,7 @@ class Commands(BasePlugin):
|
|||||||
commandArgs = ['self', 'irc', 'msg', 'args']
|
commandArgs = ['self', 'irc', 'msg', 'args']
|
||||||
# These must be class-scope, so all plugins use the same one.
|
# These must be class-scope, so all plugins use the same one.
|
||||||
_disabled = DisabledCommands()
|
_disabled = DisabledCommands()
|
||||||
|
pre_command_callbacks = []
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.__class__.__name__
|
return self.__class__.__name__
|
||||||
|
|
||||||
@ -1243,6 +1244,10 @@ class Commands(BasePlugin):
|
|||||||
return L
|
return L
|
||||||
|
|
||||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||||
|
# We run all callbacks before checking if one of them returned True
|
||||||
|
if any(bool, list(cb(command, irc, msg, *args, **kwargs)
|
||||||
|
for cb in self.pre_command_callbacks)):
|
||||||
|
return
|
||||||
method = self.getCommandMethod(command)
|
method = self.getCommandMethod(command)
|
||||||
method(irc, msg, *args, **kwargs)
|
method(irc, msg, *args, **kwargs)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user