glados.plugin module — GLaDOS 0.0.1.dev14 documentation

# glados.plugin module

class `glados.plugin.` `GladosPlugin`(config: glados.plugin.PluginConfig, bot: glados.bot.GladosBot, **kwargs)

  Bases: `object`

  Parent class for a GLaDOS Plugin

  Parameters

    - name (str) – the name of the plugin

    - bot (GladosBot) – the GLaDOS bot that this plugin will use

  `add_route`(route_type: glados.route_type.RouteType, route: Union[glados.route_type.EventRoutes, str], function: Callable)

    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

  `respond_to_url`(request: glados.request.GladosRequest, text: str, **kwargs)
  property `routes`

    List all routes for the plugin.

  `send_request`(request: glados.request.GladosRequest, **kwargs)

    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 –

class `glados.plugin.` `PluginBotConfig`(name='NOT SET')

  Bases: `object`

  `to_dict`()

class `glados.plugin.` `PluginConfig`(name, config_file, module=None, enabled=False, bot=None, **kwargs)

  Bases: `object`

  `to_dict`(user_config_only=True)
  `to_yaml`(user_config_only=True)
  `update`(config: glados.plugin.PluginConfig, use_base_module: bool = True)

    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.

class `glados.plugin.` `PluginImporter`(plugins_folder: str, plugins_config_folder: str)

  Bases: `object`

  `discover_plugins`()

    Discover all plugin config files in the plugins folder

    Returns

      list of all yaml config files

    Return type

      list

  `import_discovered_plugins`(bots: Dict[str, glados.bot.GladosBot])

    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

      None

  `load_discovered_plugins_config`(write_to_user_config=True)

    Load all the yaml configs for the plugins