Thumbnail

rani/matterbridge.git

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

commit b6621ed5b16953e813bb32f0bf1beb1451b027d2 Author: Wim <wim@42.be> Date: Tue Mar 06 21:34:55 2018 +0000 Add support for NoSendJoinPart. Closes #382 diff --git a/bridge/config/config.go b/bridge/config/config.go index 42a87f1..831ea57 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -876 +877 @@ type Protocol struct {   NickServPassword string // IRC   NicksPerRow int // mattermost, slack   NoHomeServerSuffix bool // matrix + NoSendJoinPart bool // all protocols   NoTLS bool // mattermost   Password string // IRC,mattermost,XMPP,matrix   PrefixMessagesWithNick bool // mattemost, slack diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index df1b7df..ccaf027 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -3026 +3029 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {   }   }   if event.Source.Name != b.Nick { + if b.GetBool("nosendjoinpart") { + return + }   b.Log.Debugf("<= Sending JOIN_LEAVE event from %s to gateway", b.Account)   msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}   b.Log.Debugf("<= Message is %#v", msg) diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 334bb09..7a3806a 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -4006 +4009 @@ func (b *Bmattermost) skipMessage(message *matterclient.Message) bool {   if message.Type == "system_join_leave" ||   message.Type == "system_join_channel" ||   message.Type == "system_leave_channel" { + if b.GetBool("nosendjoinpart") { + return true + }   b.Log.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account)   b.Remote <- config.Message{Username: "system", Text: message.Text, Channel: message.Channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}   return true diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index a42c7e7..7912988 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -6196 +61910 @@ func (b *Bslack) sendWebhook(msg config.Message) (string, error) {    // skipMessageEvent skips event that need to be skipped :-)  func (b *Bslack) skipMessageEvent(ev *slack.MessageEvent) bool { + if ev.SubType == "channel_leave" || ev.SubType == "channel_join" { + return b.GetBool("nosendjoinpart") + } +   // ignore pinned items   if ev.SubType == "pinned_item" || ev.SubType == "unpinned_item" {   return true diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 2f4d470..0e74f7e 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1356 +13511 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#Do not send joins/parts to other bridges +#Currently works for messages from the following bridges: irc, mattermost, slack +#OPTIONAL (default false) +NoSendJoinPart=false +  #StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285  #It will strip other characters from the nick  #OPTIONAL (default false) @@ -4466 +45111 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#Do not send joins/parts to other bridges +#Currently works for messages from the following bridges: irc, mattermost, slack +#OPTIONAL (default false) +NoSendJoinPart=false +  #StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285  #It will strip other characters from the nick  #OPTIONAL (default false) @@ -6366 +64611 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#Do not send joins/parts to other bridges +#Currently works for messages from the following bridges: irc, mattermost, slack +#OPTIONAL (default false) +NoSendJoinPart=false +  #StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285  #It will strip other characters from the nick  #OPTIONAL (default false)