Plugin Reference¶
This document contains the base plugin and commands Python references.
plugin module¶
Contains data shared with all commands in a same plugin.
Parameters: - name (str) – The plugin name.
- config (
py314.config.FileConfig) – Plugin configuration. - state (
State) – The plugin state. - essential (bool) – The essential plugin flag.
-
class
shellbot.plugin.Plugin(config, credentials=None, **kwargs)¶ Represent a ShellBot Plugin.
Parameters: - config (
py314.config.FileConfig) – Plugin configuration. - credentials (dict [optional]) – Credentials dictionary.
-
name¶ str – The plugin name given by the configuration file.
-
brief¶ str – The plugin brief given by the configuration file.
-
commands¶ dict – Arrows key → command, where key is a command name and command is an instance of
Command.
-
aliases¶ dict – Arrows alias → name, where alias is a command alias and name is a full command name.
SharedView– A shared object for commands.
-
name str – The plugin name.
-
brief str – A brief plugin explanation.
-
essential¶ bool – Essential component (disabling not allowed).
-
make_link()¶ Return the URL (Markdown style) for the commands documentation.
-
visible¶ bool – Global default plugin’s visibility.
-
reload()¶ Reload the static data from the configuration file.
-
resolve(string)¶ Return the command object called string or
None.Parameters: string (str) – The command or alias name. Returns: The desired command or None.
-
coroutine
debug(*args, **kwargs)¶ A coroutine for debug purposes.
-
coroutine
dispatch(ctx)¶ Execute the command in a specific ctx.
Parameters: ctx ( Context) – The command context.
-
coroutine
update()¶ Called by the client on an update event. Only enabled plugins can be updated at runtime.
-
coroutine
update_remote()¶ Called by the client on an update API event.
Reload only API keys/credentials if the plugin needs these latter. Only enabled plugins can be updated at runtime.
- config (
-
class
shellbot.plugin.Importer(bot, path)¶ A context manager to create extensions for a bot and according to a configuration folder.
Parameters: - bot (
ShellBotClient) – The bot the plugin factory is attached to. - path (str) – The configuration folder.
- bot (
-
class
shellbot.plugin.Library¶ A mapping of
Plugininstances.-
has(name)¶ Check that name is a plugin name.
-
get(name, default=None)¶ Return the plugin named name or default if this fails.
-
resolve(*names, syntax=<Syntax.PLUGIN: 2>)¶ For name in names, find a
Component, i.e. aCommandor aPluginobject called name. The output is a single object if names has only one item and is a list otherwise.Parameters: syntax ( Syntax[optional]) – A syntax pattern.
-
plugin_of(name)¶ Return the
Pluginassociated with the command named name.Parameters: name (str) – A command name.
-
classmethod
load(bot, path)¶ Create a
Libraryfrom the plugins given byImporterbased on bot and path.Parameters: - bot (
ShellBotClient) – The bot the plugin factory is attached to. - path (str) – The configuration folder.
- bot (
-
load_extension(extension)¶ Attempt to add the extension to the current library.
Parameters: extension ( Plugin) – The plugin to add.
-
unload_extension(name)¶ Unload the extension from the current library.
Parameters: name (str) – Plugin name.
-
names¶ set – Plugin names.
-
enabled_names¶ set – Enabled plugin names.
-
disabled_names¶ set – Disabled plugin names.
-
default_names¶ set – Default plugin names.
-
essential_names¶ set – Essential plugin names.
-
reload_all()¶ Call
Plugin.reload()on current plugins.
-
coroutine
update_all()¶ Call
Plugin.update()on current plugins.
-
coroutine
update_remote_all()¶ Call
Plugin.update_remote()on current plugins.
-