Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 27512cc794adb28be3275b0a017ca7c5560c375b Author: Wim <wim@42.be> Date: Sun Feb 17 22:43:04 2019 +0000 Support quits from irc correctly. Fixes #722 (#724) diff --git a/bridge/irc/handlers.go b/bridge/irc/handlers.go index ce4f044..a5df2d5 100644 --- a/bridge/irc/handlers.go +++ b/bridge/irc/handlers.go @@ -926 +9210 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {   return   }   b.Log.Debugf("<= Sending JOIN_LEAVE event from %s to gateway", b.Account) + // QUIT isn't channel bound, happens for all channels on the bridge + if event.Command == "QUIT" { + channel = "" + }   msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EventJoinLeave}   b.Log.Debugf("<= Message is %#v", msg)   b.Remote <- msg diff --git a/gateway/gateway.go b/gateway/gateway.go index f74a668..8b3ccf0 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -1767 +1766 @@ func (gw *Gateway) getDestChannel(msg *config.Message, dest bridge.Bridge) []con     // discord join/leave is for the whole bridge, isn't a per channel join/leave   if msg.Event == config.EventJoinLeave && dest.Protocol == "discord" && msg.Account == dest.Account { - flog.Error("here")   for _, channel := range gw.Channels {   if channel.Account == msg.Account && strings.Contains(channel.Direction, "out") &&   gw.validGatewayDest(msg) { @@ -1866 +18518 @@ func (gw *Gateway) getDestChannel(msg *config.Message, dest bridge.Bridge) []con   return channels   }   + // irc quit is for the whole bridge, isn't a per channel quit. + // channel is empty when we quit + if msg.Event == config.EventJoinLeave && getProtocol(msg) == "irc" && msg.Channel == "" { + for _, channel := range gw.Channels { + if channel.Account == dest.Account && strings.Contains(channel.Direction, "out") && + gw.validGatewayDest(msg) { + channels = append(channels, *channel) + } + } + return channels + } +   // if source channel is in only, do nothing   for _, channel := range gw.Channels {   // lookup the channel from the message @@ -4353 +4468 @@ func (gw *Gateway) ignoreText(text string, input []string) bool {   }   return false  } + +func getProtocol(msg *config.Message) string { + p := strings.Split(msg.Account, ".") + return p[0] +}