all repos — telegram-bot-api @ 4acb279a6785a43eeff7064c0b32ae306937b4d5

Golang bindings for the Telegram Bot API

loop UpdatesChan so it keeps getting updates
Syfaro syfaro@foxpaw.in
Fri, 26 Jun 2015 02:12:09 -0500
commit

4acb279a6785a43eeff7064c0b32ae306937b4d5

parent

a17651c8fe1a7072a086d5da4cd93b69a0ad5ce9

1 files changed, 11 insertions(+), 9 deletions(-)

jump to
M updates.goupdates.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 + } } }()