bot

package
v1.4.23 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateInfoText

func GenerateInfoText(botInfo AlertMessage) string

GenerateInfoText generates a formatted issue text, should be visible on any client that supports markdown and HTML.

Types

type AlertMessage

type AlertMessage struct {
	// User defined infos (need sanitization)
	PhoneNumber string
	Email       string
	Categories  string
	Comment     string
	Name        string

	// Generated infos
	CourseName  string
	LectureHall string
	StreamUrl   string
	CombIP      string
	CameraIP    string
	IsLecturer  bool
	Stream      model.Stream
	User        model.User
}

AlertMessage contains all information that is needed for a debugging message. This should later be extended with a custom message field that can be filled on the stream page.

type Bot

type Bot struct {
	Method MessageProvider
}

Bot is the bot that will be used to send messages to the chat.

func (*Bot) SendAlert

func (b *Bot) SendAlert(alert AlertMessage, statsDao dao.StatisticsDao) error

SendAlert sends an alert message to the bot e.g. via Matrix.

func (*Bot) SendMessage

func (b *Bot) SendMessage(message Message) error

SendMessage sends a message via the bot that abstracts the provider.

func (*Bot) SetMessagingMethod

func (b *Bot) SetMessagingMethod(method MessageProvider)

SetMessagingMethod sets the provider method for sending messages e.g. Matrix

type Matrix

type Matrix struct{}

Matrix strategy

func (*Matrix) SendBotMessage

func (m *Matrix) SendBotMessage(message Message) error

SendBotMessage sends a formatted message to a matrix room with id roomID.

type Message

type Message struct {
	Text           string
	Prio           bool
	ProviderMethod MessageProvider
}

Message is a generic message that will be forwarded via the implementation specified via ProviderMethod.

type MessageProvider

type MessageProvider interface {
	SendBotMessage(message Message) error
}

MessageProvider provides a generic interface for different message providers e.g. Matrix

Jump to

Keyboard shortcuts

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