extension

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Type  string `mapstructure:"type"`
	Host  string `mapstructure:"host"`
	Port  int    `mapstructure:"port"`
	URL   string `mapstructure:"url"`
	Token string `mapstructure:"token"`
}

Config contains all the require parameters to communicate with an extension

type ConfigMap added in v0.8.0

type ConfigMap map[string]Config

ConfigMap of extension server names to their configs

type Extension

type Extension interface {
	GetAllExtensions() ([]string, error)
	ExecuteExtension(question *query.Question, extensionName, channel, command string, fsmDomain *fsm.Domain, machine *fsm.FSM) ([]query.Answer, error)
}

Extension is a service (REST or RPC) that executes commands and returns an answer to the Chatto bot. Extensions are written in any language and do whatever you want.

type REST

type REST struct {
	URL string
	// contains filtered or unexported fields
}

REST is a REST Client for extension command functions

func (*REST) ExecuteExtension added in v0.7.0

func (e *REST) ExecuteExtension(question *query.Question, ext, chn, cmd string, fsmDomain *fsm.Domain, machine *fsm.FSM) ([]query.Answer, error)

ExecuteExtension runs the requested command function and returns the response

func (*REST) GetAllExtensions added in v0.7.0

func (e *REST) GetAllExtensions() ([]string, error)

GetAllExtensions returns all command functions in the extension as a list of strings

type RPC

type RPC struct {
	Client *rpc.Client
}

RPC is an RPC Client for extension command functions

func (*RPC) ExecuteExtension added in v0.7.0

func (e *RPC) ExecuteExtension(question *query.Question, ext, chn, cmd string, fsmDomain *fsm.Domain, machine *fsm.FSM) ([]query.Answer, error)

ExecuteExtension runs the requested command function and returns the response

func (*RPC) GetAllExtensions added in v0.7.0

func (e *RPC) GetAllExtensions() ([]string, error)

GetAllExtensions returns all command functions in the extension as a list of strings

type ServerMap added in v0.8.0

type ServerMap map[string]Extension

ServerMap of extension server names to their clients

func New

func New(extCfg ConfigMap) (ServerMap, error)

New loads the extension configuration and connects to the server

func (*ServerMap) Add added in v0.8.0

func (m *ServerMap) Add(server string, client Extension) error

Add new extension name and client to the extension map

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL