From d958f65f7e73579009ba61dc0ff0c9c636df8c74 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 24 Dec 2015 18:14:05 -0800 Subject: [PATCH] networks: call coreplugin and loaded plugins' main() functions on connect I haven't really tested this very well, but it *should* not break anything...... --- plugins/networks.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/networks.py b/plugins/networks.py index 83bab8f..a0d1c63 100644 --- a/plugins/networks.py +++ b/plugins/networks.py @@ -6,7 +6,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import threading -import conf +import coreplugin import utils import world from log import log @@ -49,9 +49,19 @@ def connect(irc, source, args): if network.connection_thread.is_alive(): irc.reply('Error: Network "%s" seems to be already connected.' % netname) else: # Reconnect the network! - network.initVars() network.connection_thread = threading.Thread(target=network.connect) network.connection_thread.start() + + # Call coreplugin's initialization method + log.debug('(%s) Calling main() function of coreplugin', irc.name) + coreplugin.main(irc) + + # And the plugins we have too. + for plugin in world.plugins.values(): + if hasattr(plugin, 'main'): + log.debug('(%s) Calling main() function of plugin %r', irc.name, plugin) + plugin.main(irc) + irc.reply("Done.") @utils.add_cmd