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 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

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:
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

class glados.plugin.PluginBotConfig(name='NOT SET')[source]

Bases: object

to_dict()[source]
class glados.plugin.PluginConfig(name, config_file, module=None, enabled=False, bot=None, **kwargs)[source]

Bases: object

Plugin 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
to_yaml(user_config_only=True)[source]
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 folder
  • plugins_config_folder (str) – plugin config folder
discover_plugins()[source]

Discover all plugin config files in the plugins folder

Return type:NoReturn
import_discovered_plugins(bots)[source]

Import all discovered plugins and store them in self.plugins.

Parameters:bots (Dict[str, GladosBot]) – dict of all the imported bots
Returns:the results are updated in self.plugins
Return type:obj: NoReturn:
load_discovered_plugins_config(write_to_user_config=True)[source]

Load all the yaml configs for the plugins

Parameters:write_to_user_config (bool) –
Return type:NoReturn