bot

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TypeInternal = "internal"

TypeInternal is only used internally to identify internal slack messages. @deprecated do not use it anymore

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(cfg config.Config) *log.Logger

GetLogger provides logger instance for the given config

func NewBot

func NewBot(cfg config.Config, slackClient *client.Slack, logger *log.Logger, commands *Commands) bot

NewBot created main bot struct which holds the slack connection and dispatch messages to commands

Types

type Command

type Command interface {
	GetMatcher() matcher.Matcher
}

Command is the main command struct which needs to provide the matcher and the actual executed action

type Commands

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

Commands is a wrapper of a list of commands. Only the first matched command will be executed

func (*Commands) AddCommand

func (c *Commands) AddCommand(commands ...Command)

AddCommand registers a command to the command list

func (*Commands) Count

func (c *Commands) Count() int

Count the registered/valid commands

func (*Commands) GetHelp

func (c *Commands) GetHelp() []Help

GetHelp returns the help for ALL included commands

func (*Commands) Merge

func (c *Commands) Merge(commands Commands)

Merge two list of commands

func (*Commands) Run

func (c *Commands) Run(event slack.MessageEvent) bool

Run executes the first matched command and return true in case one command matched

type Conditional

type Conditional interface {
	IsEnabled() bool
}

Conditional checks if the command should be activated. E.g. is dependencies are not present or it's disabled in the config

type Handler

type Handler interface {
	HandleMessages(kill chan os.Signal)
}

Handler is the main bot interface

type Help

type Help struct {
	Command     string
	Description string
	Examples    []string
}

Help command can provide help objects which are searchable by keywords

func (Help) GetKeywords

func (h Help) GetKeywords() []string

GetKeywords crates a string slice of help keywords -> used by fuzzy search

type HelpProvider

type HelpProvider interface {
	// each command should provide information, like a description or examples
	GetHelp() []Help
}

HelpProvider can be provided by a command to add information within "help" command

Directories

Path Synopsis
Package tester provides functionality to test the bot against a fake slack server
Package tester provides functionality to test the bot against a fake slack server

Jump to

Keyboard shortcuts

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