From 9190365289f841f6764741d36d54bde0f8f2b623 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 19 Apr 2020 00:46:35 +0200 Subject: [PATCH] Add JoinDelay option (irc). Fixes #1084 (#1098) --- bridge/bridge.go | 2 ++ bridge/config/config.go | 1 + matterbridge.toml.sample | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/bridge/bridge.go b/bridge/bridge.go index 5612e35d..eec2bfaf 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -4,6 +4,7 @@ import ( "log" "strings" "sync" + "time" "github.com/42wim/matterbridge/bridge/config" "github.com/sirupsen/logrus" @@ -74,6 +75,7 @@ func (b *Bridge) joinChannels(channels map[string]config.ChannelInfo, exists map for ID, channel := range channels { if !exists[ID] { b.Log.Infof("%s: joining %s (ID: %s)", b.Account, channel.Name, ID) + time.Sleep(time.Duration(b.GetInt("JoinDelay")) * time.Millisecond) err := b.JoinChannel(channel) if err != nil { return err diff --git a/bridge/config/config.go b/bridge/config/config.go index ea62d7cc..dfb71eec 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -89,6 +89,7 @@ type Protocol struct { IgnoreNicks string // all protocols IgnoreMessages string // all protocols Jid string // xmpp + JoinDelay string // all protocols Label string // all protocols Login string // mattermost, matrix MediaDownloadBlackList []string diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 0aca45f2..4082b6dc 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -177,6 +177,12 @@ StripNick=false #OPTIONAL (default false) ShowTopicChange=false +#Delay in milliseconds between channel joins +#Only useful when you have a LOT of channels to join +#See https://github.com/42wim/matterbridge/issues/1084 +#OPTIONAL (default 0) +JoinDelay=0 + ################################################################### #XMPP section ###################################################################