[template] Add mention function

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-05-27 21:58:58 +02:00
parent 1a023099d9
commit 12911c712f
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
2 changed files with 15 additions and 0 deletions

View file

@ -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{} { tplFuncs.Register("tag", func(m *irc.Message, r *plugins.Rule, fields *plugins.FieldCollection) interface{} {
return func(tag string) string { return func(tag string) string {
s, _ := m.GetTag(tag) s, _ := m.GetTag(tag)

View file

@ -246,6 +246,19 @@ Example:
< Last Quote: #32 < Last Quote: #32
``` ```
#### `mention`
Strips username and converts into a mention
Syntax: `mention <username>`
Example:
```
# {{ mention "@user" }} {{ mention "user" }} {{ mention "#user" }}
< @user @user @user
```
#### `pow` #### `pow`
Returns float from calculation: `float1 ** float2` Returns float from calculation: `float1 ** float2`