diff --git a/NTFServer.go b/NTFServer.go index 85eb5db..dff7f79 100644 --- a/NTFServer.go +++ b/NTFServer.go @@ -110,6 +110,7 @@ func NewNTFServer(configFile string, verbose bool) (*NTFServer, error) { } // Spawn upstream connections for all pre-existing known users + launchedAny := false for telegramUserId, telegramDisplayName := range ret.config.GroupChatMembers { hubNick, ok := ret.config.KnownUsers[telegramUserId] if !ok { @@ -120,6 +121,14 @@ func NewNTFServer(configFile string, verbose bool) (*NTFServer, error) { if err != nil { return nil, fmt.Errorf("Reconnecting upstream for '%s': %s", hubNick, err.Error()) // fatal } + + launchedAny = true + } + + // We have some bad edge cases if a telegram message comes in while the upstream + // connection is offline. Wait a bit after startup, to minimise failure cases + if launchedAny { + time.Sleep(5 * time.Second) } return &ret, nil