[msgformatter] Fix: Trim leading / trailing spaces

in order to support templating resulting in `/me` message

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-07-16 21:45:14 +02:00
parent 847e119e5d
commit 9e2628c6e3
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -3,6 +3,7 @@ package main
import ( import (
"bytes" "bytes"
"regexp" "regexp"
"strings"
"text/template" "text/template"
"time" "time"
@ -57,7 +58,7 @@ func formatMessage(tplString string, m *irc.Message, r *plugins.Rule, fields *pl
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
err = tpl.Execute(buf, compiledFields.Data()) err = tpl.Execute(buf, compiledFields.Data())
return buf.String(), errors.Wrap(err, "execute template") return strings.TrimSpace(buf.String()), errors.Wrap(err, "execute template")
} }
func formatMessageFieldChannel(compiledFields *plugins.FieldCollection, m *irc.Message, fields *plugins.FieldCollection) { func formatMessageFieldChannel(compiledFields *plugins.FieldCollection, m *irc.Message, fields *plugins.FieldCollection) {