This commit is contained in:
deathbybandaid 2022-02-12 13:15:07 -05:00
parent 3031948e7a
commit fe3929c43c
4 changed files with 14 additions and 49 deletions

View File

@ -6,9 +6,6 @@ from sopel_SpiceBot_Core_1 import sb
def get_commands(bot, trigger): def get_commands(bot, trigger):
commands = [] commands = []
# bot.say(str(sb.config.prefix_list))
# bot.nick
# Get && split for multiple commands # Get && split for multiple commands
if "&&" in trigger.args[1]: if "&&" in trigger.args[1]:
triggers = [x.strip() for x in trigger.args[1].split("&&")] triggers = [x.strip() for x in trigger.args[1].split("&&")]
@ -62,49 +59,17 @@ def get_commands(bot, trigger):
"trigger_str": trigger_str "trigger_str": trigger_str
}) })
bot.say(str(commands)) return commands
return
def prerun_command(): def prerun():
def actual_decorator(function): def actual_decorator(function):
@functools.wraps(function) @functools.wraps(function)
def internal_prerun(bot, trigger, *args, **kwargs): def internal_prerun(bot, trigger, *args, **kwargs):
get_commands(bot, trigger) commands = get_commands(bot, trigger)
function(bot, trigger, *args, **kwargs)
return internal_prerun
return actual_decorator
def prerun_nickname_command():
def actual_decorator(function):
@functools.wraps(function)
def internal_prerun(bot, trigger, *args, **kwargs):
get_commands(bot, trigger)
function(bot, trigger, *args, **kwargs)
return internal_prerun
return actual_decorator
def prerun_action_command():
def actual_decorator(function):
@functools.wraps(function)
def internal_prerun(bot, trigger, *args, **kwargs):
get_commands(bot, trigger)
function(bot, trigger, *args, **kwargs) function(bot, trigger, *args, **kwargs)

View File

@ -4,10 +4,10 @@ from sopel import plugin
from sopel_SpiceBot_Core_1 import sb from sopel_SpiceBot_Core_1 import sb
from sopel_SpiceBot_Core_Prerun import prerun_action_command from sopel_SpiceBot_Core_Prerun import prerun
@prerun_action_command() @prerun()
@plugin.action_command('test') @plugin.action_command('test')
def sb_test_commands(bot, trigger): def sb_test_commands(bot, trigger):
bot.say("%s" % trigger.raw) bot.say("%s" % trigger.raw)

View File

@ -4,10 +4,10 @@ from sopel import plugin
from sopel_SpiceBot_Core_1 import sb from sopel_SpiceBot_Core_1 import sb
from sopel_SpiceBot_Core_Prerun import prerun_command from sopel_SpiceBot_Core_Prerun import prerun
@prerun_command() @prerun()
@plugin.command('test') @plugin.command('test')
def commands_test(bot, trigger): def commands_test(bot, trigger):
bot.say("%s" % trigger.raw) bot.say("%s" % trigger.raw)
@ -15,7 +15,7 @@ def commands_test(bot, trigger):
bot.say("%s" % trigger.args[1]) bot.say("%s" % trigger.args[1])
@prerun_command() @prerun()
@plugin.command('testa') @plugin.command('testa')
def commands_test_a(bot, trigger): def commands_test_a(bot, trigger):
bot.say("test a") bot.say("test a")
@ -25,7 +25,7 @@ def commands_test_a(bot, trigger):
bot.say("test a: %s" % trigger.raw) bot.say("test a: %s" % trigger.raw)
@prerun_command() @prerun()
@plugin.command('testb') @plugin.command('testb')
def commands_test_b(bot, trigger): def commands_test_b(bot, trigger):

View File

@ -4,10 +4,10 @@ from sopel import plugin
from sopel_SpiceBot_Core_1 import sb from sopel_SpiceBot_Core_1 import sb
from sopel_SpiceBot_Core_Prerun import prerun_nickname_command from sopel_SpiceBot_Core_Prerun import prerun
@prerun_nickname_command() @prerun()
@plugin.nickname_command('test') @plugin.nickname_command('test')
def sb_test_commands(bot, trigger): def sb_test_commands(bot, trigger):
bot.say("%s" % trigger.raw) bot.say("%s" % trigger.raw)
@ -15,7 +15,7 @@ def sb_test_commands(bot, trigger):
bot.say("%s" % trigger.args[1]) bot.say("%s" % trigger.args[1])
@prerun_nickname_command() @prerun()
@plugin.nickname_command('commands') @plugin.nickname_command('commands')
def sopel_commands(bot, trigger): def sopel_commands(bot, trigger):
@ -24,7 +24,7 @@ def sopel_commands(bot, trigger):
bot.say(str(bot.rules._rules.values())) bot.say(str(bot.rules._rules.values()))
@prerun_nickname_command() @prerun()
@plugin.nickname_command('nickname_commands') @plugin.nickname_command('nickname_commands')
def sopel_nickname_commands(bot, trigger): def sopel_nickname_commands(bot, trigger):
bot.say("testing nickname_commands") bot.say("testing nickname_commands")
@ -34,7 +34,7 @@ def sopel_nickname_commands(bot, trigger):
bot.say(str(y)) bot.say(str(y))
@prerun_nickname_command() @prerun()
@plugin.nickname_command('action_commands') @plugin.nickname_command('action_commands')
def sopel_action_commands(bot, trigger): def sopel_action_commands(bot, trigger):