mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
uptime
This commit is contained in:
parent
75674019c6
commit
b9ba45122b
@ -10,6 +10,7 @@ self-trigger the bot into performing actions
|
||||
import sopel
|
||||
import functools
|
||||
import threading
|
||||
import time
|
||||
|
||||
from .Logs import logs
|
||||
|
||||
@ -34,6 +35,7 @@ class BotEvents(object):
|
||||
def __init__(self):
|
||||
self.lock = threading.Lock()
|
||||
self.RPL_WELCOME = '001' # This is a defined IRC event
|
||||
self.BOT_UPTIME = time.time()
|
||||
self.BOT_WELCOME = '1001'
|
||||
self.BOT_READY = '1002'
|
||||
self.BOT_CONNECTED = '1003'
|
||||
@ -41,7 +43,7 @@ class BotEvents(object):
|
||||
self.BOT_RECONNECTED = '1005'
|
||||
self.defaultevents = [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED, self.BOT_LOADED, self.BOT_RECONNECTED]
|
||||
self.dict = {
|
||||
"assigned_IDs": {1000: "Default", 1001: "BOT_WELCOME", 1002: "BOT_READY", 1003: "BOT_CONNECTED", 1004: "BOT_LOADED", 1005: "BOT_RECONNECTED"},
|
||||
"assigned_IDs": {1000: "BOT_UPTIME", 1001: "BOT_WELCOME", 1002: "BOT_READY", 1003: "BOT_CONNECTED", 1004: "BOT_LOADED", 1005: "BOT_RECONNECTED"},
|
||||
"triggers_recieved": {},
|
||||
"trigger_queue": [],
|
||||
"startup_required": [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED],
|
||||
|
||||
15
sopel_modules/SpiceBot_Core_Commands/Uptime.py
Normal file
15
sopel_modules/SpiceBot_Core_Commands/Uptime.py
Normal file
@ -0,0 +1,15 @@
|
||||
# coding=utf-8
|
||||
|
||||
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')
|
||||
def bot_command_srewyou(bot, trigger):
|
||||
timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago."
|
||||
bot.osd("I have been running since " + timesince)
|
||||
@ -9,6 +9,7 @@ This module contains references only for other modules to utilize.
|
||||
from .Commands import *
|
||||
from .Channels import *
|
||||
from .Database import *
|
||||
from .Uptime import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
# coding=utf-8
|
||||
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
import sopel.module
|
||||
|
||||
import time
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
|
||||
def setup(bot):
|
||||
if 'SpiceBot_Uptime' not in bot.memory:
|
||||
now = time.time()
|
||||
SpiceBot.logs.log('SpiceBot_Uptime', "Start time set to " + str(time.time()))
|
||||
bot.memory["SpiceBot_Uptime"] = now
|
||||
|
||||
|
||||
def shutdown(bot):
|
||||
if "SpiceBot_Uptime" in bot.memory:
|
||||
del bot.memory["SpiceBot_Uptime"]
|
||||
|
||||
|
||||
@sopel.module.nickname_commands('uptime')
|
||||
def bot_command_srewyou(bot, trigger):
|
||||
timesince = str(SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago."
|
||||
bot.osd("I have been running since " + timesince)
|
||||
@ -1,8 +0,0 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .Uptime import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.1'
|
||||
Loading…
Reference in New Issue
Block a user