summaryrefslogtreecommitdiffstats
path: root/gateway
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-21 17:04:03 +0200
committerWim <wim@42.be>2017-07-21 17:04:03 +0200
commitd3eef051b1c08cc583eadfaeb358c22215fd5851 (patch)
treef20f21daadb7b939e94c24ed8bfde2c3dbce5525 /gateway
parent57654df81e989a6a693504d223b70374d9af043d (diff)
downloadmatterbridge-msglm-d3eef051b1c08cc583eadfaeb358c22215fd5851.tar.gz
matterbridge-msglm-d3eef051b1c08cc583eadfaeb358c22215fd5851.tar.bz2
matterbridge-msglm-d3eef051b1c08cc583eadfaeb358c22215fd5851.zip
Fix message modification
Diffstat (limited to 'gateway')
-rw-r--r--gateway/gateway.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go
index fa1e6348..431955c8 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -218,8 +218,8 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
}
log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, originchannel, dest.Account, channel.Name)
msg.Channel = channel.Name
- gw.modifyAvatar(&msg, dest)
- gw.modifyUsername(&msg, dest)
+ msg.Avatar = gw.modifyAvatar(origmsg, dest)
+ msg.Username = gw.modifyUsername(origmsg, dest)
// for api we need originchannel as channel
if dest.Protocol == "api" {
msg.Channel = originchannel
@@ -259,7 +259,7 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
return false
}
-func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) {
+func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) string {
br := gw.Bridges[msg.Account]
msg.Protocol = br.Protocol
nick := gw.Config.General.RemoteNickFormat
@@ -281,10 +281,10 @@ func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) {
nick = strings.Replace(nick, "{NICK}", msg.Username, -1)
nick = strings.Replace(nick, "{BRIDGE}", br.Name, -1)
nick = strings.Replace(nick, "{PROTOCOL}", br.Protocol, -1)
- msg.Username = nick
+ return nick
}
-func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) {
+func (gw *Gateway) modifyAvatar(msg config.Message, dest *bridge.Bridge) string {
iconurl := gw.Config.General.IconURL
if iconurl == "" {
iconurl = dest.Config.IconURL
@@ -293,6 +293,7 @@ func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) {
if msg.Avatar == "" {
msg.Avatar = iconurl
}
+ return msg.Avatar
}
func (gw *Gateway) modifyMessage(msg *config.Message) {