Strip IRC colors relayed to Rocketchat

This commit is contained in:
chotaire
2019-04-17 03:03:37 +02:00
parent f7ed9e53fa
commit 454776d786

View File

@@ -4,6 +4,7 @@ import (
"errors"
"strings"
"sync"
"regexp"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
@@ -108,6 +109,10 @@ func (b *Brocketchat) Send(msg config.Message) (string, error) {
msg.Channel = strings.TrimPrefix(msg.Channel, "#")
channel := &models.Channel{ID: b.getChannelID(msg.Channel), Name: msg.Channel}
// Strip IRC colors sent to Rocketchat
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 + "_"