Strip IRC colors sent to Whatsapp

This commit is contained in:
chotaire
2019-04-17 03:35:03 +02:00
parent a156513b8c
commit ed5635f9d2

View File

@@ -8,6 +8,7 @@ import (
"os"
"strings"
"time"
"regexp"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
@@ -243,6 +244,10 @@ func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error {
func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg)
// Strip IRC colors sent to Whatsapp
re := regexp.MustCompile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`)
msg.Text = re.ReplaceAllString(msg.Text, "")
// Delete message
if msg.Event == config.EventMsgDelete {
if msg.ID == "" {