go-sarah: github.com/oklahomer/go-sarah/examples/simple/plugins/count Index | Files

package count

import "github.com/oklahomer/go-sarah/examples/simple/plugins/count"

Package count provides example code to setup sarah.CommandProps.

One counter instance is shared between two CommandPropsBuilder.Func, which means resulting Slack/Gitter Commands access to same counter instance. This illustrates that, when multiple Bots are registered to Runner, same memory space can be shared.

Index

Package Files

props.go

Variables

var GitterProps = sarah.NewCommandPropsBuilder().
    BotType(gitter.GITTER).
    Identifier("counter").
    Instruction("Input .count to count up").
    MatchPattern(regexp.MustCompile(`^\.count`)).
    Func(func(_ context.Context, _ sarah.Input) (*sarah.CommandResponse, error) {
        return gitter.NewResponse(fmt.Sprint(globalCounter.increment()))
    }).
    MustBuild()

GitterProps is a pre-built count command properties for Slack.

var SlackProps = sarah.NewCommandPropsBuilder().
    BotType(slack.SLACK).
    Identifier("counter").
    Instruction("Input .count to count up").
    MatchPattern(regexp.MustCompile(`^\.count`)).
    Func(func(_ context.Context, input sarah.Input) (*sarah.CommandResponse, error) {
        return slack.NewResponse(input, fmt.Sprint(globalCounter.increment()))
    }).
    MustBuild()

SlackProps is a pre-built count command properties for Slack.

Package count imports 7 packages (graph). Updated 2020-09-27. Refresh now. Tools for package owners.