Add channel variable for templating

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-12-26 01:36:18 +01:00
parent fc97d525f4
commit ab42decb1b
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D
2 changed files with 5 additions and 0 deletions

View File

@ -71,6 +71,10 @@ func formatMessage(tplString string, m *irc.Message, r *rule, fields map[string]
fields["permitTimeout"] = int64(*&config.PermitTimeout / time.Second)
fields["username"] = m.User
if m.Command == "PRIVMSG" && len(m.Params) > 0 {
fields["channel"] = m.Params[0]
}
buf := new(bytes.Buffer)
err = tpl.Execute(buf, fields)

View File

@ -60,6 +60,7 @@ rules: # See below for examples
There are certain variables available in the strings with templating enabled:
- `channel` - Channel the message was sent to, only available for regular messages not events
- `msg` - The message object, used in functions, should not be sent to chat
- `permitTimeout` - Value of `permit_timeout` in seconds
- `username` - The username of the message author