Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data

This commit is contained in:
2018-03-14 20:13:40 +00:00
parent 5b1e3c6fb1
commit d168d69732
33 changed files with 370 additions and 318 deletions

View File

@@ -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