Skip to content

Commit

Permalink
[uptime] Adds a rudimentary uptime module which tells how long the
Browse files Browse the repository at this point in the history
bot is running.
  • Loading branch information
xZise committed Aug 8, 2014
1 parent 9604bfc commit d515592
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions willie/modules/uptime.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit d515592

Please sign in to comment.