After some time, the bot stops responding
fishkaoff opened this issue · comments
fishkaoff commented
When I launch the bot, it works well, but if I don't send messages to it for a while, it stops responding. Moreover, every time after a different time, sometimes 10 minutes, sometimes an hour. I want to note that the message reaches him by logs, but he does nothing.
code:
bot.go:
func (b *Bot) StartBot() {
updateConfig := tgbotapi.NewUpdate(0)
updateConfig.Timeout = 60
updates := b.Api.GetUpdatesChan(updateConfig)
log.Printf("Authorized on account %s", b.Api.Self.UserName)
b.handleUpdates(updates)
}
handleUpdatesFunction:
func (b *Bot) handleUpdates(updates tgbotapi.UpdatesChannel) {
for update := range updates {
if update.Message != nil && !update.Message.IsCommand() {
b.HandleMessage(update)
continue
}
if update.Message != nil && update.Message.IsCommand() {
b.HandleCommand(update)
continue
}
if update.CallbackQuery != nil {
callback := tgbotapi.NewCallback(update.CallbackQuery.ID, update.CallbackQuery.Data)
if _, err := b.Api.Request(callback); err != nil {
panic(err)
}
b.HandleCallback(update)
}
}
}
terminal when bot is not responding:
2023/07/05 23:35:01 Endpoint: getUpdates, response: {"ok":true,"result":[{"update_id":276294792,
"message":{"message_id":546,"from":{"id":925823120,"is_bot":false,"first_name":"fishkaoff","username":"fishkaoff","language_code":"en"},"chat":{"id":925823120,"first_name":"fishkaoff","username":"fishkaoff","type":"private"},"date":1688589301,"text":"\u0411\u0430\u043b\u0430\u043d\u0441\ud83d\udcb0"}}]}
2023/07/05 23:35:01 Endpoint: getUpdates, params: map[allowed_updates:null offset:276294793 timeout:20]
2023/07/05 23:35:05 Endpoint: getUpdates, response: {"ok":true,"result":[{"update_id":276294793,
"message":{"message_id":547,"from":{"id":925823120,"is_bot":false,"first_name":"fishkaoff","username":"fishkaoff","language_code":"en"},"chat":{"id":925823120,"first_name":"fishkaoff","username":"fishkaoff","type":"private"},"date":1688589305,"text":"\u0411\u0430\u043b\u0430\u043d\u0441\ud83d\udcb0"}}]}
2023/07/05 23:35:05 Endpoint: getUpdates, params: map[allowed_updates:null offset:276294794 timeout:20]
2023/07/05 23:35:25 Endpoint: getUpdates, response: {"ok":true,"result":[]}
2023/07/05 23:35:25 Endpoint: getUpdates, params: map[allowed_updates:null offset:276294794 timeout:20]
DenisKozlovsky commented
@fishkaoff
I have the same problem. How did you solve it?