the limitations I see while testing my long polling bot? The bot is an admin in a supergroup, and the idea is that it should respond to any message that users post. I performed two tests, which I thought would give a similar result:
1. With my bot switched off (i.e., not asking for updates), I posted 30 messages into the chat. Then I started my bot, it got all the updates, and after responding to 20 of them, it hit the 429 error. That's predictable, as it's described in the Bot API FAQ. But then I performed the second test:
2. With the bot switched on (i.e., constantly receiving updates), I posted my 30 messages as fast as I could (in ~15 seconds), and the bot responded to them all, without hitting the "20 messages per minute" limit.
In both cases, I got 30 updates and sent 30 sendMessage requests, so what makes the difference?
1. Happens in less than 1 sec, probably
But then it should be 30 messages, not 20?
30 msgs are waiting on the side of telegram. You turn the bot on, it processes and sends back to TG server his msgs. TG processes them one by one, and at 20th gives your bot a stop signal. All that in less than 1 sec. Not sure about 20 msgs / min limit, but it is probably something else. Bot can send 1 message / second easily.
Ah, sorry, I didn't say, of course I've tried the delays of 1 second between the messages, the result was just the same
Have you tried them with the same chat? 429 error occur when the chat have slow mode.
Yes, it's the same chat. Sorry for my ignorance, what is "slow mode"? Could it be somehow disabled?
You technically could hit 2 one minute frames
You mean this "20 messages per minute" limit? Yes, definitely I hit it. Actually, the question is, why do not I hit it when typing the messages with the bot receiving updates immediately? As for me, both situations are quite similar...
I think server records how many messages you have sent in given minute. So if you ended up sending part in one minute and part in the next minute it won't give you 429 since limit already reset
Ah, I see... Thanks, I'll check that!
429 contains data that specifies how many seconds to wait before your limit is reset. You could use that to wait and retry or just spread the messages with 3 second interval
Yeah, thank you. Of course I could do it, but I actually need a bot, that is able to respond to a lot of messages, so that users would not wait for a long time after they posted a message. Perhaps it's impossible due to the limits
Well unless they talk directly to the bot I guess
I'll think about it, that could be a solution for my task. Thank you for the idea!
not sure if the limit is per chat...Would be crazy if it is
Обсуждают сегодня