Plugin¶
-
class
glados.plugin.
GladosPlugin
(config, bot, **kwargs)[source]¶ Bases:
object
Parent class for a GLaDOS Plugin
- Parameters
config (
PluginConfig
) – PluginConfig object for the plugin.bot (
GladosBot
) – the GLaDOS bot that this plugin will use
-
add_route
(route_type, route, function)[source]¶ Add a new route to the plugin
- Parameters
route_type (
RouteType
) – what type of route this is thisroute (
Union
[EventRoutes
,str
]) – what is the route to be addedfunction (
Callable
) – the function to be executed when this route runs
- Return type
NoReturn
-
has_route
(route)[source]¶ See if route exists.
- Parameters
route (route to check) –
- Returns
- Return type
True if route exists else false
-
respond_to_url
(request, text, **kwargs)[source]¶ When you click on a link that was sent via slack it sends a callback, This is to handle that
- Parameters
request (
GladosRequest
) –text (
str
) –
-
property
routes
¶ List all routes for the plugin.
- Return type
List
[GladosRoute
]
-
send_request
(request, **kwargs)[source]¶ This is the function to be called when sending a request to a plugin.
This function is responsible for validating the slack signature if needed. It also returns and empty string if the function called returns None.
- Parameters
request (
GladosRequest
) – the request object to be sentkwargs –
- Return type
Any
-
class
glados.plugin.
PluginConfig
(name, config_file, module=None, enabled=False, bot=None, **kwargs)[source]¶ Bases:
object
Plugin Config Object.
- Parameters
name (
str
) – Plugin Nameconfig_file (
str
) – Path to config file for pluginmodule – plugin python module name
enabled – enable this plugin
bot – what bot does this plugin use
kwargs –
-
to_dict
(user_config_only=True)[source]¶ Return config as dict
- Parameters
user_config_only – if True only get get waht is in the config file and not the running config.
- Return type
dict
-
update
(config, use_base_module=True)[source]¶ Update a config object using the default values from the config object passed in.
- Parameters
config (PluginConfig) – the config object to use as the base. By default the module property will be set from the base config object only
use_base_module (bool) – if set true use the value of module and package from the base config object only.
- Return type
NoReturn
-
class
glados.plugin.
PluginImporter
(plugins_folder, plugins_config_folder)[source]¶ Bases:
object
Create the PluginImporter object.
- Parameters
plugins_folder (
str
) – plugin folderplugins_config_folder (
str
) – plugin config folder
-
discover_plugins
()[source]¶ Discover all plugin config files in the plugins folder
- Return type
NoReturn