From 5542635d65bea382ed11855e09e86c04b1744f53 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 25 Jun 2019 07:57:45 -0400 Subject: [PATCH] test uptime --- sopel_modules/SpiceBot/Prerun.py | 20 +++++++++++++++++-- .../SpiceBot_Core_Commands/Uptime.py | 4 +--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8bbcf87..e58615c 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -16,7 +16,23 @@ from .Commands import commands as botcommands from .Database import db as botdb -def prerun(trigger_command_type='module'): +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 actual_decorator(function): @functools.wraps(function) @@ -49,7 +65,7 @@ def prerun(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): - return function(bot, trigger, *args, **kwargs) + function(*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 4bde934..2ad65e4 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Uptime.py +++ b/sopel_modules/SpiceBot_Core_Commands/Uptime.py @@ -2,14 +2,12 @@ from __future__ import unicode_literals, absolute_import, division, print_function -import sopel.module - import time import sopel_modules.SpiceBot as SpiceBot -@sopel.module.nickname_commands('uptime') +@SpiceBot.prerun(['uptime'], 'module') 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)