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