52 lines
1.1 KiB
Python
52 lines
1.1 KiB
Python
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"],
|
|
}
|
|
|
|
numbers = "0123456789"
|
|
|
|
listener = None
|
|
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)
|