Documentation ¶
Overview ¶
package slot gives some helpful abstractions over the nlopes/slack RTM integrations. Most use cases are intended to be made easier. The common bot response abstraction is the Responder. Many implementations will be created to assist in most of the common bot use cases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAction ¶
func GetAction(ev *slack.MessageEvent) string
GetAction takes an event and returns either the empty string, or the first !action string in the message text.
func MaybeRespond ¶
MaybeRespond checks if a Responder is a MatchResponder and conditionally exits if there is no match.
Types ¶
type ActionMap ¶
ActionMap holds action words and responders, calling the appropriate responder when an !action message is received.
type Bot ¶
type Bot struct { Responders []Responder // contains filtered or unexported fields }
A Bot handles a client
type BotMentionAction ¶
type BotMentionAction struct { FollowingText string Responder Responder // contains filtered or unexported fields }
BotMentionAction executes a responder if the bot's name is @mentioned
func (*BotMentionAction) Match ¶
func (b *BotMentionAction) Match(rtm *slack.RTM, ev *slack.MessageEvent) bool
Match implements MatchResponder
func (*BotMentionAction) Respond ¶
func (b *BotMentionAction) Respond(rtm *slack.RTM, ev *slack.MessageEvent) error
Respond implements Responder
type MatchResponder ¶
A MatchResponder conditionally acts on a message
type RegexResponder ¶
RegexResponder matches a regex against an incoming string and executes a response if a match occurred
func (*RegexResponder) Match ¶
func (r *RegexResponder) Match(rtm *slack.RTM, ev *slack.MessageEvent) bool
Match implements MatchResponder
func (*RegexResponder) Respond ¶
func (r *RegexResponder) Respond(rtm *slack.RTM, ev *slack.MessageEvent) error
Respond implements Responder
type Responder ¶
type Responder interface {
Respond(*slack.RTM, *slack.MessageEvent) error
}
A Responder handles an event
type ResponderFunc ¶
type ResponderFunc func(*slack.RTM, *slack.MessageEvent) error
An ResponderFunc is a function that can respond to a slack event
func (ResponderFunc) Respond ¶
func (f ResponderFunc) Respond(r *slack.RTM, ev *slack.MessageEvent) error
Respond implements Responder.
type StringFuncResponder ¶
type StringFuncResponder func() string
StringFuncResponder always responds with the result of calling the function
func (StringFuncResponder) Respond ¶
func (s StringFuncResponder) Respond(r *slack.RTM, ev *slack.MessageEvent) error
Respond implements Responder
type TextResponder ¶
type TextResponder string
TextResponder always responds with a string
func (TextResponder) Respond ¶
func (p TextResponder) Respond(r *slack.RTM, ev *slack.MessageEvent) error
Respond implements Responder