diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index e58615c..b16fe7a 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -16,30 +16,12 @@ from .Commands import commands as botcommands from .Database import db as botdb -def prerun(command_list, trigger_command_type='module'): - - if trigger_command_type == 'nickname': - def add_attribute(function): - if not hasattr(function, "nickname_commands"): - function.nickname_commands = [] - function.nickname_commands.extend(command_list) - return function - return add_attribute - else: - def add_attribute(function): - if not hasattr(function, "commands"): - function.commands = [] - function.commands.extend(command_list) - return function - return add_attribute +def prerun(trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) - def internal_prerun(*args, **kwargs): - - # Assign trigger and bot for easy access later - bot, trigger = args[0:2] + def internal_prerun(bot, trigger, *args, **kwargs): # Primary command used for trigger, and a list of all words trigger_args, trigger_command = make_trigger_args(trigger.args[1], trigger_command_type) @@ -65,7 +47,7 @@ def prerun(command_list, trigger_command_type='module'): if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command if trigger_runstatus(bot, trigger): - function(*args, **kwargs) + function(bot, trigger, *args, **kwargs) else: trigger_hyphen_arg_handler(bot, trigger) diff --git a/sopel_modules/SpiceBot_Core_Commands/Uptime.py b/sopel_modules/SpiceBot_Core_Commands/Uptime.py index 2ad65e4..4bde934 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Uptime.py +++ b/sopel_modules/SpiceBot_Core_Commands/Uptime.py @@ -2,12 +2,14 @@ from __future__ import unicode_literals, absolute_import, division, print_function +import sopel.module + import time import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.prerun(['uptime'], 'module') +@sopel.module.nickname_commands('uptime') def bot_command_uptime(bot, trigger): timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago." bot.osd("I have been running since " + timesince)