From bb4c835e96ab06899536408e13a416e235adce3c Mon Sep 17 00:00:00 2001 From: chotaire Date: Wed, 17 Apr 2019 03:26:35 +0200 Subject: [PATCH] Strip IRC colors sent to Slack --- bridge/slack/slack.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 36b74b99..2fcf807f 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -7,6 +7,7 @@ import ( "strings" "sync" "time" + "regexp" "github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge/config" @@ -181,6 +182,10 @@ func (b *Bslack) Send(msg config.Message) (string, error) { msg.Text = b.replaceCodeFence(msg.Text) + // Strip IRC colors sent to Slack + 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 + "_"