slander

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DropMessage = HandlerFunc[any](func(ctx context.Context, data any, rtm *socketmode.Client) error {
	return nil
})
View Source
var MentionRE = regexp.MustCompile(`<@(.+?)(?:\|(.+?))?>`)

Functions

func ReplyTo

func ReplyTo(ctx context.Context, msg *slackevents.MessageEvent, rtm *socketmode.Client, text string)

ReplyTo takes an rtm and slack message and sends the given text as a response to the message or the thread the message was a part of.

Types

type AllHandler

type AllHandler[T any] []Handler[T]

AllHandler runs all handlers in the underlying slice for each message.

func (AllHandler[T]) Handle

func (a AllHandler[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error

Handle implements Handler by running all its underlying handlers.

func (AllHandler[T]) Match

func (a AllHandler[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type AlwaysMatcher

type AlwaysMatcher[T any] struct {
	Handler[T]
}

An AlwaysMatcher always matches, and thus always calls the underlying Handler

func (AlwaysMatcher[T]) Match

func (a AlwaysMatcher[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type AnyMatch

type AnyMatch[T any] []MatchHandler[T]

func (AnyMatch[T]) Handle

func (a AnyMatch[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error

func (AnyMatch[T]) Match

func (a AnyMatch[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type BotIMMatch

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

func (*BotIMMatch) Match

type ChannelToggler

type ChannelToggler struct {
	Redis *redis.Client
	Name  string
	Handler[*slackevents.MessageEvent]
	Default bool
}

ChannelToggler uses Redis to store state on whether channels want certain handlers.

func (ChannelToggler) Handle

Handle for ChannelToggler toggles channels off/on or calls a subhandler.

func (ChannelToggler) Match

type ConditionalHandler

type ConditionalHandler[T any] struct {
	Handler[T]
	Matcher[T]
}

func MustMatch

MustMatch is a convenience wrapper for creating ConditionalHandlers using the regexp matcher, which is commonly desired.

func (ConditionalHandler[T]) Handle

func (c ConditionalHandler[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error

type Dedupe

type Dedupe struct {
	Handler[*slackevents.MessageEvent]
	// contains filtered or unexported fields
}

func (*Dedupe) Handle

func (d *Dedupe) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) error

type FirstMatch

type FirstMatch[T any] []MatchHandler[T]

FirstMatch checks all handlers to find whichever handler matches first.

func IgnoreChannels

func IgnoreChannels(blacklisted []string, h Handler[*slackevents.MessageEvent]) FirstMatch[*slackevents.MessageEvent]

IgnoreChannels returns a FirstMatch handler that does not pass messages through to the handler channels

func (FirstMatch[T]) Handle

func (f FirstMatch[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error

func (FirstMatch[T]) Match

func (f FirstMatch[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

Match implements Matcher by finding out if any subs match a message.

type FirstWordRegistry

type FirstWordRegistry map[string]Handler[*slackevents.MessageEvent]

func (FirstWordRegistry) Handle

func (FirstWordRegistry) Match

func (FirstWordRegistry) Register

type Handler

type Handler[T any] interface {
	Handle(ctx context.Context, data T, rtm *socketmode.Client) error
}

A Handler can do something with a slackMessage.

type HandlerFunc

type HandlerFunc[T any] func(ctx context.Context, data T, rtm *socketmode.Client) error

func (HandlerFunc[T]) Handle

func (f HandlerFunc[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error

type MatchAll

type MatchAll[T any] []Matcher[T]

func (MatchAll[T]) Match

func (a MatchAll[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type MatchAny

type MatchAny[T any] []Matcher[T]

func (MatchAny[T]) Match

func (m MatchAny[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type MatchHandler

type MatchHandler[T any] interface {
	Handler[T]
	Matcher[T]
}

type Matcher

type Matcher[T any] interface {
	Match(ctx context.Context, data T, rtm *socketmode.Client) bool
}

type MatcherFunc

type MatcherFunc[T any] func(ctx context.Context, data T, rtm *socketmode.Client) bool

func (MatcherFunc[T]) Match

func (f MatcherFunc[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type MessageStartsWith

type MessageStartsWith string

func (MessageStartsWith) Match

type MessageType

type MessageType string
const (
	SubtypeBotMessage MessageType = "bot_message"
	SubtypeReply      MessageType = "message_replied"
)

func (MessageType) Match

type NoPanic

type NoPanic[T any] struct {
	Handler[T]
}

func (*NoPanic[T]) Handle

func (n *NoPanic[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error

type Not

type Not[T any] struct {
	Matcher Matcher[T]
}

func (Not[T]) Match

func (n Not[T]) Match(ctx context.Context, data T, rtm *socketmode.Client) bool

type RegexpMatcher

type RegexpMatcher struct {
	Regexp *regexp.Regexp
}

RegexpMatcher implements Matcher by checking message text against a regexp.

func (RegexpMatcher) Match

type StaticResponse

type StaticResponse string

func (StaticResponse) Handle

type StringMatcher

type StringMatcher string

func (StringMatcher) Match

type UserMentionMatch

type UserMentionMatch struct {
	User *slack.User
	// contains filtered or unexported fields
}

func (*UserMentionMatch) Match

type WhiteList

type WhiteList struct {
	Channels []string
	Handler[*slackevents.MessageEvent]
}

WhiteList allows a subhandler to conditionally handle based on a predefined list.

func (WhiteList) Handle

func (WhiteList) Match

Match only returns true for matched channels

Jump to

Keyboard shortcuts

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