hello

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: 4 Imported by: 0

Documentation

Overview

Package hello provides example code to setup relatively simple sarah.CommandProps.

In this example, instead of simply assigning regular expression to CommandPropsBuilder.MatchPattern, a function is set via CommandPropsBuilder.MatchFunc to do the equivalent task. With CommandPropsBuilder.MatchFunc, developers may define more complex matching logic than assigning simple regular expression to CommandPropsBuilder.MatchPattern. One more benefit is that strings package or other packages with higher performance can be used internally like this example.

This sarah.CommandProps can be fed to sarah.NewRunner() as below.

runner, err := sarah.NewRunner(config.Runner, sarah.WithCommandProps(hello.SlackProps), ... )

Index

Constants

This section is empty.

Variables

View Source
var SlackProps = sarah.NewCommandPropsBuilder().
	BotType(slack.SLACK).
	Identifier("hello").
	InputExample(".hello").
	MatchFunc(func(input sarah.Input) bool {
		return strings.HasPrefix(input.Message(), ".hello")
	}).
	Func(func(_ context.Context, _ sarah.Input) (*sarah.CommandResponse, error) {
		return slack.NewStringResponse("Hello, 世界"), nil
	}).
	MustBuild()

SlackProps is a pre-built hello 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