telegram-bot-api
telegram-bot-api copied to clipboard
Problems with debugging of bot.shutdownChannel throwing
Hello there,
I'm trying to run the code with the given example of getting all the updates from chat. It runs OK on my computer, but it definitely fails on an AWS EC2 instance.
It fails with "assignment mismatch: 2 variables but bot.GetUpdatesChan returns 1 value"
, so it fails on this function in bot.go
:
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error) {
ch := make(chan Update, bot.Buffer)
go func() {
for {
select {
case <-bot.shutdownChannel:
return
default:
}
updates, err := bot.GetUpdates(config)
if err != nil {
log.Println(err)
log.Println("Failed to get updates, retrying in 3 seconds...")
time.Sleep(time.Second * 3)
continue
}
for _, update := range updates {
if update.UpdateID >= config.Offset {
config.Offset = update.UpdateID + 1
ch <- update
}
}
}
}()
return ch, nil
}
So, the only place, where this function returns a single value, is after throwing <-bot.shutdownChannel
But the problem is, I can't find any place, except the function (bot *BotAPI) StopReceivingUpdates()
(and at least any use of this function), which could throw bot.shutdownChannel, so I can't find the cause of the error.
I'll appreciate any help.
The master branch just received a rather substantial update with a few breaking changes. One of these changes includes no longer returning the always nil error from GetUpdatesChan
. Is it possible you're trying to pull a different version than you're using locally?
https://github.com/go-telegram-bot-api/telegram-bot-api/blob/3834565c356e9b2d94bd8080555aeaf795bbb0ea/bot.go#L430-L431