Make the stats command aware of duplicate networks
This commit is contained in:
parent
7cd6bc3616
commit
3bf361134f
|
@ -1,6 +1,7 @@
|
|||
import main
|
||||
import modules.counters as count
|
||||
import modules.userinfo as userinfo
|
||||
from string import digits
|
||||
|
||||
class Stats:
|
||||
def __init__(self, register):
|
||||
|
@ -15,8 +16,12 @@ class Stats:
|
|||
for i in main.IRCPool.keys():
|
||||
numChannels += len(main.IRCPool[i].channels)
|
||||
numWhoEntries += userinfo.getNumTotalWhoEntries()
|
||||
stats.append("Servers: %s" % len(main.pool.keys()))
|
||||
stats.append("Online servers: %s" % len(main.IRCPool.keys()))
|
||||
stats.append("Registered servers:")
|
||||
stats.append(" Total: %s" % len(main.pool.keys()))
|
||||
stats.append(" Unique: %s" % len(main.nets()))
|
||||
stats.append("Online servers:")
|
||||
stats.append(" Total: %s" % len(main.IRCPool.keys()))
|
||||
stats.append(" Unique: %s" % len(main.liveNets()))
|
||||
stats.append("Channels: %s" % numChannels)
|
||||
stats.append("User records: %s" % numWhoEntries)
|
||||
counterEvents = count.getEvents()
|
||||
|
@ -33,14 +38,20 @@ class Stats:
|
|||
stats = []
|
||||
numChannels = 0
|
||||
numWhoEntries = 0
|
||||
found = False
|
||||
numNodes = 0
|
||||
|
||||
if spl[1] in main.IRCPool.keys():
|
||||
numChannels += len(main.IRCPool[spl[1]].channels)
|
||||
else:
|
||||
for i in main.IRCPool.keys():
|
||||
if "".join([x for x in i if not x in digits]) == spl[1]:
|
||||
numChannels += len(main.IRCPool[spl[1]].channels)
|
||||
found = True
|
||||
numNodes += 1
|
||||
if not found:
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
numWhoEntries += userinfo.getNumWhoEntries(spl[1])
|
||||
stats.append("Channels: %s" % numChannels)
|
||||
stats.append("User records: %s" % numWhoEntries)
|
||||
stats.append("Endpoints: %s" % numNodes)
|
||||
counterEvents = count.getEvents(spl[1])
|
||||
if counterEvents == None:
|
||||
stats.append("No counters records")
|
||||
|
|
|
@ -76,7 +76,7 @@ class IRCBot(IRCClient):
|
|||
|
||||
def privmsg(self, user, channel, msg):
|
||||
nick, ident, host = self.parsen(user)
|
||||
userinfo.editUser(self.net, channel, nick, user)
|
||||
#userinfo.editUser(self.net, channel, nick, user)
|
||||
count.event(self.net, "privmsg")
|
||||
|
||||
keyword.actKeyword(user, channel, msg, self.nickname, "MSG", self.name)
|
||||
|
|
10
main.py
10
main.py
|
@ -31,8 +31,14 @@ def nets():
|
|||
if not "pool" in globals():
|
||||
return
|
||||
networks = set()
|
||||
for i in pool:
|
||||
networks.add("".join([x for x in i if not i in digits]))
|
||||
for i in pool.keys():
|
||||
networks.add("".join([x for x in i if not x in digits]))
|
||||
return networks
|
||||
|
||||
def liveNets():
|
||||
networks = set()
|
||||
for i in IRCPool.keys():
|
||||
networks.add("".join([x for x in i if not x in digits]))
|
||||
return networks
|
||||
|
||||
def register(command, function):
|
||||
|
|
Loading…
Reference in New Issue