From 4b176ef0cc1dfe0aebdcef93863ba9f2a0a80049 Mon Sep 17 00:00:00 2001 From: chotaire Date: Wed, 17 Apr 2019 03:16:39 +0200 Subject: [PATCH] Strip IRC colors sent to Mattermost --- bridge/mattermost/mattermost.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index ce4f4c33..cdc62810 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -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 + "*"