From 4acb279a6785a43eeff7064c0b32ae306937b4d5 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Fri, 26 Jun 2015 02:12:09 -0500 Subject: [PATCH] loop UpdatesChan so it keeps getting updates --- updates.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/updates.go b/updates.go index 47e4608..a5168fa 100644 --- a/updates.go +++ b/updates.go @@ -5,17 +5,19 @@ func (bot *BotAPI) UpdatesChan(config UpdateConfig) (chan Update, error) { bot.Updates = make(chan Update, 100) go func() { - updates, err := bot.GetUpdates(config) - if err != nil { - panic(err) - } - - for _, update := range updates { - if update.UpdateID > config.Offset { - config.Offset = update.UpdateID + 1 + for { + updates, err := bot.GetUpdates(config) + if err != nil { + panic(err) } - bot.Updates <- update + for _, update := range updates { + if update.UpdateID > config.Offset { + config.Offset = update.UpdateID + 1 + } + + bot.Updates <- update + } } }()