Skip to content

Commit

Permalink
Merge pull request #2489 from SnoopJ/doc/gh2488-warn-about-plugin-unb…
Browse files Browse the repository at this point in the history
…oxing

docs: add example of plugin re-use
  • Loading branch information
dgw committed Jul 16, 2023
2 parents 85f19c7 + 1cb9654 commit a620c14
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/source/plugin/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,37 @@ Note that you don't specifically need to use ``@plugin.thread(False)``, but
it is still recommended to prevent any race condition.


Re-using commands from other plugins
====================================

.. TODO: this example should be updated when the Wikipedia plugin is removed
.. as part of https://github.com/sopel-irc/sopel/issues/1291
Because plugins are just Python modules it is possible to import functionality
from other plugins, including commands. For example, this can be used to add
an alias for an existing command::

from sopel import plugin
from sopel.modules import wikipedia as wp

@plugin.command("wiki")
@plugin.output_prefix(wp.wikipedia.output_prefix)
def wiki_alias(bot, trigger):
wp.wikipedia(bot, trigger)

.. warning::

Any callables imported from other plugins will be treated as if they were
exposed in the current plugin. This can lead to duplication of plugin
rules. For the most predictable results, import the other plugin as a
module rather than unpacking its callables using a ``from`` import.

.. warning::

While this example shows off loading a built-in plugin, some plugins may
not be as easy to import. For example, a :term:`Single file plugin` may
not be available on ``sys.path`` without extra handling not shown here.

Managing Capability negotiation
===============================

Expand Down

0 comments on commit a620c14

Please sign in to comment.