loop UpdatesChan so it keeps getting updates

bot-api-6.1
Syfaro 2015-06-26 02:12:09 -05:00
parent a17651c8fe
commit 4acb279a67
1 changed files with 11 additions and 9 deletions

View File

@ -5,17 +5,19 @@ func (bot *BotAPI) UpdatesChan(config UpdateConfig) (chan Update, error) {
bot.Updates = make(chan Update, 100) bot.Updates = make(chan Update, 100)
go func() { go func() {
updates, err := bot.GetUpdates(config) for {
if err != nil { updates, err := bot.GetUpdates(config)
panic(err) if err != nil {
} panic(err)
for _, update := range updates {
if update.UpdateID > config.Offset {
config.Offset = update.UpdateID + 1
} }
bot.Updates <- update for _, update := range updates {
if update.UpdateID > config.Offset {
config.Offset = update.UpdateID + 1
}
bot.Updates <- update
}
} }
}() }()