bot

package
v0.0.0-...-78a2729 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNotifications = 10
	MaxInvites       = 10
)

Variables

This section is empty.

Functions

func EventContains

func EventContains[T comparable](evt *event.Event, field string, value T) bool

EventContains checks if raw event content contains specified field with specified values

func EventField

func EventField[T comparable](content *event.Content, field string) T

EventField returns field value from raw event content

Types

type Bot

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

Bot represents matrix bot

func New

func New(cfg *config.Config, repo *bolt.Repo, psd botPSD, exe botExecutor, log *zerolog.Logger) (*Bot, error)

New creates a new matrix bot

func (*Bot) CanceledHook

func (b *Bot) CanceledHook(r *models.Run) (bool, string)

CanceledHook is called when an order is canceled it marks the order message as canceled

func (*Bot) Error

func (b *Bot) Error(roomID id.RoomID, message string, args ...interface{})

Error message to the log and matrix room

func (*Bot) FindThreadBy

func (b *Bot) FindThreadBy(ctx context.Context, roomID id.RoomID, field, value string, fromToken ...string) *event.Event

FindThreadBy tries to find thread message event by field and value

func (*Bot) InstalledHook

func (b *Bot) InstalledHook(r *models.Run) (bool, string)

InstalledHook is called when a new homeserver is successfully installed it marks the order message as completed

func (*Bot) Notice

func (b *Bot) Notice(roomID id.RoomID, threadID id.EventID, message string, args ...interface{})

Notice message to the matrix room

func (*Bot) SendAlert

func (b *Bot) SendAlert(admin, message string)

SendAlert to matrix room

func (*Bot) SendPM

func (b *Bot) SendPM(userID id.UserID, content event.MessageEventContent) id.RoomID

func (*Bot) Start

func (b *Bot) Start() error

Start performs matrix /sync

func (*Bot) Stop

func (b *Bot) Stop()

Stop the bot

func (*Bot) Threads

func (b *Bot) Threads(ctx context.Context, roomID id.RoomID, fromToken ...string) (*RespThreads, error)

Threads endpoint, ref: https://spec.matrix.org/v1.8/client-server-api/#get_matrixclientv1roomsroomidthreads

type RespThreads

type RespThreads struct {
	Chunk     []*event.Event `json:"chunk"`
	NextBatch string         `json:"next_batch"`
}

RespThreads is response of https://spec.matrix.org/v1.8/client-server-api/#get_matrixclientv1roomsroomidthreads

Jump to

Keyboard shortcuts

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