Documentation ¶
Index ¶
- func AddFlags(opt *Options)
- func ValidateOptions(opt *Options) error
- type BotCommand
- type ClientDefaults
- type ClientOption
- type CommandDefinition
- type Options
- type ReplyDefaults
- type ReplyOption
- type ReportErrorDefaults
- type ReportErrorOption
- type Request
- type ResponseWriter
- type Slacker
- func (s *Slacker) Command(usage string, definition *CommandDefinition)
- func (s *Slacker) DefaultCommand(defaultMessageHandler func(request Request, response ResponseWriter))
- func (s *Slacker) Help(definition *CommandDefinition)
- func (s *Slacker) Listen(ctx context.Context) error
- func (s *Slacker) Run(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateOptions ¶
Types ¶
type BotCommand ¶
type BotCommand interface { Usage() string Definition() *CommandDefinition Match(text string) (*proper.Properties, bool) Tokenize() []*commander.Token Execute(request Request, response ResponseWriter) }
BotCommand interface
func NewBotCommand ¶
func NewBotCommand(usage string, definition *CommandDefinition) BotCommand
NewBotCommand creates a new bot command object
type ClientOption ¶
type ClientOption func(*ClientDefaults)
ClientOption an option for client values
type CommandDefinition ¶
type CommandDefinition struct { Description string Example string AuthorizationFunc func(request Request) bool Handler func(request Request, response ResponseWriter) }
CommandDefinition structure contains definition of the bot command
type ReplyDefaults ¶
type ReplyDefaults struct { Attachments []slack.Attachment Blocks []slack.Block ThreadResponse bool }
ReplyDefaults configuration
type ReplyOption ¶
type ReplyOption func(*ReplyDefaults)
ReplyOption an option for reply values
func WithAttachments ¶
func WithAttachments(attachments []slack.Attachment) ReplyOption
WithAttachments sets message attachments
func WithThreadReply ¶
func WithThreadReply(useThread bool) ReplyOption
WithThreadReply specifies the reply to be inside a thread of the original message
type ReportErrorDefaults ¶
type ReportErrorDefaults struct {
ThreadResponse bool
}
ReportErrorDefaults configuration
type ReportErrorOption ¶
type ReportErrorOption func(*ReportErrorDefaults)
ReportErrorOption an option for report error values
func WithThreadError ¶
func WithThreadError(useThread bool) ReportErrorOption
WithThreadError specifies the reply to be inside a thread of the original message
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() *slackevents.MessageEvent Properties() *proper.Properties }
Request interface that contains the Event received and parameters
func NewRequest ¶
func NewRequest(ctx context.Context, event *slackevents.MessageEvent, properties *proper.Properties) Request
NewRequest creates a new Request structure
type ResponseWriter ¶
type ResponseWriter interface { Reply(text string, options ...ReplyOption) error ReportError(err error, options ...ReportErrorOption) Client() *slack.Client }
A ResponseWriter interface is used to respond to an event
func NewResponse ¶
func NewResponse(event *slackevents.MessageEvent, client *slack.Client) ResponseWriter
NewResponse creates a new response structure
type Slacker ¶
type Slacker struct {
// contains filtered or unexported fields
}
func (*Slacker) Command ¶
func (s *Slacker) Command(usage string, definition *CommandDefinition)
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) Help ¶
func (s *Slacker) Help(definition *CommandDefinition)
Help handle the help message, it will use the default if not set