3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

networks: call coreplugin and loaded plugins' main() functions on connect

I haven't really tested this very well, but it *should* not break anything......
This commit is contained in:
James Lu 2015-12-24 18:14:05 -08:00
parent 3f45450969
commit d958f65f7e

View File

@ -6,7 +6,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import threading import threading
import conf import coreplugin
import utils import utils
import world import world
from log import log from log import log
@ -49,9 +49,19 @@ def connect(irc, source, args):
if network.connection_thread.is_alive(): if network.connection_thread.is_alive():
irc.reply('Error: Network "%s" seems to be already connected.' % netname) irc.reply('Error: Network "%s" seems to be already connected.' % netname)
else: # Reconnect the network! else: # Reconnect the network!
network.initVars()
network.connection_thread = threading.Thread(target=network.connect) network.connection_thread = threading.Thread(target=network.connect)
network.connection_thread.start() 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.") irc.reply("Done.")
@utils.add_cmd @utils.add_cmd