all repos — telegram-bot-api @ 04d46c28963e882622edc2b1a543e598ccdb5bfc

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}