summaryrefslogtreecommitdiffstats
path: root/gateway/gateway.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-11-20 23:27:27 +0100
committerWim <wim@42.be>2017-11-20 23:27:27 +0100
commitcd4c9b194fe486bcea08c1b9166e1ac22508ab00 (patch)
tree40c6ac0715228f10259ec31c4bcc4050a3a11387 /gateway/gateway.go
parent98762a02356d41857e8a474daba602e8d258d5b9 (diff)
downloadmatterbridge-msglm-cd4c9b194fe486bcea08c1b9166e1ac22508ab00.tar.gz
matterbridge-msglm-cd4c9b194fe486bcea08c1b9166e1ac22508ab00.tar.bz2
matterbridge-msglm-cd4c9b194fe486bcea08c1b9166e1ac22508ab00.zip
Add support for ReplaceNicks using regexp to replace nicks. Closes #269
Diffstat (limited to 'gateway/gateway.go')
-rw-r--r--gateway/gateway.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 8a0a666f..be03a99b 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -254,6 +254,20 @@ func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) strin
if nick == "" {
nick = gw.Config.General.RemoteNickFormat
}
+
+ // loop to replace nicks
+ for _, outer := range br.Config.ReplaceNicks {
+ search := outer[0]
+ replace := outer[1]
+ // TODO move compile to bridge init somewhere
+ re, err := regexp.Compile(search)
+ if err != nil {
+ log.Errorf("regexp in %s failed: %s", msg.Account, err)
+ break
+ }
+ msg.Username = re.ReplaceAllString(msg.Username, replace)
+ }
+
if len(msg.Username) > 0 {
// fix utf-8 issue #193
i := 0