diff --git a/plugins/commands.py b/plugins/commands.py index bf4b679..1c15612 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -199,7 +199,7 @@ def rehash(irc, source, args): for network, sdata in new_conf['servers'].items(): # New server was added. Connect them if not already connected. if network not in world.networkobjects: - proto = utils.getProtoModule(sdata['protocol']) + proto = utils.getProtocolModule(sdata['protocol']) world.networkobjects[network] = classes.Irc(network, proto, new_conf) irc.reply("Done.") diff --git a/pylink b/pylink index 75b11c6..4e4ff74 100755 --- a/pylink +++ b/pylink @@ -39,10 +39,18 @@ if __name__ == '__main__': log.debug('Calling main() function of plugin %r', pl) pl.main() - for network in conf.conf['servers']: - proto = utils.getProtoModule(conf.conf['servers'][network]['protocol']) + # Initialize all the networks one by one + for network, sdata in conf.conf['servers'].items(): + + protoname = sdata['protocol'] + + # Fetch the correct protocol module + proto = utils.getProtocolModule(protoname) world.networkobjects[network] = irc = classes.Irc(network, proto, conf.conf) + + # Call coreplugin's initialization method log.debug('Calling main() function of coreplugin on network %s', irc.name) coreplugin.main(irc) + world.started.set() log.info("loaded plugins: %s", world.plugins) diff --git a/utils.py b/utils.py index d62b4de..5d78f78 100644 --- a/utils.py +++ b/utils.py @@ -519,7 +519,7 @@ def loadModuleFromFolder(name, folder): m = importlib.machinery.SourceFileLoader(name, fullpath).load_module() return m -def getProtoModule(protoname): +def getProtocolModule(protoname): """Imports and returns the protocol module requested.""" return loadModuleFromFolder(protoname, world.protocols_folder)