From d515592fef69be2d14e880add304f38fb0ada2ff Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Fri, 8 Aug 2014 16:04:30 +0200 Subject: [PATCH] [uptime] Adds a rudimentary uptime module which tells how long the bot is running. --- willie/modules/uptime.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 willie/modules/uptime.py diff --git a/willie/modules/uptime.py b/willie/modules/uptime.py new file mode 100644 index 0000000000..8c03fdeb2e --- /dev/null +++ b/willie/modules/uptime.py @@ -0,0 +1,27 @@ +# coding=utf8 +""" +uptime.py - Uptime module +Copyright 2014, Fabian Neundorf +Licensed under the Eiffel Forum License 2. + +http://willie.dftba.net +""" +from __future__ import unicode_literals + +from willie.module import commands +import datetime + + +def setup(bot): + if "uptime" not in bot.memory: + bot.memory["uptime"] = datetime.datetime.utcnow() + + +@commands('uptime') +def uptime(bot, trigger): + """.uptime - Returns the uptime of Willie.""" + delta = datetime.timedelta(seconds=round((datetime.datetime.utcnow() - + bot.memory["uptime"]) + .total_seconds())) + bot.say("I've been sitting here for {} and I keep " + "going!".format(delta))