Hi there! Could anyone explain to me the weirdness of

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?

15 ответов

12 просмотров

1. Happens in less than 1 sec, probably

Vadim-Vainshtein Автор вопроса
Yegor
1. Happens in less than 1 sec, probably

But then it should be 30 messages, not 20?

Vadim Vainshtein
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.

Vadim-Vainshtein Автор вопроса
Yegor
30 msgs are waiting on the side of telegram. You t...

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.

Vadim-Vainshtein Автор вопроса
NY 
Have you tried them with the same chat? 429 error...

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

Vadim-Vainshtein Автор вопроса
Covfefe
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...

Vadim Vainshtein
You mean this "20 messages per minute" limit? Yes,...

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

Vadim-Vainshtein Автор вопроса
Vadim Vainshtein
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

Vadim-Vainshtein Автор вопроса
Covfefe
429 contains data that specifies how many seconds ...

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

Vadim Vainshtein
Yeah, thank you. Of course I could do it, but I ac...

Well unless they talk directly to the bot I guess

Vadim-Vainshtein Автор вопроса
Covfefe
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!

Vadim Vainshtein
I'll think about it, that could be a solution for ...

not sure if the limit is per chat...Would be crazy if it is

Похожие вопросы

Карта сайта