change focus from bot to just bindings, code cleanup
This commit is contained in:
parent
5d6f84e9b2
commit
9cf4f13772
9 changed files with 728 additions and 1188 deletions
22
updates.go
Normal file
22
updates.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package tgbotapi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
bot.Updates <- update
|
||||
}
|
||||
}()
|
||||
|
||||
return bot.Updates, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue