test
This commit is contained in:
parent
8ac47082a9
commit
00f75a4530
@ -3,6 +3,62 @@ import functools
|
||||
from sopel_SpiceBot_Core_1 import sb
|
||||
|
||||
|
||||
def dispatch():
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@functools.wraps(function)
|
||||
def internal_dispatch(bot, trigger, *args, **kwargs):
|
||||
|
||||
bot.say("dispatch")
|
||||
|
||||
# Get list of trigger command(s)
|
||||
commands = get_commands(bot, trigger)
|
||||
|
||||
# If more than 1 trigger command, dispatch
|
||||
if len(commands) > 1:
|
||||
for trigger_dict in commands:
|
||||
sb.commands.dispatch(bot, trigger, trigger_dict)
|
||||
return
|
||||
|
||||
function(bot, trigger, *args, **kwargs)
|
||||
|
||||
return internal_dispatch
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def command_args():
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@functools.wraps(function)
|
||||
def internal_command_args(bot, trigger, *args, **kwargs):
|
||||
|
||||
bot.say("command_args")
|
||||
|
||||
function(bot, trigger, *args, **kwargs)
|
||||
|
||||
return internal_command_args
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def prerun():
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@dispatch()
|
||||
@command_args()
|
||||
@functools.wraps(function)
|
||||
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||
|
||||
bot.say("prerun")
|
||||
|
||||
function(bot, trigger, *args, **kwargs)
|
||||
|
||||
return internal_prerun
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def get_commands(bot, trigger):
|
||||
commands = []
|
||||
|
||||
@ -102,59 +158,3 @@ def get_commands(bot, trigger):
|
||||
})
|
||||
|
||||
return commands
|
||||
|
||||
|
||||
def dispatch():
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@functools.wraps(function)
|
||||
def internal_dispatch(bot, trigger, *args, **kwargs):
|
||||
|
||||
bot.say("dispatch")
|
||||
|
||||
# Get list of trigger command(s)
|
||||
commands = get_commands(bot, trigger)
|
||||
|
||||
# If more than 1 trigger command, dispatch
|
||||
if len(commands) > 1:
|
||||
for trigger_dict in commands:
|
||||
sb.commands.dispatch(bot, trigger, trigger_dict)
|
||||
return
|
||||
|
||||
function(bot, trigger, *args, **kwargs)
|
||||
|
||||
return internal_dispatch
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def command_args():
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@functools.wraps(function)
|
||||
def internal_command_args(bot, trigger, *args, **kwargs):
|
||||
|
||||
bot.say("command_args")
|
||||
|
||||
function(bot, trigger, *args, **kwargs)
|
||||
|
||||
return internal_command_args
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def prerun():
|
||||
|
||||
def actual_decorator(function):
|
||||
|
||||
@dispatch()
|
||||
@command_args()
|
||||
@functools.wraps(function)
|
||||
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||
|
||||
bot.say("prerun")
|
||||
|
||||
function(bot, trigger, *args, **kwargs)
|
||||
|
||||
return internal_prerun
|
||||
return actual_decorator
|
||||
|
||||
Loading…
Reference in New Issue
Block a user