goop

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MPL-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateGateway = errors.New("goop: Duplicate gateway")
	ErrDuplicateCommand = errors.New("goop: Duplicate command")
)

Errors

Functions

This section is empty.

Types

type Command

type Command interface {
	CanExecute(t *gateway.Trigger) bool
	Execute(t *gateway.Trigger, gw gateway.Gateway, g *Goop) error
}

Command interface

type Config

type Config interface {
	GetRelay(to, from string) *RelayConfig

	Map() map[string]interface{}
	FlatMap() map[string]interface{}
	Get(key string) (interface{}, error)
	Set(key string, val interface{}) error
	Unset(key string) (err error)
	GetString(key string) (string, error)
	SetString(key string, val string) error
}

Config interface

type Goop

type Goop struct {
	network.EventEmitter

	// Read-only
	Commands map[string]Command
	Gateways map[string]gateway.Gateway
	Relay    map[string]map[string]*Relay
	Config   Config
}

Goop main

func New

func New(conf Config) *Goop

New initializes a Goop struct

func (*Goop) AddCommand

func (g *Goop) AddCommand(name string, c Command) error

AddCommand to goop

func (*Goop) AddGateway

func (g *Goop) AddGateway(id string, gw gateway.Gateway) error

AddGateway to goop

func (*Goop) Run

func (g *Goop) Run(ctx context.Context)

Run connects to each gateway and returns when all connections have ended

type NewCommand added in v0.10.0

type NewCommand struct {
	Name    string
	Command Command
}

NewCommand event

type NewGateway added in v0.10.0

type NewGateway struct {
	gateway.Gateway
}

NewGateway event

type Relay

type Relay struct {
	From gateway.Gateway
	To   gateway.Gateway

	*RelayConfig
}

Relay manages a relay between two gateways

func NewRelay

func NewRelay(from, to gateway.Gateway, conf *RelayConfig) *Relay

NewRelay initializes a new GatRelayeway struct

func (*Relay) InitDefaultHandlers

func (r *Relay) InitDefaultHandlers()

InitDefaultHandlers adds the default callbacks for relevant events

type RelayConfig

type RelayConfig struct {
	Log         bool
	System      bool
	Channel     bool
	Joins       bool
	Chat        bool
	PrivateChat bool
	Say         bool

	JoinAccess        gateway.AccessLevel
	ChatAccess        gateway.AccessLevel
	PrivateChatAccess gateway.AccessLevel
}

RelayConfig stores the configuration of a gateway relay

type Start added in v0.9.12

type Start struct{}

Start event

type Stop added in v0.9.12

type Stop struct{}

Stop event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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