Add toLower / toUpper functions

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-01-20 23:45:09 +01:00
parent 092143d5c7
commit 206b682f39
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D
2 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,11 @@ func formatMessage(tplString string, m *irc.Message, r *rule, fields map[string]
// Create anonymous functions in current context in order to access function variables
messageFunctions := korvike.GetFunctionMap()
// Generic functions
messageFunctions["toLower"] = strings.ToLower
messageFunctions["toUpper"] = strings.ToUpper
// Message specific functions
messageFunctions["arg"] = func(arg int) (string, error) {
msgParts := strings.Split(m.Trailing(), " ")
if len(msgParts) <= arg {

View File

@ -83,6 +83,8 @@ Additionally there are some functions available in the templates:
- `group <idx>` - Gets matching group specified by index from `match_message` regular expression
- `recentGame <username> [fallback]` - Returns the last played game name of the specified user (see shoutout example) or the `fallback` if the game could not be fetched. If no fallback was supplied the message will fail and not be sent.
- `tag <tagname>` - Takes the message sent to the channel, returns the value of the tag specified
- `toLower <string>` - Converts the given string to lower-case
- `toUpper <string>` - Converts the given string to upper-case
## Command executions