Strip IRC colors relayed to Rocketchat
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/42wim/matterbridge/bridge"
|
"github.com/42wim/matterbridge/bridge"
|
||||||
"github.com/42wim/matterbridge/bridge/config"
|
"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, "#")
|
msg.Channel = strings.TrimPrefix(msg.Channel, "#")
|
||||||
channel := &models.Channel{ID: b.getChannelID(msg.Channel), Name: 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
|
// Make a action /me of the message
|
||||||
if msg.Event == config.EventUserAction {
|
if msg.Event == config.EventUserAction {
|
||||||
msg.Text = "_" + msg.Text + "_"
|
msg.Text = "_" + msg.Text + "_"
|
||||||
|
|||||||
Reference in New Issue
Block a user