mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 00:30:02 +00:00
24 lines
849 B
Go
24 lines
849 B
Go
// Package slice contains slice manipulation helpers
|
|
package slice
|
|
|
|
import (
|
|
"github.com/Luzifer/go_helpers/v2/str"
|
|
"github.com/Luzifer/twitch-bot/v3/plugins"
|
|
)
|
|
|
|
// Register provides the plugins.RegisterFunc
|
|
func Register(args plugins.RegistrationArguments) error {
|
|
args.RegisterTemplateFunction("inList", plugins.GenericTemplateFunctionGetter(func(search string, list ...string) bool {
|
|
return str.StringInSlice(search, list)
|
|
}), plugins.TemplateFuncDocumentation{
|
|
Description: "Tests whether a string is in a given list of strings (for conditional templates).",
|
|
Syntax: "inList <search> <...string>",
|
|
Example: &plugins.TemplateFuncDocumentationExample{
|
|
MatchMessage: "!command (.*)",
|
|
MessageContent: "!command foo",
|
|
Template: `{{ inList (group 1) "foo" "bar" }}`,
|
|
ExpectedOutput: "true",
|
|
},
|
|
})
|
|
return nil
|
|
}
|