]>
jfr.im git - erebus.git/blob - modules/server.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # Utility commands to show info like uptime and current server
4 # This file is released into the public domain; see http://unlicense.org/
10 'author': 'Erebus Team',
11 'license': 'public domain',
12 'compatible': [0], # compatible module API versions
13 'depends': [], # other modules required to work properly?
14 'softdeps': ['help'], # modules which are preferred but not required
19 lib
= modlib
.modlib(__name__
)
20 modstart
= lib
.modstart
25 duration
= time
.time() - when
26 days
, duration
= divmod(duration
, 60*60*24)
27 hours
, duration
= divmod(duration
, 60*60)
28 minutes
, duration
= divmod(duration
, 60)
32 output
+= [str(int(days
)), "days" if days
> 1 else "day"]
34 output
+= [str(int(hours
)), "hours" if hours
> 1 else "hour"]
36 output
+= [str(int(minutes
)), "minutes" if minutes
> 1 else "minute"]
38 output
+= [str(int(seconds
)), "seconds" if seconds
> 1 else "second"]
39 return ' '.join(output
)
41 @lib.hook(needchan
=False, wantchan
=True)
42 @lib.help(None, 'identifies which server the bot is connected to')
43 def server(bot
, user
, chan
, realtarget
, *args
):
44 if chan
is not None: replyto
= chan
47 bot
.msg(replyto
, "Connected to %s (from %s:%s) since %s UTC" % (bot
.servername
, bot
.server
, bot
.port
, time
.asctime(time
.gmtime(bot
.connecttime
))))
49 @lib.hook(needchan
=False, wantchan
=True)
50 @lib.help(None, 'shows the uptime of the bot')
51 def uptime(bot
, user
, chan
, realtarget
, *args
):
52 if chan
is not None: replyto
= chan
55 bot
.msg(replyto
, "This bot has been connected %s (process uptime %s)" % (_since(bot
.connecttime
), _since(bot
.parent
.starttime
)))