From 206b682f393e8d2974d53bb08c4985b661e365fb Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 20 Jan 2021 23:45:09 +0100 Subject: [PATCH] Add toLower / toUpper functions Signed-off-by: Knut Ahlers --- msgformatter.go | 5 +++++ wiki/Home.md | 2 ++ 2 files changed, 7 insertions(+) diff --git a/msgformatter.go b/msgformatter.go index 4fb37de..5e179c3 100644 --- a/msgformatter.go +++ b/msgformatter.go @@ -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 { diff --git a/wiki/Home.md b/wiki/Home.md index 18eb1d7..038b695 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -83,6 +83,8 @@ Additionally there are some functions available in the templates: - `group ` - Gets matching group specified by index from `match_message` regular expression - `recentGame [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 ` - Takes the message sent to the channel, returns the value of the tag specified +- `toLower ` - Converts the given string to lower-case +- `toUpper ` - Converts the given string to upper-case ## Command executions