Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct call to bot.register_* methods by plugin handler #2425

Open
2 tasks done
Exirel opened this issue Mar 18, 2023 · 0 comments · May be fixed by #2636
Open
2 tasks done

Direct call to bot.register_* methods by plugin handler #2425

Exirel opened this issue Mar 18, 2023 · 0 comments · May be fixed by #2636
Labels
Core/Plugin Handling High Priority Housekeeping Code cleanup, removal of deprecated stuff, etc.
Milestone

Comments

@Exirel
Copy link
Contributor

Exirel commented Mar 18, 2023

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:

  • 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:

self.register_callables(callables)
self.register_jobs(jobs)
self.register_shutdowns(shutdowns)
self.register_urls(urls)

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).

Planning

Removing the deprecated method will be done in #2640

@Exirel Exirel added Housekeeping Code cleanup, removal of deprecated stuff, etc. Core/Plugin Handling labels Mar 18, 2023
@Exirel Exirel added this to the 8.1.0 milestone Mar 18, 2023
@Exirel Exirel linked a pull request Oct 19, 2024 that will close this issue
4 tasks
@Exirel Exirel changed the title Replace add_plugin and remove_plugin old interface Direct call to bot.register_* methods by plugin handler Oct 21, 2024
@Exirel Exirel linked a pull request Oct 21, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core/Plugin Handling High Priority Housekeeping Code cleanup, removal of deprecated stuff, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant