morning

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2019 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").
	InputExample(".morning").
	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, _ sarah.Input) (*sarah.CommandResponse, error) {
		return slack.NewStringResponse("Good morning."), nil
	}).
	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