You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the new plugin system was put in place, it was important to keep the bot's interface as backward compatible as possible, and we did a pretty good job. Now it is time to think about the future, and remove the leftovers. For instance, the registration (and removal) of a plugin is a complex sequence:
the bot in its setup phase, calls setup_plugins to register and loads its plugins
this setup_plugins method calls the handler's register method (and provide the bot itself as argument)
this register method calls loader.clean_module, which does a bunch of stuff we should not need, but for now we do
then it calls bot.add_plugin, circling back to the bot...
This issue is a follow-up on #2341 that adds TODO to remove add_plugin and remove_plugin.
Problems & Solutions
The problem is that bot.add_plugin must have the same input as the output of loader.clean_module, and adding any new type of plugin callables is more difficult because of that. Since the bot already has a bunch of specific register_* methods:
we could reuse these directly. All that is left is to register the plugin handler itself (self._plugins[plugin.name] = plugin) which can be done directly by the setup_plugins method.
And then, we can deprecate add_plugin, do the same thing for remove_plugin, and probably clean up some other things along the way (I'm looking at you, sopel.loader).
Context
When the new plugin system was put in place, it was important to keep the bot's interface as backward compatible as possible, and we did a pretty good job. Now it is time to think about the future, and remove the leftovers. For instance, the registration (and removal) of a plugin is a complex sequence:
setup_plugins
to register and loads its pluginssetup_plugins
method calls the handler's register method (and provide the bot itself as argument)register
method callsloader.clean_module
, which does a bunch of stuff we should not need, but for now we dobot.add_plugin
, circling back to the bot...This issue is a follow-up on #2341 that adds TODO to remove
add_plugin
andremove_plugin
.Problems & Solutions
The problem is that
bot.add_plugin
must have the same input as the output ofloader.clean_module
, and adding any new type of plugin callables is more difficult because of that. Since the bot already has a bunch of specificregister_*
methods:we could reuse these directly. All that is left is to register the plugin handler itself (
self._plugins[plugin.name] = plugin
) which can be done directly by thesetup_plugins
method.And then, we can deprecate
add_plugin
, do the same thing forremove_plugin
, and probably clean up some other things along the way (I'm looking at you,sopel.loader
).Planning
add_plugin
andremove_plugin
by direct call to specific registration methods (see bot, plugins: deprecate bot.{add|remove}_plugin #2636)Removing the deprecated method will be done in #2640
The text was updated successfully, but these errors were encountered: