Plugin¶
-
class
glados.plugin.GladosPlugin(config, bot, **kwargs)[source]¶ Bases:
objectParent 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 this - route (
Union[EventRoutes,str]) – what is the route to be added - function (
Callable) – the function to be executed when this route runs
Return type: NoReturn- route_type (
-
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) –
- request (
-
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 sent - kwargs –
Return type: Any- request (
- config (
-
class
glados.plugin.PluginConfig(name, config_file, module=None, enabled=False, bot=None, **kwargs)[source]¶ Bases:
objectPlugin Config Object.
Parameters: - name (
str) – Plugin Name - config_file (
str) – Path to config file for plugin - module – 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
- name (
-
class
glados.plugin.PluginImporter(plugins_folder, plugins_config_folder)[source]¶ Bases:
objectCreate the PluginImporter object.
Parameters: - plugins_folder (
str) – plugin folder - plugins_config_folder (
str) – plugin config folder
-
discover_plugins()[source]¶ Discover all plugin config files in the plugins folder
Return type: NoReturn
- plugins_folder (