node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

Offset Issue if Error

Open Beyondem opened this issue 11 years ago • 6 comments

If the first message received back has a problem (Such as a group chat that kicked the bot) the offset will not update.

You will be stuck in an endless loop with offset being 0.

As a temporary fix for myself, i edited the source and added my offset in and now my bot is working again. @ExcuseBot

Beyondem avatar Jul 25 '15 19:07 Beyondem

I can't reproduce your issue, I've tested with stickers as you are commenting in the other issue and it's working normal.

First request:

Polling with options: {"qs":{"offset":1,"timeout":0},"url":"https://api.telegram.org/botTOKEN/getUpdates"} +5ms
polling data [{"update_id":784639540,"message":{"message_id":472,"from":{"id":1234,"..."},"chat":{"id":1234,"..."},"date":1437946658,"sticker":{"width":400,"height":512,"thumb":{"file_id":"...","file_size":2350,"width":100,"height":128},"file_id":"...","file_size":10452}}}] +193ms

Updates the offset:

updated offset: 784639540 +0ms

The next request:

Polling with options: {"qs":{"offset":784639541,"timeout":0},"url":"https://api.telegram.org/botTOKEN/getUpdates"}

yagop avatar Jul 26 '15 21:07 yagop

Hmm very strange, I'll have to re-download the source (as i butchered mine to make it work temporarily) and see if it still happens

Beyondem avatar Jul 27 '15 21:07 Beyondem

Same issue here, as i mentioned in the https://github.com/yagop/node-telegram-bot-api/issues/36 post.

vhdmsm avatar Oct 03 '15 17:10 vhdmsm

@yagop

I also had this issue and a user was flooded with response and eventually blocked bot and that took down the bot-server all because of this loop.

Question: Why do we set the offset only when it's the last item to process? what's wrong with just setting it after each item (i.e. get rid of the if)?

I also think there need to be a much more reliable error handling around the self.callback -- i.e. wrap with try/catch as opposed to let it bubble to the promise error handler.

what do you think?

mvalipour avatar Nov 09 '15 22:11 mvalipour

@yagop any updates on this? I keep running into this issue - I've nailed it down a bit:

  • sometimes events get "stuck" and I keep receiving the same message, command, etc events
  • calling /getUpdates with a super high offset fixes the issue
  • it seems to happen when many events get sent in a short amount of time
  • I tried spamming a python bot that also uses the default long polling options - no issues there

omnidan avatar Apr 26 '16 22:04 omnidan

Please proceed to issue #36 as it handles this particular bug!

Thanks @Beyondem, @mvalipour and @omnidan for your time and effort in this. See you there!

gochomugo avatar Dec 21 '16 14:12 gochomugo