--- /dev/null
+# Erebus IRC bot - Author: Erebus Team
+# vim: fileencoding=utf-8
+# This file is released into the public domain; see http://unlicense.org/
+
+import time
+
+# module info
+modinfo = {
+ 'author': 'Erebus Team',
+ 'license': 'public domain',
+ 'compatible': [0], # compatible module API versions
+ 'depends': [], # other modules required to work properly?
+ 'softdeps': ['help'], # modules which are preferred but not required
+}
+
+# preamble
+import modlib
+lib = modlib.modlib(__name__)
+modstart = lib.modstart
+modstop = lib.modstop
+
+# module code
+def _since(when):
+ duration = time.time() - when
+ days, duration = divmod(duration, 60*60*24)
+ hours, duration = divmod(duration, 60*60)
+ minutes, duration = divmod(duration, 60)
+ seconds = duration
+ output = []
+ if days > 0:
+ output += [str(int(days)), "days" if days > 1 else "day"]
+ if hours > 0:
+ output += [str(int(hours)), "hours" if hours > 1 else "hour"]
+ if minutes > 0:
+ output += [str(int(minutes)), "minutes" if minutes > 1 else "minute"]
+ if seconds > 0:
+ output += [str(int(seconds)), "seconds" if seconds > 1 else "second"]
+ return ' '.join(output)
+
+@lib.hook(needchan=False, wantchan=True)
+@lib.help(None, 'identifies which server the bot is connected to')
+def server(bot, user, chan, realtarget, *args):
+ if chan is not None: replyto = chan
+ else: replyto = user
+
+ bot.msg(replyto, "Connected to %s (from %s:%s) since %s UTC" % (bot.servername, bot.server, bot.port, time.asctime(time.gmtime(bot.connecttime))))
+
+@lib.hook(needchan=False, wantchan=True)
+@lib.help(None, 'shows the uptime of the bot')
+def uptime(bot, user, chan, realtarget, *args):
+ if chan is not None: replyto = chan
+ else: replyto = user
+
+ bot.msg(replyto, "This bot has been connected %s (process uptime %s)" % (_since(bot.connecttime), _since(bot.parent.starttime)))