mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
[template] Add inList
function
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
beb491f015
commit
b0d9b5782f
3 changed files with 28 additions and 0 deletions
11
internal/template/slice/slice.go
Normal file
11
internal/template/slice/slice.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package slice
|
||||
|
||||
import (
|
||||
"github.com/Luzifer/go_helpers/v2/str"
|
||||
"github.com/Luzifer/twitch-bot/plugins"
|
||||
)
|
||||
|
||||
func Register(args plugins.RegistrationArguments) error {
|
||||
args.RegisterTemplateFunction("inList", plugins.GenericTemplateFunctionGetter(str.StringInSlice))
|
||||
return nil
|
||||
}
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/Luzifer/twitch-bot/internal/apimodules/overlays"
|
||||
"github.com/Luzifer/twitch-bot/internal/template/numeric"
|
||||
"github.com/Luzifer/twitch-bot/internal/template/random"
|
||||
"github.com/Luzifer/twitch-bot/internal/template/slice"
|
||||
"github.com/Luzifer/twitch-bot/plugins"
|
||||
"github.com/Luzifer/twitch-bot/twitch"
|
||||
)
|
||||
|
@ -52,6 +53,7 @@ var (
|
|||
// Template functions
|
||||
numeric.Register,
|
||||
random.Register,
|
||||
slice.Register,
|
||||
|
||||
// API-only modules
|
||||
customevent.Register,
|
||||
|
|
|
@ -184,6 +184,21 @@ Example:
|
|||
< test - oops
|
||||
```
|
||||
|
||||
#### `inList`
|
||||
|
||||
Tests whether a string is in a given list of strings (for conditional templates).
|
||||
|
||||
Syntax: `inList "search" "item1" "item2" [...]`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
! !command (.*)
|
||||
> !command foo
|
||||
# {{ inList (group 1) "foo" "bar" }}
|
||||
< true
|
||||
```
|
||||
|
||||
#### `lastQuoteIndex`
|
||||
|
||||
Gets the last quote index in the quote database for the current channel
|
||||
|
|
Loading…
Reference in a new issue