forked from alexandre-normand/slackscot
/
versioner.go
31 lines (27 loc) · 966 Bytes
/
versioner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package plugins provides a collection of example (and usable) plugins for instances
// of slackscot
package plugins
import (
"fmt"
"github.com/alexandre-normand/slackscot"
"strings"
)
// Versioner holds the plugin data for the karma plugin
type Versioner struct {
slackscot.Plugin
}
const (
versionerPluginName = "versioner"
)
// NewVersioner creates a new instance of the versioner plugin
func NewVersioner(name string, version string) *Versioner {
return &Versioner{Plugin: slackscot.Plugin{Name: versionerPluginName, Commands: []slackscot.ActionDefinition{{
Match: func(m *slackscot.IncomingMessage) bool {
return strings.HasPrefix(m.NormalizedText, "version")
},
Usage: "version",
Description: fmt.Sprintf("Reply with `%s`'s `version` number", name),
Answer: func(m *slackscot.IncomingMessage) *slackscot.Answer {
return &slackscot.Answer{Text: fmt.Sprintf("I'm `%s`, version `%s`", name, version)}
}}}, HearActions: nil}}
}