summaryrefslogtreecommitdiffstats
path: root/gateway/samechannel/samechannel.go
diff options
context:
space:
mode:
Diffstat (limited to 'gateway/samechannel/samechannel.go')
-rw-r--r--gateway/samechannel/samechannel.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/gateway/samechannel/samechannel.go b/gateway/samechannel/samechannel.go
index 23c4152b..47dfeb99 100644
--- a/gateway/samechannel/samechannel.go
+++ b/gateway/samechannel/samechannel.go
@@ -54,13 +54,17 @@ func (gw *SameChannelGateway) handleReceive(c chan config.Message) {
}
}
-func (gw *SameChannelGateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
+func (gw *SameChannelGateway) handleMessage(msg config.Message, dest bridge.Bridge) {
+ // is this a configured channel
+ if !gw.validChannel(msg.Channel) {
+ return
+ }
// do not send the message to the bridge we come from if also the channel is the same
if msg.Account == dest.Account {
return
}
gw.modifyUsername(&msg, dest)
- log.Debugf("Sending %#v from %s to %s", msg, msg.Account, dest.Account)
+ log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, msg.Channel, dest.Account, msg.Channel)
err := dest.Send(msg)
if err != nil {
log.Error(err)
@@ -75,3 +79,12 @@ func (gw *SameChannelGateway) modifyUsername(msg *config.Message, dest *bridge.B
nick = strings.Replace(nick, "{PROTOCOL}", br.Protocol, -1)
msg.Username = nick
}
+
+func (gw *SameChannelGateway) validChannel(channel string) bool {
+ for _, c := range gw.Channels {
+ if c == channel {
+ return true
+ }
+ }
+ return false
+}