diff --git a/bot.py b/bot.py index 2a6fb10..387a78d 100755 --- a/bot.py +++ b/bot.py @@ -16,6 +16,7 @@ class Bot(object): print 'Welcome to Cloudbot - Version DEV - http://git.io/cloudbotirc' bot = Bot() +bot.start_time = time.time() print 'Loading plugins...' diff --git a/plugins/system.py b/plugins/system.py index da64d90..352caeb 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,5 +1,6 @@ import os import re +import time import platform import subprocess from util import hook @@ -52,13 +53,11 @@ def memory(inp): @hook.command(autohelp=False) -def uptime(inp): +def uptime(inp, bot=None): ".uptime -- Shows the bot's uptime." - if os.name != "posix": - return "Sorry, this command is not supported on your OS." - up = subprocess.check_output("ps -eo pid,etime | grep %s | awk " \ - "'{print $2}'" % os.getpid(), shell=True) - return "Uptime: \x02%s\x02" % up + uptime_raw = time.time() - bot.start_time + uptime = time.strftime('%H:%M:%S', time.gmtime(uptime_raw)) + return "Uptime: \x02%s\x02" % uptime @hook.command(autohelp=False)