Plugin Loader#
Utility functions to manage plugin callables from a Python module.
Important
Its usage and documentation is for Sopel core development and advanced developers. It is subject to rapid changes between versions without much (or any) warning.
Do not build your plugin based on what is here, you do not need to.
- sopel.loader.clean_callable(func, config)#
Clean the callable. (compile regexes, fix docs, set defaults)
- Parameters:
func (callable) – the callable to clean
config (
sopel.config.Config) – Sopel’s settings
This function will set all the default attributes expected for a Sopel callable, i.e. properties related to threading, docs, examples, rate limiting, commands, rules, and other features.
- sopel.loader.clean_module(module, config)#
Clean a module and return its command, rule, job, etc. callables.
- Parameters:
module (module) – the module to clean
config (
sopel.config.Config) – Sopel’s settings
- Returns:
a tuple with triggerable, job, shutdown, and url functions
- Return type:
This function will parse the
modulelooking for callables:shutdown actions
triggerables (commands, rules, etc.)
jobs
URL callbacks
This function will set all the default attributes expected for a Sopel callable, i.e. properties related to threading, docs, examples, rate limiting, commands, rules, and other features.
- sopel.loader.is_limitable(obj)#
Check if
objneeds to carry attributes related to limits.- Parameters:
obj – any function to check
- Returns:
Trueifobjmust have limit-related attributes
Limitable callables aren’t necessarily triggerable directly, but they all must pass through Sopel’s rate-limiting machinery during dispatching. Therefore, they must have the attributes checked by that machinery.
- sopel.loader.is_triggerable(obj)#
Check if
objcan handle the bot’s triggers.- Parameters:
obj – any function to check
- Returns:
Trueifobjcan handle the bot’s triggers
A triggerable is a callable that will be used by the bot to handle a particular trigger (i.e. an IRC message): it can be a regex rule, an event, a CTCP command, a command, a nickname command, or an action command. However, it must not be a job or a URL callback.
See also
Many of the decorators defined in
sopel.pluginmake the decorated function a triggerable object.
- sopel.loader.is_url_callback(obj)#
Check if
objcan handle a URL callback.- Parameters:
obj – any function to check
- Returns:
Trueifobjcan handle a URL callback
A URL callback handler is a callable that will be used by the bot to handle a particular URL in an IRC message.
See also
Both
sopel.plugin.url()sopel.plugin.url_lazy()make the decorated function a URL callback handler.