matcher

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapResult

type MapResult map[string]string

func (MapResult) GetInt

func (m MapResult) GetInt(key string) int

func (MapResult) GetString

func (m MapResult) GetString(key string) string

func (MapResult) Matched

func (m MapResult) Matched() bool

func (MapResult) MatchedString

func (m MapResult) MatchedString() string

type Matcher

type Matcher interface {
	Match(event slack.MessageEvent) (Runner, Result)
}

Matcher is executed for each command and checks if it should execute the Runner for the given event text

func NewAdminMatcher

func NewAdminMatcher(cfg config.Config, slackClient client.SlackClient, matcher Matcher) Matcher

NewAdminMatcher is a wrapper to only executable by a whitelisted admin user

func NewConditionalMatcher

func NewConditionalMatcher(run conditionalRunner) Matcher

func NewGroupMatcher

func NewGroupMatcher(matcher ...Matcher) Matcher

NewGroupMatcher is a matcher which go through the list of given sub-matcher...just define multiple matcher in a chain/group

func NewPrefixMatcher

func NewPrefixMatcher(prefix string, run Runner) Matcher

NewPrefixMatcher accepts command which starts with the given prefix Example: prefix for "random" "random" -> match "random 1 2 3" -> match "randomness" -> no match

func NewRegexpMatcher

func NewRegexpMatcher(regexpString string, run Runner) Matcher

NewRegexpMatcher matches a command based on a given prefix. 2 additional rules: - it's case insensitive - it always has to match the full line (adding ^ and $ implicitly)

func NewTextMatcher

func NewTextMatcher(text string, run Runner) Matcher

NewTextMatcher match messages by full text (case insensitive)

func NewVoidMatcher

func NewVoidMatcher() Matcher

NewVoidMatcher just do nothing (might be useful when a command is not loadable because dependencies are not configures)

type ReResult

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

func (ReResult) GetInt

func (m ReResult) GetInt(key string) int

func (ReResult) GetString

func (m ReResult) GetString(key string) string

func (ReResult) Matched

func (m ReResult) Matched() bool

func (ReResult) MatchedString

func (m ReResult) MatchedString() string

type Result

type Result interface {
	GetString(key string) string
	GetInt(key string) int
	MatchedString() string
	Matched() bool
}

type Runner

type Runner func(match Result, event slack.MessageEvent)

Runner contains the actual logic of the executed command. gets the actual slack MessageEvent and the matched parameters of the message

Jump to

Keyboard shortcuts

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