diff options
Diffstat (limited to 'bridge/zulip')
-rw-r--r-- | bridge/zulip/zulip.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go index 88832d36..3c6c7ec6 100644 --- a/bridge/zulip/zulip.go +++ b/bridge/zulip/zulip.go @@ -100,7 +100,30 @@ func (b *Bzulip) getChannel(id int) string { func (b *Bzulip) handleQueue() error { for { - messages, _ := b.q.GetEvents() + messages, err := b.q.GetEvents() + switch err { + case gzb.BackoffError: + time.Sleep(time.Second * 5) + case gzb.NoJSONError: + b.Log.Error("Response wasn't JSON, server down or restarting? sleeping 10 seconds") + time.Sleep(time.Second * 10) + case gzb.BadEventQueueError: + b.Log.Info("got a bad event queue id error, reconnecting") + b.bot.Queues = nil + b.q, err = b.bot.RegisterAll() + if err != nil { + b.Log.Errorf("reconnecting failed: %s. Sleeping 10 seconds", err) + time.Sleep(time.Second * 10) + continue + } + case gzb.HeartbeatError: + b.Log.Debug("heartbeat received.") + default: + b.Log.Debugf("receiving error: %#v", err) + } + if err != nil { + continue + } for _, m := range messages { b.Log.Debugf("== Receiving %#v", m) // ignore our own messages |