5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 11:40:27 +00:00

Strip IRC colors. Closes #33

This commit is contained in:
Wim 2016-09-21 00:33:40 +02:00
parent 272eef544f
commit 1d240140c9

View File

@ -6,6 +6,7 @@ import (
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
ircm "github.com/sorcix/irc" ircm "github.com/sorcix/irc"
"github.com/thoj/go-ircevent" "github.com/thoj/go-ircevent"
"regexp"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@ -158,6 +159,9 @@ func (b *Birc) handlePrivMsg(event *irc.Event) {
msg = event.Nick + " " msg = event.Nick + " "
} }
msg += event.Message() msg += event.Message()
// strip IRC colors
re := regexp.MustCompile(`[[:cntrl:]]\d+,\d`)
msg = re.ReplaceAllString(msg, "")
flog.Debugf("Sending message from %s on %s to gateway", event.Arguments[0], b.FullOrigin()) flog.Debugf("Sending message from %s on %s to gateway", event.Arguments[0], b.FullOrigin())
b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()} b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()}
} }