Avoid doing pointless lookups against numbered networks
This commit is contained in:
parent
9dc202fd53
commit
7d7ef69d98
9
main.py
9
main.py
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue