matcher

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 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 Matcher

type Matcher interface {
	Match(message msg.Message) (Runner, Result)
}

Matcher is executed for each command and checks if it should execute the Runner for the given event text when a Runner is returned, it matched and we can execute the Runner in the next step

func NewAdminMatcher

func NewAdminMatcher(admins config.UserList, slackClient client.SlackClient, matcher Matcher) Matcher

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

func NewGroupMatcher

func NewGroupMatcher(matcher ...Matcher) Matcher

NewGroupMatcher is a matcher that iterates through the list of specified sub-matchers ...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 regexp. 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)

func WildcardMatcher

func WildcardMatcher(run wildcardRunner) Matcher

WildcardMatcher will pass all messages into the runner. The runner needs to check if the event is relevant or not if the runner returns "true", the command is marked as executed and no other commands are checked

type Result

type Result map[string]string

Result implements the Result interface and is a wrapper for map[string]string

func (Result) GetInt

func (m Result) GetInt(key string) int

GetInt returns a parameter, casted as int

func (Result) GetString

func (m Result) GetString(key string) string

GetString returns a parameter, casted as string

type Runner

type Runner func(match Result, message msg.Message)

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