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
|
from json import load, dump, loads
|
||||||
import redis
|
import redis
|
||||||
|
from string import digits
|
||||||
from utils.loaders.command_loader import loadCommands
|
from utils.loaders.command_loader import loadCommands
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
|
|
||||||
|
@ -26,6 +27,14 @@ MonitorPool = []
|
||||||
|
|
||||||
CommandMap = {}
|
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):
|
def register(command, function):
|
||||||
if not command in CommandMap:
|
if not command in CommandMap:
|
||||||
CommandMap[command] = function
|
CommandMap[command] = function
|
||||||
|
|
|
@ -10,7 +10,7 @@ def getWhoSingle(name, query):
|
||||||
|
|
||||||
def getWho(query):
|
def getWho(query):
|
||||||
result = {}
|
result = {}
|
||||||
for i in main.pool.keys():
|
for i in main.nets():
|
||||||
f = getWhoSingle(i, query)
|
f = getWhoSingle(i, query)
|
||||||
if f:
|
if f:
|
||||||
result[i] = f
|
result[i] = f
|
||||||
|
@ -25,7 +25,7 @@ def getChansSingle(name, nick):
|
||||||
|
|
||||||
def getChans(nick):
|
def getChans(nick):
|
||||||
result = {}
|
result = {}
|
||||||
for i in main.pool.keys():
|
for i in main.nets():
|
||||||
f = getChansSingle(i, nick)
|
f = getChansSingle(i, nick)
|
||||||
if f:
|
if f:
|
||||||
result[i] = f
|
result[i] = f
|
||||||
|
@ -40,7 +40,7 @@ def getUsersSingle(name, nick):
|
||||||
|
|
||||||
def getUsers(nick):
|
def getUsers(nick):
|
||||||
result = {}
|
result = {}
|
||||||
for i in main.pool.keys():
|
for i in main.nets():
|
||||||
f = getUsersSingle(i, nick)
|
f = getUsersSingle(i, nick)
|
||||||
if f:
|
if f:
|
||||||
result[i] = f
|
result[i] = f
|
||||||
|
@ -51,7 +51,7 @@ def getNumWhoEntries(name):
|
||||||
|
|
||||||
def getNumTotalWhoEntries():
|
def getNumTotalWhoEntries():
|
||||||
total = 0
|
total = 0
|
||||||
for i in main.pool.keys():
|
for i in main.nets():
|
||||||
total += getNumWhoEntries(i)
|
total += getNumWhoEntries(i)
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue