all repos — telegram-bot-api @ cea0df2dae12eccb41669acd95203f3a691da2b0

Golang bindings for the Telegram Bot API

updates.go (view raw)

 1package tgbotapi
 2
 3func (bot *BotApi) UpdatesChan(config UpdateConfig) (chan Update, error) {
 4	bot.Updates = make(chan Update, 100)
 5
 6	go func() {
 7		updates, err := bot.GetUpdates(config)
 8		if err != nil {
 9			panic(err)
10		}
11
12		for _, update := range updates {
13			if update.UpdateId > config.Offset {
14				config.Offset = update.UpdateId + 1
15			}
16
17			bot.Updates <- update
18		}
19	}()
20
21	return bot.Updates, nil
22}