Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data
This commit is contained in:
50
main.py
Normal file
50
main.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from json import load, dump, loads
|
||||
|
||||
from utils.loaders.command_loader import loadCommands
|
||||
from utils.logging.log import *
|
||||
|
||||
configPath = "conf/"
|
||||
certPath = "cert/"
|
||||
|
||||
filemap = {
|
||||
"config": ["config.json", "configuration"],
|
||||
"keyconf": ["keyword.json", "keyword lists"],
|
||||
"pool": ["pool.json", "pool"],
|
||||
"help": ["help.json", "command help"],
|
||||
"wholist": ["wholist.json", "WHO lists"],
|
||||
"counters": ["counters.json", "counters file"],
|
||||
"masterbuf": ["masterbuf.json", "master buffer"],
|
||||
}
|
||||
|
||||
connections = {}
|
||||
IRCPool = {}
|
||||
ReactorPool = {}
|
||||
FactoryPool = {}
|
||||
|
||||
MonitorPool = []
|
||||
|
||||
CommandMap = {}
|
||||
|
||||
def register(command, function):
|
||||
if not command in CommandMap:
|
||||
CommandMap[command] = function
|
||||
debug("Registered command: %s" % command)
|
||||
else:
|
||||
error("Duplicate command: %s" % (command))
|
||||
|
||||
def saveConf(var):
|
||||
with open(configPath+filemap[var][0], "w") as f:
|
||||
dump(globals()[var], f, indent=4)
|
||||
return
|
||||
|
||||
def loadConf(var):
|
||||
with open(configPath+filemap[var][0], "r") as f:
|
||||
globals()[var] = load(f)
|
||||
|
||||
def initConf():
|
||||
for i in filemap.keys():
|
||||
loadConf(i)
|
||||
|
||||
def initMain():
|
||||
initConf()
|
||||
loadCommands(register)
|
||||
Reference in New Issue
Block a user