-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #589 from xZise/uptime-module
Adds a rudimentary uptime module
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |