Autoload plugins in session_start instead of core.__init__
This commit is contained in:
parent
eaced10c16
commit
bd2d1caa0a
2 changed files with 7 additions and 6 deletions
|
@ -177,8 +177,6 @@ class Core(object):
|
||||||
|
|
||||||
self.connected_events = {}
|
self.connected_events = {}
|
||||||
|
|
||||||
self.autoload_plugins()
|
|
||||||
|
|
||||||
def autoload_plugins(self):
|
def autoload_plugins(self):
|
||||||
plugins = config.get('plugins_autoload', '')
|
plugins = config.get('plugins_autoload', '')
|
||||||
for plugin in plugins.split():
|
for plugin in plugins.split():
|
||||||
|
@ -456,6 +454,7 @@ class Core(object):
|
||||||
Called when we are connected and authenticated
|
Called when we are connected and authenticated
|
||||||
"""
|
"""
|
||||||
self.connection_time = time.time()
|
self.connection_time = time.time()
|
||||||
|
self.autoload_plugins()
|
||||||
self.information(_("Authentication success."))
|
self.information(_("Authentication success."))
|
||||||
self.information(_("Your JID is %s") % self.xmpp.boundjid.full)
|
self.information(_("Your JID is %s") % self.xmpp.boundjid.full)
|
||||||
if not self.xmpp.anon:
|
if not self.xmpp.anon:
|
||||||
|
|
|
@ -37,7 +37,7 @@ class PluginManager(object):
|
||||||
self.event_handlers = {} # module name -> list of event_name/handler pairs loaded for the module
|
self.event_handlers = {} # module name -> list of event_name/handler pairs loaded for the module
|
||||||
self.tab_commands = {} #module name -> dict of tab types; tab type -> commands loaded by the module
|
self.tab_commands = {} #module name -> dict of tab types; tab type -> commands loaded by the module
|
||||||
|
|
||||||
def load(self, name):
|
def load(self, name, notify=True):
|
||||||
if name in self.plugins:
|
if name in self.plugins:
|
||||||
self.unload(name)
|
self.unload(name)
|
||||||
|
|
||||||
|
@ -64,9 +64,10 @@ class PluginManager(object):
|
||||||
self.tab_commands[name] = {}
|
self.tab_commands[name] = {}
|
||||||
self.event_handlers[name] = []
|
self.event_handlers[name] = []
|
||||||
self.plugins[name] = module.Plugin(self, self.core, plugins_conf_dir)
|
self.plugins[name] = module.Plugin(self, self.core, plugins_conf_dir)
|
||||||
self.core.information('Plugin %s loaded' % name, 'Info')
|
if notify:
|
||||||
|
self.core.information('Plugin %s loaded' % name, 'Info')
|
||||||
|
|
||||||
def unload(self, name):
|
def unload(self, name, notify=True):
|
||||||
if name in self.plugins:
|
if name in self.plugins:
|
||||||
try:
|
try:
|
||||||
for command in self.commands[name].keys():
|
for command in self.commands[name].keys():
|
||||||
|
@ -83,7 +84,8 @@ class PluginManager(object):
|
||||||
del self.commands[name]
|
del self.commands[name]
|
||||||
del self.tab_commands[name]
|
del self.tab_commands[name]
|
||||||
del self.event_handlers[name]
|
del self.event_handlers[name]
|
||||||
self.core.information('Plugin %s unloaded' % name, 'Info')
|
if notify:
|
||||||
|
self.core.information('Plugin %s unloaded' % name, 'Info')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
self.core.information(_("Could not unload plugin (may not be safe to try again): ") + traceback.format_exc())
|
self.core.information(_("Could not unload plugin (may not be safe to try again): ") + traceback.format_exc())
|
||||||
|
|
Loading…
Reference in a new issue