Documentation ¶
Index ¶
- type BotCommand
- type Request
- type Response
- type ResponseWriter
- type Slacker
- func (s *Slacker) Command(usage string, description string, ...)
- func (s *Slacker) DefaultCommand(defaultMessageHandler func(request Request, response ResponseWriter))
- func (s *Slacker) DefaultEvent(defaultEventHandler func(interface{}))
- func (s *Slacker) Err(errorHandler func(err string))
- func (s *Slacker) Help(helpHandler func(request Request, response ResponseWriter))
- func (s *Slacker) Init(initHandler func())
- func (s *Slacker) Listen() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotCommand ¶
type BotCommand struct {
// contains filtered or unexported fields
}
BotCommand structure contains the bot's command, description and handler
func NewBotCommand ¶
func NewBotCommand(usage string, description string, handler func(request Request, response ResponseWriter)) *BotCommand
NewBotCommand creates a new bot command object
func (*BotCommand) Execute ¶
func (c *BotCommand) Execute(request Request, response ResponseWriter)
Execute executes the handler logic
func (*BotCommand) Match ¶
func (c *BotCommand) Match(text string) (*proper.Properties, bool)
Match determines whether the bot should respond based on the text received
func (*BotCommand) Tokenize ¶
func (c *BotCommand) Tokenize() []*commander.Token
Tokenize returns the command format's tokens
type Request ¶
type Request interface { Param(key string) string StringParam(key string, defaultValue string) string BooleanParam(key string, defaultValue bool) bool IntegerParam(key string, defaultValue int) int FloatParam(key string, defaultValue float64) float64 Context() context.Context Event() *slack.MessageEvent Properties() *proper.Properties }
Request interface that contains the Event received and parameters
func NewRequest ¶
func NewRequest(ctx context.Context, event *slack.MessageEvent, properties *proper.Properties) Request
NewRequest creates a new Request structure
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response contains the channel and Real Time Messaging library
func NewResponse ¶
NewResponse creates a new response structure
func (*Response) ReportError ¶
ReportError sends back a formatted error message to the channel where we received the event from
type ResponseWriter ¶
type ResponseWriter interface { Reply(text string) Reply(text string, attachments *[]slack.Attachment) ReportError(err error) Typing() RTM() *slack.RTM Client() *slack.Client }
A ResponseWriter interface is used to respond to an event
type Slacker ¶
type Slacker struct { Client *slack.Client RTM *slack.RTM // contains filtered or unexported fields }
Slacker contains the Slack API, botCommands, and handlers
func (*Slacker) Command ¶
func (s *Slacker) Command(usage string, description string, handler func(request Request, response ResponseWriter))
Command define a new command and append it to the list of existing commands
func (*Slacker) DefaultCommand ¶
func (s *Slacker) DefaultCommand(defaultMessageHandler func(request Request, response ResponseWriter))
DefaultCommand handle messages when none of the commands are matched
func (*Slacker) DefaultEvent ¶
func (s *Slacker) DefaultEvent(defaultEventHandler func(interface{}))
DefaultEvent handle events when an unknown event is seen
func (*Slacker) Help ¶
func (s *Slacker) Help(helpHandler func(request Request, response ResponseWriter))
Help handle the help message, it will use the default if not set