Strip IRC colors sent to SSHChat

This commit is contained in:
chotaire
2019-04-17 03:28:45 +02:00
parent bb4c835e96
commit ea4948728c

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"io"
"strings"
"regexp"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
@@ -80,6 +81,11 @@ func (b *Bsshchat) Send(msg config.Message) (string, error) {
return b.handleUploadFile(&msg)
}
}
// Strip IRC colors sent to SSHChat
re := regexp.MustCompile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`)
msg.Text = re.ReplaceAllString(msg.Text, "")
_, err := b.w.Write([]byte(msg.Username + msg.Text + "\r\n"))
return "", err
}