Skip to content

Commit

Permalink
docs: add example of plugin re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
SnoopJ committed Jul 12, 2023
1 parent 6af4f23 commit 482184a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/source/plugin/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ 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
====================================

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
defined 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 callables from it using a 'from' import.


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

Expand Down

0 comments on commit 482184a

Please sign in to comment.