Documentation
¶
Index ¶
- Variables
- func AdaptOpts(opts ...slack.MsgOption) url.Values
- func ReplyTo(ctx context.Context, msg *slackevents.MessageEvent, rtm RTM, text string)
- type AllHandler
- type AlwaysMatcher
- type AnyMatch
- type BotIMMatch
- type ChannelToggler
- type ConditionalHandler
- type ConversationGetter
- type ConversationInfoGetter
- type Dedupe
- type FirstMatch
- type FirstWordRegistry
- type Handler
- type HandlerFunc
- type MatchAll
- type MatchAny
- type MatchHandler
- type Matcher
- type MatcherFunc
- type MessageStartsWith
- type MessageType
- type NoPanic
- type Not
- type RTM
- 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 RTM) error { return nil })
var MentionRE = regexp.MustCompile(`<@(.+?)(?:\|(.+?))?>`)
Functions ¶
func ReplyTo ¶
func ReplyTo(ctx context.Context, msg *slackevents.MessageEvent, rtm RTM, 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.
type AlwaysMatcher ¶
An AlwaysMatcher always matches, and thus always calls the underlying Handler
type AnyMatch ¶
type AnyMatch[T any] []MatchHandler[T]
type BotIMMatch ¶
type BotIMMatch struct {
// contains filtered or unexported fields
}
func (*BotIMMatch) Match ¶
func (m *BotIMMatch) Match(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) 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 RTM) 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 RTM) 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.
type ConversationGetter ¶ added in v1.2.0
type ConversationInfoGetter ¶ added in v1.2.0
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 RTM) 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
type FirstWordRegistry ¶
type FirstWordRegistry map[string]Handler[*slackevents.MessageEvent]
func (FirstWordRegistry) Handle ¶
func (f FirstWordRegistry) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) error
func (FirstWordRegistry) Match ¶
func (f FirstWordRegistry) Match(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) bool
func (FirstWordRegistry) Register ¶
func (f FirstWordRegistry) Register(w string, h Handler[*slackevents.MessageEvent])
type Handler ¶
A Handler can do something with a slackMessage.
type HandlerFunc ¶
type MatchAll ¶
type MatchAny ¶
type MatcherFunc ¶
type MessageStartsWith ¶
type MessageStartsWith string
func (MessageStartsWith) Match ¶
func (msw MessageStartsWith) Match(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) 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 RTM) bool
type NoPanic ¶
type Not ¶
type RTM ¶ added in v1.2.0
type RTM interface { SendMessageContext(ctx context.Context, channelID string, options ...slack.MsgOption) (_channel string, _timestamp string, _text string, err error) AuthTestContext(ctx context.Context) (*slack.AuthTestResponse, error) AddReactionContext(ctx context.Context, reaction string, ref slack.ItemRef) error }
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 RTM) bool
type StaticResponse ¶
type StaticResponse string
func (StaticResponse) Handle ¶
func (s StaticResponse) Handle(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) error
type StringMatcher ¶
type StringMatcher string
func (StringMatcher) Match ¶
func (s StringMatcher) Match(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) bool
type UserMentionMatch ¶
func (*UserMentionMatch) Match ¶
func (m *UserMentionMatch) Match(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) 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 RTM) error
func (WhiteList) Match ¶
func (wl WhiteList) Match(ctx context.Context, data *slackevents.MessageEvent, rtm RTM) bool
Match only returns true for matched channels