From ed5635f9d203958d2b2f19683fa48cbd7889dc56 Mon Sep 17 00:00:00 2001 From: chotaire Date: Wed, 17 Apr 2019 03:35:03 +0200 Subject: [PATCH] Strip IRC colors sent to Whatsapp --- bridge/whatsapp/whatsapp.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go index 286d463c..8649bdb4 100644 --- a/bridge/whatsapp/whatsapp.go +++ b/bridge/whatsapp/whatsapp.go @@ -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 == "" {