From a156513b8c16cffd72c58891b2a40765e0246b7f Mon Sep 17 00:00:00 2001 From: chotaire Date: Wed, 17 Apr 2019 03:33:21 +0200 Subject: [PATCH] Strip IRC colors sent to Telegram --- bridge/telegram/telegram.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 33d55bcd..4fc6d90d 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -4,6 +4,7 @@ import ( "html" "strconv" "strings" + "regexp" "github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge/config" @@ -91,6 +92,10 @@ func (b *Btelegram) Send(msg config.Message) (string, error) { } } + // Strip IRC colors sent to Telegram + re := regexp.MustCompile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`) + msg.Text = re.ReplaceAllString(msg.Text, "") + // edit the message if we have a msg ID if msg.ID != "" { return b.handleEdit(&msg, chatid)