From e5989adf92cd5ea007b5e7d50580579f8581fee2 Mon Sep 17 00:00:00 2001 From: Wim Date: Tue, 6 Mar 2018 21:34:55 +0100 Subject: Add support for NoSendJoinPart. Closes #382 --- bridge/config/config.go | 1 + bridge/irc/irc.go | 3 +++ bridge/mattermost/mattermost.go | 3 +++ bridge/slack/slack.go | 4 ++++ matterbridge.toml.sample | 15 +++++++++++++++ 5 files changed, 26 insertions(+) diff --git a/bridge/config/config.go b/bridge/config/config.go index 42a87f1c..831ea575 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -87,6 +87,7 @@ 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 df1b7df7..ccaf0276 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -302,6 +302,9 @@ 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 334bb093..7a3806ab 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -400,6 +400,9 @@ 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 a42c7e78..7912988e 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -619,6 +619,10 @@ 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 2f4d470e..0e74f7e8 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -135,6 +135,11 @@ 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) @@ -446,6 +451,11 @@ 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) @@ -636,6 +646,11 @@ 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) -- cgit v1.2.3