mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test uptime
This commit is contained in:
parent
09133221a4
commit
5542635d65
@ -16,7 +16,23 @@ from .Commands import commands as botcommands
|
|||||||
from .Database import db as botdb
|
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):
|
def actual_decorator(function):
|
||||||
|
|
||||||
@functools.wraps(function)
|
@functools.wraps(function)
|
||||||
@ -49,7 +65,7 @@ def prerun(trigger_command_type='module'):
|
|||||||
if not trigger.sb["hyphen_arg"]:
|
if not trigger.sb["hyphen_arg"]:
|
||||||
# check if anything prohibits the nick from running the command
|
# check if anything prohibits the nick from running the command
|
||||||
if trigger_runstatus(bot, trigger):
|
if trigger_runstatus(bot, trigger):
|
||||||
return function(bot, trigger, *args, **kwargs)
|
function(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
trigger_hyphen_arg_handler(bot, trigger)
|
trigger_hyphen_arg_handler(bot, trigger)
|
||||||
|
|
||||||
|
|||||||
@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.nickname_commands('uptime')
|
@SpiceBot.prerun(['uptime'], 'module')
|
||||||
def bot_command_uptime(bot, trigger):
|
def bot_command_uptime(bot, trigger):
|
||||||
timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago."
|
timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago."
|
||||||
bot.osd("I have been running since " + timesince)
|
bot.osd("I have been running since " + timesince)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user