from core.main import * class Stats: def __init__(self, register): register("stats", self.stats) def stats(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length): if authed: if length == 1: stats = [] numChannels = 0 numWhoEntries = 0 for i in IRCPool.keys(): numChannels += len(IRCPool[i].channels) for i in wholist.keys(): numWhoEntries += len(wholist[i].keys()) stats.append("Servers: %s" % len(IRCPool.keys())) stats.append("Channels: %s" % numChannels) stats.append("User records: %s" % numWhoEntries) info("\n".join(stats)) return elif length == 2: stats = [] numChannels = 0 numWhoEntries = 0 failures = 0 if spl[1] in IRCPool.keys(): numChannels += len(IRCPool[spl[1]].channels) else: failure("Name does not exist: %s" % spl[1]) failures += 1 if spl[1] in wholist.keys(): numWhoEntries += len(wholist[spl[1]].keys()) else: failure("Who entry does not exist: %s" % spl[1]) failures += 1 if failures == 2: failure("No information found, aborting") return stats.append("Channels: %s" % numChannels) stats.append("User records: %s" % numWhoEntries) info("\n".join(stats)) return else: incUsage("stats") else: incUsage(None)