endpoint

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeConsole  string = "console"
	TypeTelegram string = "telegram"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Name    string
	Data    []byte
	IsImage bool
}

func ConvertAttachments

func ConvertAttachments(ctx context.Context, es envelope.Service, env *envelope.Envelope) ([]Attachment, error)

func NewAttachment

func NewAttachment(att *envelope.Attachment, data []byte) Attachment

func OnlyImages

func OnlyImages(atts []Attachment) []Attachment

type Config

type Config map[string]string

func (Config) Require

func (c Config) Require(keys []string) error

type Console

type Console struct{}

func (*Console) Send

func (c *Console) Send(ctx context.Context, text string, atts []Attachment) error

type CreateEndpointRequest

type CreateEndpointRequest struct {
	Name               string
	Type               string
	Config             Config
	TextDisable        bool
	TextTemplate       string
	AttachmentsDisable bool
}

type Endpoint

type Endpoint struct {
	Name        string
	Type        string
	TextDisable bool

	AttachmentsDisable bool
	// contains filtered or unexported fields
}

func NewEndpoint

func NewEndpoint(name string, endpointType string, textDisable bool, textTemplateStr string, attachmentsDisable bool, sender Sender) (Endpoint, error)

func (Endpoint) Send

func (e Endpoint) Send(ctx context.Context, env *envelope.Envelope, atts []Attachment) error

func (Endpoint) SendRaw

func (e Endpoint) SendRaw(ctx context.Context, text string, atts []Attachment) error

func (Endpoint) Text

func (e Endpoint) Text(env *envelope.Envelope) (string, error)

func (Endpoint) TextTemplate

func (e Endpoint) TextTemplate() string

type EndpointService

type EndpointService struct {
	// contains filtered or unexported fields
}

func NewEndpointService

func NewEndpointService(store Store) *EndpointService

func (*EndpointService) CreateEndpoint

func (es *EndpointService) CreateEndpoint(req CreateEndpointRequest) error

func (*EndpointService) GetEndpoint

func (es *EndpointService) GetEndpoint(name string) (Endpoint, error)

func (*EndpointService) ListEndpoint

func (es *EndpointService) ListEndpoint() []Endpoint

type Sender

type Sender interface {
	// Send text and attachments to endpoint. Text can be empty and atts can be length 0 but not both.
	Send(ctx context.Context, text string, atts []Attachment) error
}

type Service

type Service interface {
	CreateEndpoint(req CreateEndpointRequest) error
	GetEndpoint(name string) (Endpoint, error)
	ListEndpoint() []Endpoint
}

type Store

type Store interface {
	CreateEndpoint(endpoint Endpoint) error
	GetEndpoint(name string) (Endpoint, error)
	ListEndpoint() []Endpoint
}

type Telegram

type Telegram struct {
	Token  string
	ChatID string
	Client *http.Client
}

func NewTelegram

func NewTelegram(token, chatID string) *Telegram

func (*Telegram) Send

func (t *Telegram) Send(ctx context.Context, text string, atts []Attachment) error

Jump to

Keyboard shortcuts

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