From 12911c712fd8406acbc7c993a91236d5538f1262 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 27 May 2023 21:58:58 +0200 Subject: [PATCH] [template] Add `mention` function Signed-off-by: Knut Ahlers --- functions_irc.go | 2 ++ wiki/Templating.md | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/functions_irc.go b/functions_irc.go index 432a7e4..50c844f 100644 --- a/functions_irc.go +++ b/functions_irc.go @@ -56,6 +56,8 @@ func init() { } }) + tplFuncs.Register("mention", plugins.GenericTemplateFunctionGetter(func(username string) string { return "@" + strings.TrimLeft(username, "@#") })) + tplFuncs.Register("tag", func(m *irc.Message, r *plugins.Rule, fields *plugins.FieldCollection) interface{} { return func(tag string) string { s, _ := m.GetTag(tag) diff --git a/wiki/Templating.md b/wiki/Templating.md index fa5dc25..42b4f67 100644 --- a/wiki/Templating.md +++ b/wiki/Templating.md @@ -246,6 +246,19 @@ Example: < Last Quote: #32 ``` +#### `mention` + +Strips username and converts into a mention + +Syntax: `mention ` + +Example: + +``` +# {{ mention "@user" }} {{ mention "user" }} {{ mention "#user" }} +< @user @user @user +``` + #### `pow` Returns float from calculation: `float1 ** float2`