Documentation ¶
Overview ¶
Package actions provides a fluent API for creating slackscot plugin actions. Typical usages will also involve using the plugin fluent API from github.com/alexandre-normand/slackscot/plugin.
Plugin examples using this API can be found in github.com/alexandre-normand/slackscot/plugins but a quick one could look like:
import ( "github.com/alexandre-normand/slackscot" "github.com/alexandre-normand/slackscot/plugin" "github.com/alexandre-normand/slackscot/actions" ) func newPlugin() (p *slackscot.Plugin) { p = plugin.New("maker"). WithCommand(actions.NewCommand(). WithMatcher(func(m *slackscot.IncomingMessage) bool { return strings.HasPrefix(m.NormalizedText, "make") }). WithUsage("make <something>"). WithDescription("Make the `<something>` you need"). WithAnswerer(func(m *slackscot.IncomingMessage) *slackscot.Answer { return &slackscot.Answer{Text: fmt.Sprintf(":white_check_mark: It's ready for you!")} }). Build() ). WithHearAction(actions.NewHearAction(). Hidden(). WithMatcher(func(m *slackscot.IncomingMessage) bool { return strings.HasPrefix(m.NormalizedText, "chirp") }). WithAnswerer(func(m *slackscot.IncomingMessage) *slackscot.Answer { return &slackscot.Answer{Text: "Did I hear a bird?"} }). Build() ). WithScheduledAction(actions.NewScheduledAction(). WithSchedule(schedule.New().Every(time.Monday.string()).AtTime("10:00").Build()). WithDescription("Start the week off"). WithAction(weeklyKickoff). Build() ). Build() return p }
Index ¶
- type ActionBuilder
- func (ab *ActionBuilder) Build() slackscot.ActionDefinition
- func (ab *ActionBuilder) Hidden() *ActionBuilder
- func (ab *ActionBuilder) WithAnswerer(answerer slackscot.Answerer) *ActionBuilder
- func (ab *ActionBuilder) WithDescription(description string) *ActionBuilder
- func (ab *ActionBuilder) WithDescriptionf(format string, a ...interface{}) *ActionBuilder
- func (ab *ActionBuilder) WithMatcher(matcher slackscot.Matcher) *ActionBuilder
- func (ab *ActionBuilder) WithUsage(usage string) *ActionBuilder
- type ScheduledActionBuilder
- func (sab *ScheduledActionBuilder) Build() slackscot.ScheduledActionDefinition
- func (sab *ScheduledActionBuilder) WithAction(action slackscot.ScheduledAction) *ScheduledActionBuilder
- func (sab *ScheduledActionBuilder) WithDescription(desc string) *ScheduledActionBuilder
- func (sab *ScheduledActionBuilder) WithDescriptionf(format string, a ...interface{}) *ScheduledActionBuilder
- func (sab *ScheduledActionBuilder) WithSchedule(schedule schedule.Definition) *ScheduledActionBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionBuilder ¶
type ActionBuilder struct {
// contains filtered or unexported fields
}
ActionBuilder holds the action to build
func NewCommand ¶
func NewCommand() (ab *ActionBuilder)
NewCommand returns a new ActionBuilder to build a new command
func NewHearAction ¶
func NewHearAction() (ab *ActionBuilder)
NewHearAction returns a new ActionBuilder to build a new hear action
func (*ActionBuilder) Build ¶
func (ab *ActionBuilder) Build() slackscot.ActionDefinition
Build returns the ActionDefinition
func (*ActionBuilder) Hidden ¶
func (ab *ActionBuilder) Hidden() *ActionBuilder
Hidden sets the action to hidden
func (*ActionBuilder) WithAnswerer ¶
func (ab *ActionBuilder) WithAnswerer(answerer slackscot.Answerer) *ActionBuilder
WithAnswerer sets the action's answerer function
func (*ActionBuilder) WithDescription ¶
func (ab *ActionBuilder) WithDescription(description string) *ActionBuilder
WithDescription sets the action description
func (*ActionBuilder) WithDescriptionf ¶
func (ab *ActionBuilder) WithDescriptionf(format string, a ...interface{}) *ActionBuilder
WithDescriptionf sets the action description delegating format and arguments to fmt.Sprintf
func (*ActionBuilder) WithMatcher ¶
func (ab *ActionBuilder) WithMatcher(matcher slackscot.Matcher) *ActionBuilder
WithMatcher sets the action's matcher function
func (*ActionBuilder) WithUsage ¶
func (ab *ActionBuilder) WithUsage(usage string) *ActionBuilder
WithUsage sets the action usage
type ScheduledActionBuilder ¶
type ScheduledActionBuilder struct {
// contains filtered or unexported fields
}
ScheduledActionBuilder holds the scheduled action to build
func NewScheduledAction ¶
func NewScheduledAction() (sab *ScheduledActionBuilder)
NewScheduledAction returns a new ScheduledActionBuilder to build a new ScheduledActionDefinition
func (*ScheduledActionBuilder) Build ¶
func (sab *ScheduledActionBuilder) Build() slackscot.ScheduledActionDefinition
Build returns the ScheduledActionDefinition
func (*ScheduledActionBuilder) WithAction ¶
func (sab *ScheduledActionBuilder) WithAction(action slackscot.ScheduledAction) *ScheduledActionBuilder
WithAction sets the action function to run on schedule
func (*ScheduledActionBuilder) WithDescription ¶
func (sab *ScheduledActionBuilder) WithDescription(desc string) *ScheduledActionBuilder
WithDescription sets the scheduled action description
func (*ScheduledActionBuilder) WithDescriptionf ¶
func (sab *ScheduledActionBuilder) WithDescriptionf(format string, a ...interface{}) *ScheduledActionBuilder
WithDescriptionf sets the scheduled action description delegating format and arguments to fmt.Sprintf
func (*ScheduledActionBuilder) WithSchedule ¶
func (sab *ScheduledActionBuilder) WithSchedule(schedule schedule.Definition) *ScheduledActionBuilder
WithSchedule sets the schedule for the scheduled action