Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
from core.main import *
|
||||
import main
|
||||
|
||||
def event(name, eventType):
|
||||
if not "local" in counters.keys():
|
||||
counters["local"] = {}
|
||||
if not "global" in counters.keys():
|
||||
counters["global"] = {}
|
||||
if not name in counters["local"].keys():
|
||||
counters["local"][name] = {}
|
||||
if eventType not in counters["local"][name].keys():
|
||||
counters["local"][name][eventType] = 0
|
||||
if not "local" in main.counters.keys():
|
||||
main.counters["local"] = {}
|
||||
if not "global" in main.counters.keys():
|
||||
main.counters["global"] = {}
|
||||
if not name in main.counters["local"].keys():
|
||||
main.counters["local"][name] = {}
|
||||
if eventType not in main.counters["local"][name].keys():
|
||||
main.counters["local"][name][eventType] = 0
|
||||
|
||||
if eventType not in counters["global"]:
|
||||
counters["global"][eventType] = 0
|
||||
if eventType not in main.counters["global"]:
|
||||
main.counters["global"][eventType] = 0
|
||||
|
||||
counters["local"][name][eventType] += 1
|
||||
counters["global"][eventType] += 1
|
||||
main.counters["local"][name][eventType] += 1
|
||||
main.counters["global"][eventType] += 1
|
||||
|
||||
def getEvents(name=None):
|
||||
if name == None:
|
||||
if "global" in counters.keys():
|
||||
return counters["global"]
|
||||
if "global" in main.counters.keys():
|
||||
return main.counters["global"]
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
if name in counters["local"].keys():
|
||||
return counters["local"][name]
|
||||
if name in main.counters["local"].keys():
|
||||
return main.counters["local"][name]
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
from core.main import *
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
import modules.counters as count
|
||||
|
||||
def sendMaster(data):
|
||||
if not len(MonitorPool) == 0:
|
||||
if not len(main.MonitorPool) == 0:
|
||||
hasMonitors = True
|
||||
else:
|
||||
hasMonitors = False
|
||||
|
||||
if config["Master"] == [None, None]:
|
||||
if main.config["Master"] == [None, None]:
|
||||
if hasMonitors:
|
||||
for i in MonitorPool:
|
||||
connections[i].send(data)
|
||||
for i in main.MonitorPool:
|
||||
main.connections[i].send(data)
|
||||
return
|
||||
else:
|
||||
masterbuf.append(data)
|
||||
saveConf("masterbuf")
|
||||
main.masterbuf.append(data)
|
||||
main.saveConf("masterbuf")
|
||||
return
|
||||
|
||||
if config["Master"][0] in IRCPool.keys():
|
||||
if config["Master"][1] in IRCPool[config["Master"][0]].channels:
|
||||
IRCPool[config["Master"][0]].msg(config["Master"][1], data)
|
||||
if main.config["Master"][0] in main.IRCPool.keys():
|
||||
if main.config["Master"][1] in main.IRCPool[main.config["Master"][0]].channels:
|
||||
main.IRCPool[main.config["Master"][0]].msg(main.config["Master"][1], data)
|
||||
else:
|
||||
if not hasMonitors:
|
||||
masterbuf.append(data)
|
||||
saveConf("masterbuf")
|
||||
main.masterbuf.append(data)
|
||||
main.saveConf("masterbuf")
|
||||
else:
|
||||
if not hasMonitors:
|
||||
masterbuf.append(data)
|
||||
saveConf("masterbuf")
|
||||
main.masterbuf.append(data)
|
||||
main.saveConf("masterbuf")
|
||||
warn("Master with no IRC instance defined")
|
||||
|
||||
for i in MonitorPool:
|
||||
connections[i].send(data)
|
||||
for i in main.MonitorPool:
|
||||
main.connections[i].send(data)
|
||||
|
||||
def isKeyword(msg):
|
||||
message = msg.lower()
|
||||
@@ -40,10 +40,10 @@ def isKeyword(msg):
|
||||
toUndo = False
|
||||
uniqueNum = 0
|
||||
totalNum = 0
|
||||
for i in keyconf["Keywords"]:
|
||||
for i in main.keyconf["Keywords"]:
|
||||
if i in message:
|
||||
if i in keyconf["KeywordsExcept"].keys():
|
||||
for x in keyconf["KeywordsExcept"][i]:
|
||||
if i in main.keyconf["KeywordsExcept"].keys():
|
||||
for x in main.keyconf["KeywordsExcept"][i]:
|
||||
if x in message:
|
||||
toUndo = True
|
||||
messageDuplicate = messageDuplicate.replace(x, "\0\r\n\n\0")
|
||||
@@ -68,10 +68,10 @@ def isKeyword(msg):
|
||||
|
||||
def actKeyword(user, channel, message, nickname, actType, name):
|
||||
toSend = isKeyword(message)
|
||||
if name == config["Master"][0] and channel == config["Master"][1]:
|
||||
if name == main.config["Master"][0] and channel == main.config["Master"][1]:
|
||||
pass
|
||||
else:
|
||||
if config["HighlightNotifications"]:
|
||||
if main.config["HighlightNotifications"]:
|
||||
msgLower = message.lower()
|
||||
nickLower = nickname.lower()
|
||||
if nickLower in msgLower:
|
||||
@@ -83,19 +83,19 @@ def actKeyword(user, channel, message, nickname, actType, name):
|
||||
count.event(name, "keymatch")
|
||||
|
||||
def addKeyword(keyword):
|
||||
if keyword in keyconf["Keywords"]:
|
||||
if keyword in main.keyconf["Keywords"]:
|
||||
return "EXISTS"
|
||||
else:
|
||||
for i in keyconf["Keywords"]:
|
||||
for i in main.keyconf["Keywords"]:
|
||||
if i in keyword or keyword in i:
|
||||
return "ISIN"
|
||||
keyconf["Keywords"].append(keyword)
|
||||
saveConf("keyconf")
|
||||
main.keyconf["Keywords"].append(keyword)
|
||||
main.saveConf("keyconf")
|
||||
return True
|
||||
|
||||
def delKeyword(keyword):
|
||||
if not keyword in keyconf["Keywords"]:
|
||||
if not keyword in main.keyconf["Keywords"]:
|
||||
return "NOKEY"
|
||||
keyconf["Keywords"].remove(keyword)
|
||||
saveConf("keyconf")
|
||||
main.keyconf["Keywords"].remove(keyword)
|
||||
main.saveConf("keyconf")
|
||||
return True
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
from core.main import *
|
||||
import main
|
||||
from string import digits
|
||||
#from utils.logging.log import *
|
||||
|
||||
def setWho(network, newObjects):
|
||||
network = "".join([x for x in network if not x in digits])
|
||||
if not network in wholist.keys():
|
||||
wholist[network] = {}
|
||||
if not network in main.wholist.keys():
|
||||
main.wholist[network] = {}
|
||||
for i in newObjects.keys():
|
||||
wholist[network][i] = newObjects[i]
|
||||
main.wholist[network][i] = newObjects[i]
|
||||
|
||||
return
|
||||
|
||||
def setWhoSingle(network, nick, ident, host):
|
||||
network = "".join([x for x in network if not x in digits])
|
||||
|
||||
if network in wholist.keys():
|
||||
if nick in wholist[network].keys():
|
||||
wholist[network][nick][1] = ident
|
||||
wholist[network][nick][2] = host
|
||||
if network in main.wholist.keys():
|
||||
if nick in main.wholist[network].keys():
|
||||
main.wholist[network][nick][1] = ident
|
||||
main.wholist[network][nick][2] = host
|
||||
else:
|
||||
wholist[network][nick] = [nick, ident, host, None, None, None]
|
||||
main.wholist[network][nick] = [nick, ident, host, None, None, None]
|
||||
else:
|
||||
main.wholist[network] = {nick: [nick, ident, host, None, None, None]}
|
||||
|
||||
def getWho(nick):
|
||||
result = {}
|
||||
for i in wholist.keys():
|
||||
for x in wholist[i].keys():
|
||||
for i in main.wholist.keys():
|
||||
for x in main.wholist[i].keys():
|
||||
if nick.lower() == x.lower():
|
||||
if not i in result.keys():
|
||||
result[i] = []
|
||||
result[i].append(wholist[i][x])
|
||||
result[i].append(main.wholist[i][x])
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user