Strip IRC colors sent to Mattermost

This commit is contained in:
chotaire
2019-04-17 03:16:39 +02:00
parent 454776d786
commit 4b176ef0cc

View File

@@ -3,6 +3,7 @@ package bmattermost
import (
"errors"
"fmt"
"regexp"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
@@ -98,6 +99,10 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
}
b.Log.Debugf("=> Receiving %#v", msg)
// Strip IRC colors sent to Mattermost
re := regexp.MustCompile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`)
msg.Text = re.ReplaceAllString(msg.Text, "")
// Make a action /me of the message
if msg.Event == config.EventUserAction {
msg.Text = "*" + msg.Text + "*"