From 991183e5147f2d9078e8e88979ced1356d9d1796 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 21 Jan 2017 21:00:40 +0100 Subject: Fix IgnoreNicks (global). Closes #115 --- gateway/samechannel/samechannel.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'gateway/samechannel') diff --git a/gateway/samechannel/samechannel.go b/gateway/samechannel/samechannel.go index 5ea58b84..bd8e3607 100644 --- a/gateway/samechannel/samechannel.go +++ b/gateway/samechannel/samechannel.go @@ -47,8 +47,10 @@ func (gw *SameChannelGateway) handleReceive(c chan config.Message) { for { select { case msg := <-c: - for _, br := range gw.Bridges { - gw.handleMessage(msg, br) + if !gw.ignoreMessage(&msg) { + for _, br := range gw.Bridges { + gw.handleMessage(msg, br) + } } } } @@ -71,6 +73,16 @@ func (gw *SameChannelGateway) handleMessage(msg config.Message, dest *bridge.Bri } } +func (gw *SameChannelGateway) ignoreMessage(msg *config.Message) bool { + for _, entry := range strings.Fields(gw.Bridges[msg.Account].Config.IgnoreNicks) { + if msg.Username == entry { + log.Debugf("ignoring %s from %s", msg.Username, msg.Account) + return true + } + } + return false +} + func (gw *SameChannelGateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) { br := gw.Bridges[msg.Account] nick := gw.Config.General.RemoteNickFormat -- cgit v1.2.3