From 69d6f4b2daa50484cd370b67b4d776c1ce1268f6 Mon Sep 17 00:00:00 2001
From: Wim <wim@42.be>
Date: Sun, 13 Nov 2016 23:50:12 +0100
Subject: [PATCH] Remove double username modify. Fixes #77

---
 gateway/samechannel/samechannel.go | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/gateway/samechannel/samechannel.go b/gateway/samechannel/samechannel.go
index 2240ee84..60d0958d 100644
--- a/gateway/samechannel/samechannel.go
+++ b/gateway/samechannel/samechannel.go
@@ -4,7 +4,6 @@ import (
 	"github.com/42wim/matterbridge/bridge"
 	"github.com/42wim/matterbridge/bridge/config"
 	log "github.com/Sirupsen/logrus"
-	"strings"
 )
 
 type SameChannelGateway struct {
@@ -62,7 +61,6 @@ func (gw *SameChannelGateway) handleMessage(msg config.Message, dest bridge.Brid
 	if msg.FullOrigin == dest.FullOrigin() {
 		return
 	}
-	gw.modifyMessage(&msg, dest)
 	log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.FullOrigin, msg.Channel, dest.FullOrigin(), msg.Channel)
 	err := dest.Send(msg)
 	if err != nil {
@@ -70,29 +68,6 @@ func (gw *SameChannelGateway) handleMessage(msg config.Message, dest bridge.Brid
 	}
 }
 
-func setNickFormat(msg *config.Message, format string) {
-	if format == "" {
-		msg.Username = msg.Protocol + "." + msg.Origin + "-" + msg.Username + ": "
-		return
-	}
-	msg.Username = strings.Replace(format, "{NICK}", msg.Username, -1)
-	msg.Username = strings.Replace(msg.Username, "{BRIDGE}", msg.Origin, -1)
-	msg.Username = strings.Replace(msg.Username, "{PROTOCOL}", msg.Protocol, -1)
-}
-
-func (gw *SameChannelGateway) modifyMessage(msg *config.Message, dest bridge.Bridge) {
-	switch dest.Protocol() {
-	case "irc":
-		setNickFormat(msg, gw.Config.IRC[dest.Origin()].RemoteNickFormat)
-	case "mattermost":
-		setNickFormat(msg, gw.Config.Mattermost[dest.Origin()].RemoteNickFormat)
-	case "slack":
-		setNickFormat(msg, gw.Config.Slack[dest.Origin()].RemoteNickFormat)
-	case "discord":
-		setNickFormat(msg, gw.Config.Discord[dest.Origin()].RemoteNickFormat)
-	}
-}
-
 func (gw *SameChannelGateway) validChannel(channel string) bool {
 	for _, c := range gw.Channels {
 		if c == channel {