commit 2eb0973c22c8357e34cb190cdfe8e92f28503d5f
Author: Wim <wim@42.be>
Date: Mon Nov 20 23:27:27 2017 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index f26e60b..afb9f1a 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -596 +5910 @@ type Protocol struct {
IgnoreMessages string // all protocols
Jid string // xmpp
Login string // mattermost, matrix
+ MessageQueue int // IRC, size of message queue for flood control
+ MessageDelay int // IRC, time in millisecond to wait between messages
+ MessageLength int // IRC, max length of a message allowed
+ MessageFormat string // telegram
Muc string // xmpp
Name string // all protocols
Nick string // all protocols
@@ -7112 +759 @@ type Protocol struct {
NoTLS bool // mattermost
Password string // IRC,mattermost,XMPP,matrix
PrefixMessagesWithNick bool // mattemost, slack
- Protocol string //all protocols
- ReplaceMessages [][]string // all messages
- MessageQueue int // IRC, size of message queue for flood control
- MessageDelay int // IRC, time in millisecond to wait between messages
- MessageLength int // IRC, max length of a message allowed
- MessageFormat string // telegram
+ Protocol string // all protocols
+ ReplaceMessages [][]string // all protocols
+ ReplaceNicks [][]string // all protocols
RemoteNickFormat string // all protocols
Server string // IRC,mattermost,XMPP,discord
ShowJoinPart bool // all protocols
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 8a0a666..be03a99 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -2546 +25420 @@ 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