Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from core.main import *
|
||||
import main
|
||||
import modules.keyword as keyword
|
||||
|
||||
class Key:
|
||||
@@ -39,45 +39,45 @@ class Key:
|
||||
return
|
||||
if length == 4:
|
||||
if spl[1] == "except":
|
||||
if not spl[2] in keyconf["Keywords"]:
|
||||
if not spl[2] in main.keyconf["Keywords"]:
|
||||
failure("No such keyword: %s" % spl[2])
|
||||
return
|
||||
if spl[2] in keyconf["KeywordsExcept"].keys():
|
||||
if spl[3] in keyconf["KeywordsExcept"][spl[2]]:
|
||||
if spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||
if spl[3] in main.keyconf["KeywordsExcept"][spl[2]]:
|
||||
failure("Exception exists: %s" % spl[3])
|
||||
return
|
||||
else:
|
||||
if not spl[2] in spl[3]:
|
||||
failure("Keyword %s not in exception %s. This won't work" % (spl[2], spl[3]))
|
||||
return
|
||||
keyconf["KeywordsExcept"][spl[2]] = []
|
||||
main.keyconf["KeywordsExcept"][spl[2]] = []
|
||||
|
||||
keyconf["KeywordsExcept"][spl[2]].append(spl[3])
|
||||
saveConf("keyconf")
|
||||
main.keyconf["KeywordsExcept"][spl[2]].append(spl[3])
|
||||
main.saveConf("keyconf")
|
||||
success("Successfully added exception %s for keyword %s" % (spl[3], spl[2]))
|
||||
return
|
||||
elif spl[1] == "master":
|
||||
if not spl[2] in pool.keys():
|
||||
if not spl[2] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[2])
|
||||
return
|
||||
if spl[2] in IRCPool.keys():
|
||||
if not spl[3] in IRCPool[spl[2]].channels:
|
||||
if spl[2] in main.IRCPool.keys():
|
||||
if not spl[3] in main.IRCPool[spl[2]].channels:
|
||||
info("Bot not on channel: %s" % spl[3])
|
||||
config["Master"] = [spl[2], spl[3]]
|
||||
saveConf("config")
|
||||
main.config["Master"] = [spl[2], spl[3]]
|
||||
main.saveConf("config")
|
||||
success("Master set to %s on %s" % (spl[3], spl[2]))
|
||||
return
|
||||
elif spl[1] == "unexcept":
|
||||
if not spl[2] in keyconf["KeywordsExcept"].keys():
|
||||
if not spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||
failure("No such exception: %s" % spl[2])
|
||||
return
|
||||
if not spl[3] in keyconf["KeywordsExcept"][spl[2]]:
|
||||
if not spl[3] in main.keyconf["KeywordsExcept"][spl[2]]:
|
||||
failure("Exception %s has no attribute %s" % (spl[2], spl[3]))
|
||||
return
|
||||
keyconf["KeywordsExcept"][spl[2]].remove(spl[3])
|
||||
if keyconf["KeywordsExcept"][spl[2]] == []:
|
||||
del keyconf["KeywordsExcept"][spl[2]]
|
||||
saveConf("keyconf")
|
||||
main.keyconf["KeywordsExcept"][spl[2]].remove(spl[3])
|
||||
if main.keyconf["KeywordsExcept"][spl[2]] == []:
|
||||
del main.keyconf["KeywordsExcept"][spl[2]]
|
||||
main.saveConf("keyconf")
|
||||
success("Successfully removed exception %s for keyword %s" % (spl[3], spl[2]))
|
||||
return
|
||||
else:
|
||||
@@ -85,32 +85,32 @@ class Key:
|
||||
return
|
||||
elif length == 3:
|
||||
if spl[1] == "unexcept":
|
||||
if not spl[2] in keyconf["KeywordsExcept"].keys():
|
||||
if not spl[2] in main.keyconf["KeywordsExcept"].keys():
|
||||
failure("No such exception: %s" % spl[2])
|
||||
return
|
||||
del keyconf["KeywordsExcept"][spl[2]]
|
||||
saveConf("keyconf")
|
||||
del main.keyconf["KeywordsExcept"][spl[2]]
|
||||
main.saveConf("keyconf")
|
||||
success("Successfully removed exception list of %s" % spl[2])
|
||||
return
|
||||
elif spl[1] == "monitor":
|
||||
if spl[2] == "on":
|
||||
if not obj.addr in MonitorPool:
|
||||
MonitorPool.append(obj.addr)
|
||||
if not obj.addr in main.MonitorPool:
|
||||
main.MonitorPool.append(obj.addr)
|
||||
success("Keyword monitoring enabled")
|
||||
if len(masterbuf) == 0:
|
||||
if len(main.masterbuf) == 0:
|
||||
return
|
||||
rtrn = []
|
||||
for i in range(len(masterbuf)):
|
||||
rtrn.append(masterbuf.pop(0))
|
||||
saveConf("masterbuf")
|
||||
for i in range(len(main.masterbuf)):
|
||||
rtrn.append(main.masterbuf.pop(0))
|
||||
main.saveConf("masterbuf")
|
||||
info("\n".join(rtrn))
|
||||
return
|
||||
else:
|
||||
failure("Keyword monitoring is already enabled")
|
||||
return
|
||||
elif spl[2] == "off":
|
||||
if obj.addr in MonitorPool:
|
||||
MonitorPool.remove(obj.addr)
|
||||
if obj.addr in main.MonitorPool:
|
||||
main.MonitorPool.remove(obj.addr)
|
||||
success("Keyword monitoring disabled")
|
||||
return
|
||||
else:
|
||||
@@ -124,22 +124,22 @@ class Key:
|
||||
return
|
||||
elif length == 2:
|
||||
if spl[1] == "show":
|
||||
info(",".join(keyconf["Keywords"]))
|
||||
info(",".join(main.keyconf["Keywords"]))
|
||||
return
|
||||
|
||||
elif spl[1] == "showexcept":
|
||||
exceptMap = []
|
||||
for i in keyconf["KeywordsExcept"].keys():
|
||||
for i in main.keyconf["KeywordsExcept"].keys():
|
||||
exceptMap.append("Key: %s" % i)
|
||||
exceptMap.append("%s: %s" % (i, ",".join(keyconf["KeywordsExcept"][i])))
|
||||
exceptMap.append("%s: %s" % (i, ",".join(main.keyconf["KeywordsExcept"][i])))
|
||||
exceptMap.append("\n")
|
||||
info("\n".join(exceptMap))
|
||||
return
|
||||
elif spl[1] == "master":
|
||||
info(" - ".join([str(i) for i in config["Master"]]))
|
||||
info(" - ".join([str(i) for i in main.config["Master"]]))
|
||||
return
|
||||
elif spl[1] == "monitor":
|
||||
if obj.addr in MonitorPool:
|
||||
if obj.addr in main.MonitorPool:
|
||||
info("Keyword monitoring is enabled on this connection")
|
||||
return
|
||||
else:
|
||||
@@ -148,7 +148,6 @@ class Key:
|
||||
else:
|
||||
incUsage("key")
|
||||
return
|
||||
|
||||
else:
|
||||
incUsage("key")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user