2016-05-09 15:14:12 +00:00
|
|
|
import time
|
2018-09-24 14:13:27 +00:00
|
|
|
from src import Utils
|
2016-05-09 15:14:12 +00:00
|
|
|
|
|
|
|
class Module(object):
|
2018-09-02 18:54:45 +00:00
|
|
|
def __init__(self, bot, events, exports):
|
2016-05-09 15:14:12 +00:00
|
|
|
self.bot = bot
|
|
|
|
|
2018-09-26 17:27:17 +00:00
|
|
|
@Utils.hook("received.command.uptime")
|
2016-05-09 15:14:12 +00:00
|
|
|
def uptime(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
|
|
|
Show my uptime
|
|
|
|
"""
|
2018-09-11 17:24:34 +00:00
|
|
|
seconds = int(time.time()-self.bot.start_time)
|
2018-08-18 20:54:12 +00:00
|
|
|
event["stdout"].write("Uptime: %s" % Utils.to_pretty_time(
|
|
|
|
seconds))
|
2016-05-09 15:14:12 +00:00
|
|
|
|
2018-09-26 17:27:17 +00:00
|
|
|
@Utils.hook("received.command.stats")
|
2016-05-09 15:14:12 +00:00
|
|
|
def stats(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
|
|
|
Show my network/channel/user stats
|
|
|
|
"""
|
2016-05-09 15:14:12 +00:00
|
|
|
networks = len(self.bot.servers)
|
|
|
|
channels = 0
|
|
|
|
users = 0
|
|
|
|
for server in self.bot.servers.values():
|
|
|
|
channels += len(server.channels)
|
|
|
|
users += len(server.users)
|
|
|
|
|
|
|
|
|
|
|
|
response = "I currently have %d network" % networks
|
|
|
|
if networks > 1:
|
|
|
|
response += "s"
|
|
|
|
response += ", %d channel" % channels
|
|
|
|
if channels > 1:
|
|
|
|
response += "s"
|
|
|
|
response += " and %d visible user" % users
|
|
|
|
if users > 1:
|
|
|
|
response += "s"
|
|
|
|
|
|
|
|
event["stdout"].write(response)
|