import json import time import os from core.registry import Registry try: config = json.load(open("./conf/config.json", "r")) Registry.load_instances([ "core", os.path.join("modules", "core"), os.path.join("modules", "standard"), os.path.join("modules", "custom") ]) Registry.inject_all() db = Registry.get_instance("db") db.connect(config["database"]["name"]) Registry.start_all() bot = Registry.get_instance("budabot") bot.superadmin = config["superadmin"].capitalize() bot.dimension = 5 bot.connect("chat.d1.funcom.com", 7105) bot.post_start() if not bot.login(config["username"], config["password"], config["character"]): bot.disconnect() time.sleep(5)
if not os.path.exists(config_file): config_creator.create_new_cfg(config_file, "./conf/config.template.hjson") # load config logger.debug("Reading config file '%s'" % config_file) with open(config_file, "r") as cfg: config = DictObject(hjson.load(cfg)) # paths to search for instances: core + module_paths paths = ["core"] paths.extend(config.module_paths) # load instances logger.debug("Loading instances") Registry.load_instances(paths) Registry.inject_all() # configure database db = Registry.get_instance("db") if config.database.type == "sqlite": db.connect_sqlite("./data/" + config.database.name) elif config.database.type == "mysql": db.connect_mysql(config.database.host, config.database.username, config.database.password, config.database.name) else: raise Exception("Unknown database type '%s'" % config.database.type) # run db upgrade scripts import upgrade
# Create a new config create_new_cfg() else: print( 'You can manually create a config by editing the template /conf/config.template.json and rename it to config.json' ) exit(0) logger.debug("Reading config file '%s'" % config_file) with open(config_file) as cfg: config = json.load(cfg) logger.debug("Loading instances") Registry.load_instances([ "core", os.path.join("modules", "core"), os.path.join("modules", "addons") ]) Registry.add_instance("mmdb_parser", MMDBParser("text.mdb")) Registry.inject_all() bot = Registry.get_instance("mangopie") db = Registry.get_instance("db") db.connect(config["db_host"], config["db_name"]) bot.init(config, Registry) if int(config["dimension"]) == 1: bot.connect("chat.d1.funcom.com", 7105) elif int(config["dimension"]) == 2: bot.connect("chat.dt.funcom.com", 7109) elif int(config["dimension"]) == 3: