bot

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCommand

func RegisterCommand(factory CommandFactory)

RegisterCommand registers a new command if not already done.

Types

type Bot

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

Bot is the struct for the slack bot.

func New

func New(authorizer *auth.Authorizer, cfg *config.SlackConfig, logger log.Logger) (*Bot, error)

New returns a new Bot or an error.

func (*Bot) ListenAndRespond

func (b *Bot) ListenAndRespond(stop <-chan struct{})

ListenAndRespond will make the bot listen to events and respond o them.

type Command

type Command interface {

	// Init maybe used for initializing the command.
	Init() error

	// Describe returns a short description of the command.
	Describe() string

	// Keywords is a list of strings which trigger this command.
	Keywords() []string

	// IsDisabled can be used to (temporarily) disable a command.
	IsDisabled() bool

	// RequiredUserRole returns the UserRole required to run the command.
	// Should at least return auth.UserRoles.Base .
	RequiredUserRole() auth.UserRole

	// Run executes the command and returns the response or an error.
	Run(originalMsg *slack.Msg) (*slack.Msg, error)
}

Command is the interface for slack bot commands.

type CommandFactory

type CommandFactory func() Command

Jump to

Keyboard shortcuts

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