morning

package
v3.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL