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

Stickers will crash!

Open Beyondem opened this issue 11 years ago • 5 comments

Receiving a sticker will put the bot in an infinite loop. It will error with the offset, never update the offset position and continuously try and fail.

Beyondem avatar Jul 26 '15 17:07 Beyondem

Seems this is a duplicated with your previous issue. Isn't it?

yagop avatar Jul 26 '15 21:07 yagop

yes, i get this too. was just trying with the debugger to see what was going on and getting the same sticker event just being received over and over from the poll.

is there a workaround way to modify the internal offset +1?

I'm using

        this.bot = new TelegramBot(token, {
            polling: true
        });

        // FIXME - same message repeats
        bot.on('sticker', function(input) {
            console.log("sticker", input);
            TelegramAdapter.showFileInfo(input);
        });

is there another way to use the service, with polling not webhook?

for example where can we set the value for long polling? is my understanding that to do that we would call getUpdates from the app and the app would have to keep track of the offset?

TelegramBot.prototype.getUpdates = function (timeout, limit, offset) {

when using long polling, more events will stream in, so the offset needs to be adjusted on each incoming event, not just when the poll is made?

Thanks for any advice.

dcsan avatar Aug 23 '15 09:08 dcsan

this works:

        bot.on('message', function(input) {
            console.log("message", input);
            if (input.sticker) {
                TelegramAdapter.showFileInfo(input.sticker, input.chat.id);
            }
            if (input.photo) {
                TelegramAdapter.showPhotoInfo(input.photo, input.chat.id);
            }
        });

btw related question - is there any way in the telegram UI for getting the file_id for a photo? that was why i had to write that little script above....

dcsan avatar Aug 23 '15 10:08 dcsan

With Telegram UI you means Web / Android / iOS client? None of them I think.

yagop avatar Nov 19 '15 13:11 yagop

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

Thanks @Beyondem and @dcsan for your time and effort in this. See you there!

gochomugo avatar Dec 21 '16 14:12 gochomugo