chatlib

package module
v0.0.0-...-78066cc Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RoleAdmin = "admin"
	RoleStaff = "staff"
	RoleUser  = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	SendMessage(c context.Context, msg *Message) error
	ReceiveMessage(c context.Context) (*Message, error)
	Start(c context.Context) error
	Stop(c context.Context) error
}

type Action

type Action struct {
	Command string
	// contains filtered or unexported fields
}

type ActionFunc

type ActionFunc func(c context.Context, re *regexp.Regexp, msg *Message) error

type Error

type Error string
const (
	ErrInvalidConfig Error = "invalidConfig"
	ErrTimeout       Error = "timeout"
)

func (Error) Error

func (e Error) Error() string

type Handler

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

func New

func New(opts ...Option) (*Handler, error)

func (*Handler) ApplyOptions

func (h *Handler) ApplyOptions(opts ...Option) error

func (*Handler) Start

func (h *Handler) Start(ctx context.Context) error

type Message

type Message struct {
	Text     string
	Command  string
	Sender   string
	Receiver string
	Raw      string
}

type Option

type Option func(*Handler) error

func CombineOptions

func CombineOptions(opts ...Option) Option

func RegisterAction

func RegisterAction(command, pattern, example, help string, fn ActionFunc, roles ...string) Option

func WithAPI

func WithAPI(api API) Option

Directories

Path Synopsis
examples
freyabot module

Jump to

Keyboard shortcuts

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