Separate out everything into files and implement a modules system to segment commands
This commit is contained in:
50
core/main.py
Normal file
50
core/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"],
|
||||
}
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user