Commit dec8ea3b authored by Guillaume Binet's avatar Guillaume Binet

Globally respect the plugin callback order.

Also remove unused methods from the plugin_manager.
parent b89a99e7
......@@ -104,7 +104,7 @@ class ErrBot(Backend, StoreMixin):
:param *args: Passed to the callback function.
:param **kwargs: Passed to the callback function.
"""
for plugin in self.plugin_manager.get_all_active_plugin_objects_ordered():
for plugin in self.plugin_manager.get_all_active_plugins():
plugin_name = plugin.name
log.debug('Triggering %s on %s.', method, plugin_name)
# noinspection PyBroadException
......@@ -170,7 +170,7 @@ class ErrBot(Backend, StoreMixin):
:param msg: the message to send.
:return: None
"""
for bot in self.plugin_manager.get_all_active_plugin_objects():
for bot in self.plugin_manager.get_all_active_plugins():
# noinspection PyBroadException
try:
bot.callback_botmessage(msg)
......@@ -616,10 +616,10 @@ class ErrBot(Backend, StoreMixin):
def callback_stream(self, stream):
log.info('Initiated an incoming transfer %s.', stream)
Tee(stream, self.plugin_manager.get_all_active_plugin_objects()).start()
Tee(stream, self.plugin_manager.get_all_active_plugins()).start()
def signal_connect_to_all_plugins(self):
for bot in self.plugin_manager.get_all_active_plugin_objects():
for bot in self.plugin_manager.get_all_active_plugins():
if hasattr(bot, 'callback_connect'):
# noinspection PyBroadException
try:
......
......@@ -181,13 +181,6 @@ class BotPluginManager(StoreMixin):
def attach_bot(self, bot):
self.bot = bot
def check_enabled_core_plugin(self, plugin_info: PluginInfo) -> bool:
""" Checks if the given plugin is core and if it is, if it is part of the enabled core_plugins_list.
:param plugin_info: the info from the plugin
:return: True if it is OK to load this plugin.
"""
return plugin_info.core and plugin_info.name in self.core_plugins
def get_plugin_obj_by_name(self, name: str) -> BotPlugin:
return self.plugins.get(name, None)
......@@ -291,7 +284,8 @@ class BotPluginManager(StoreMixin):
self.plugin_places = [Path(root) for root in all_roots]
return self._load_plugins()
def get_all_active_plugin_objects_ordered(self) -> List[BotPlugin]:
def get_all_active_plugins(self) -> List[BotPlugin]:
"""This returns the list of plugins in the callback ordered defined from the config."""
# Make sure there is a 'None' entry in the callback order, to include
# any plugin not explicitly ordered.
if None not in self.plugins_callback_order:
......@@ -311,9 +305,6 @@ class BotPluginManager(StoreMixin):
all_plugins.append(plugin)
return all_plugins
def get_all_active_plugin_objects(self):
return [plugin for plugin in self.plugins.values() if plugin.is_activated]
def get_all_active_plugin_names(self):
return [name for name, plugin in self.plugins.items() if plugin.is_activated]
......
......@@ -176,7 +176,7 @@ def test_backup(testbot):
assert 'errbotio/err-helloworld' in open(filename).read()
# Now try to clean the bot and restore
for p in testbot.bot.plugin_manager.get_all_active_plugin_objects():
for p in testbot.bot.plugin_manager.get_all_active_plugins():
p.close_storage()
assert 'Plugin HelloWorld deactivated.' in testbot.exec_command('!plugin deactivate HelloWorld')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment