test uptime

This commit is contained in:
deathbybandaid 2019-06-25 07:57:45 -04:00
parent 09133221a4
commit 5542635d65
2 changed files with 19 additions and 5 deletions

View File

@ -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)

View File

@ -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)