monolith/core/main.py

51 lines
1.1 KiB
Python
Raw Normal View History

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"],
}
numbers = "0123456789"
listener = None
connections = {}
IRCPool = {}
ReactorPool = {}
FactoryPool = {}
MonitorPool = []
CommandMap = {}
def register(command, function):
if not command in CommandMap:
CommandMap[command] = function
log("Registering 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)