Documentation ¶
Overview ¶
Package morning provides example code to setup sarah.CommandProps with relatively complex matching function.
This setting does not simply provide regular expression via CommandPropsBuilder.MatchPattern, but instead provide whole matching function to implement complex matcher.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var SlackProps = sarah.NewCommandPropsBuilder(). BotType(slack.SLACK). Identifier("morning"). InstructionFunc(func(input *sarah.HelpInput) string { hour := time.Now().Hour() if 12 < hour { return "" } return "Input .morning to greet." }). MatchFunc(func(input sarah.Input) bool { match := strings.HasPrefix(input.Message(), ".morning") if !match { return false } hour := time.Now().Hour() return hour >= 0 && hour < 12 }). Func(func(_ context.Context, input sarah.Input) (*sarah.CommandResponse, error) { return slack.NewResponse(input, "Good morning.") }). MustBuild()
SlackProps is a pre-built morning command properties for Slack.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.