Documentation ¶
Index ¶
- Variables
- func ReplyTo(ctx context.Context, msg *slackevents.MessageEvent, rtm *socketmode.Client, ...)
- type AllHandler
- type AlwaysMatcher
- type AnyMatch
- type BotIMMatch
- type ChannelToggler
- type ConditionalHandler
- type Dedupe
- type FirstMatch
- type FirstWordRegistry
- func (f FirstWordRegistry) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) error
- func (f FirstWordRegistry) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
- func (f FirstWordRegistry) Register(w string, h Handler[*slackevents.MessageEvent])
- type Handler
- type HandlerFunc
- type MatchAll
- type MatchAny
- type MatchHandler
- type Matcher
- type MatcherFunc
- type MessageStartsWith
- type MessageType
- type NoPanic
- type Not
- type RegexpMatcher
- type StaticResponse
- type StringMatcher
- type UserMentionMatch
- type WhiteList
Constants ¶
This section is empty.
Variables ¶
var DropMessage = HandlerFunc[any](func(ctx context.Context, data any, rtm *socketmode.Client) error { return nil })
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 ¶
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 ¶
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 BotIMMatch ¶
type BotIMMatch struct {
// contains filtered or unexported fields
}
func (*BotIMMatch) Match ¶
func (m *BotIMMatch) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
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 ¶
func (c ChannelToggler) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) error
Handle for ChannelToggler toggles channels off/on or calls a subhandler.
func (ChannelToggler) Match ¶
func (c ChannelToggler) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
type ConditionalHandler ¶
func MustMatch ¶
func MustMatch(re string, h Handler[*slackevents.MessageEvent]) *ConditionalHandler[*slackevents.MessageEvent]
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 (f FirstWordRegistry) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) error
func (FirstWordRegistry) Match ¶
func (f FirstWordRegistry) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
func (FirstWordRegistry) Register ¶
func (f FirstWordRegistry) Register(w string, h Handler[*slackevents.MessageEvent])
type HandlerFunc ¶
func (HandlerFunc[T]) Handle ¶
func (f HandlerFunc[T]) Handle(ctx context.Context, data T, rtm *socketmode.Client) error
type MatchHandler ¶
type MatcherFunc ¶
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 ¶
func (msw MessageStartsWith) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
type MessageType ¶
type MessageType string
const ( SubtypeBotMessage MessageType = "bot_message" SubtypeReply MessageType = "message_replied" )
func (MessageType) Match ¶
func (m MessageType) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
type RegexpMatcher ¶
RegexpMatcher implements Matcher by checking message text against a regexp.
func (RegexpMatcher) Match ¶
func (r RegexpMatcher) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
type StaticResponse ¶
type StaticResponse string
func (StaticResponse) Handle ¶
func (s StaticResponse) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) error
type StringMatcher ¶
type StringMatcher string
func (StringMatcher) Match ¶
func (s StringMatcher) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
type UserMentionMatch ¶
func (*UserMentionMatch) Match ¶
func (m *UserMentionMatch) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
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 (wl WhiteList) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) error
func (WhiteList) Match ¶
func (wl WhiteList) Match(ctx context.Context, data *slackevents.MessageEvent, rtm *socketmode.Client) bool
Match only returns true for matched channels