Avoid doing pointless lookups against numbered networks

This commit is contained in:
Mark Veidemanis 2018-10-14 14:47:08 +01:00
parent 9dc202fd53
commit 7d7ef69d98
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,6 @@
from json import load, dump, loads
import redis
from string import digits
from utils.loaders.command_loader import loadCommands
from utils.logging.log import *
@ -26,6 +27,14 @@ MonitorPool = []
CommandMap = {}
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]))
return networks
def register(command, function):
if not command in CommandMap:
CommandMap[command] = function

View File

@ -10,7 +10,7 @@ def getWhoSingle(name, query):
def getWho(query):
result = {}
for i in main.pool.keys():
for i in main.nets():
f = getWhoSingle(i, query)
if f:
result[i] = f
@ -25,7 +25,7 @@ def getChansSingle(name, nick):
def getChans(nick):
result = {}
for i in main.pool.keys():
for i in main.nets():
f = getChansSingle(i, nick)
if f:
result[i] = f
@ -40,7 +40,7 @@ def getUsersSingle(name, nick):
def getUsers(nick):
result = {}
for i in main.pool.keys():
for i in main.nets():
f = getUsersSingle(i, nick)
if f:
result[i] = f
@ -51,7 +51,7 @@ def getNumWhoEntries(name):
def getNumTotalWhoEntries():
total = 0
for i in main.pool.keys():
for i in main.nets():
total += getNumWhoEntries(i)
return total