Good afternoon people! I'm building a bot and started receiving

429 errors. Could you please help me clarify the following: 20 messages per minute limit applies to groups and not individual chats with a bot, or if my bot's user sends /start 20 times inside a 60 seconds period this will result in 429 as well? Sending less than 30 messages per second (my bot works with 1-on-1 chats, not groups) and getting 429 error. Could you please advise on how to approach this issue?

7 ответов

9 просмотров

Obviously, use queue or several queues for message sending

Victor-Khodalov Автор вопроса
Sery
Obviously, use queue or several queues for message...

how would you do this? my current solution: im using aws for my telegram bot, I have webhooks delivered to rest api gateway-> inbound fifo queue->inbound lambda (sends 200 status to telegram)->outbound fifo queue->outbound lambda (sends messages to users). The documention says this: When sending messages inside a particular chat, avoid sending more than one message per second. We may allow short bursts that go over this limit, but eventually you'll begin receiving 429 errors. If you're sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8—12 hours for best results. Also note that your bot will not be able to send more than 20 messages per minute to the same group. Does the 20 messages per minute limit also apply to individual chats with a bot, not just groups? I'm trying to understand what caused the 429 error in my case. Looks like im sending less than 30 messages per second to all users at any given second. So i wonder if it's the 1 message per second or 20 messages per limit (if this limit applies to the individual chats with the bot) that I'm hitting.

Victor Khodalov
how would you do this? my current solution: im usi...

I don`t use webhooks. My current implementation includes one queue for all users and one per chat for chats. All queues connected to own and shared limiters. But it is overengineering, my bot never reaches limits

Victor Khodalov
how would you do this? my current solution: im usi...

Even if you prefer webhooks you can try this way: When update is received, it is added to queue (first in, first out). Then your bot begins parsing updates in this queue. It polls the update and processes it. Then it waits some time (51ms will guarantee you not sending more than 20 messages in different chats within 1 second) before processing next request. If the current request didn't result into 200, you add it's update back to query

Victor-Khodalov Автор вопроса
s0m31 🇷🇺
Even if you prefer webhooks you can try this way: ...

could you please clarify. there are 3 types of limits i can hit: 1. 30 messages per second (to all users or to one user at a time) 2. 20 messages per minute (to a given chat with the user) 3. 1 message per second (to a given chat with a user. Do I get it right or the second limit (20 msgs per minute only applies to groups and not individual chats? I got this info from the bots faq section, here's the text: When sending messages inside a particular chat, avoid sending more than one message per second. We may allow short bursts that go over this limit, but eventually you'll begin receiving 429 errors. If you're sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8—12 hours for best results. Also note that your bot will not be able to send more than 20 messages per minute to the same group.

Victor Khodalov
could you please clarify. there are 3 types of lim...

If you will process updates this way even if you will run to limits your bot will still work. Maybe just be slowed down a little

Victor-Khodalov Автор вопроса
s0m31 🇷🇺
If you will process updates this way even if you w...

Could you please explain? When a user sends 20 /start messages within a short period. Even if I add a 1 second delay before sending the reply message to /start command, this will still result in hitting the 20 messages per minute limit. Do I get it right?

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

Обсуждают сегодня

а кроме lighttp\vibe\hunt какие ещё интересные, продвинутые, необычные сервера видели в дишке? Можно и мёртвые проекты тож, для перенятия опыта, так сказать. Там прост в репоз...
Constantin F.
1
а кто писал сокетные фреймворки, как вы управляли пулом открытых дескрипторов соединений? Там может прилететь, например, миллион. Наиболее быстрый способ доступа к ним всёж ли...
Constantin F.
4
мне кажется, или погоня за безопасностью носит оттенок хайпа и одержимости? ведь реально высокие требования предъявляются лишь к небольшому кол-ву приложений
Aleksandr Druzhinin
2
Мне интересно, скорее людей здесь используют D, Rust, C/C++ для решения реальных прикладных задач за деньги?)
Evil Satanson
49
Вопрос тем кто смотрит видео и слушает подкасты - как вы потом ищете нужную вам информацию? Вот статью я прочитал, потом могу искать нужную мне часть банальным поиском. Пропус...
Aleksandr Druzhinin
4
Мне были интересны дишные хаки и я нашёл любопытный способ на форуме через __traits, что-то вроде int delegate(int) fac = (int n) => n == 0 ? 1 : n * __traits(parent, {})(n - ...
Constantin F.
1
А кто нибудь напрямую с https://code.dlang.org/packages/libasync работал? я так понимаю, она популярна через вайб как зависимость?
Aleksandr Druzhinin
1
А что не работало и почему он не хотел принимать, не знаешь?
Aleksandr Druzhinin
1
И к какой архитектуре привязана Java?
Dmitry Olshansky
17
Я думаю тему с тем, что “Google не продвигает свои технологии. Язык Го сам просто такой хороший» можно закрыть https://www.opennet.ru/opennews/art.shtml?num=61454
Serg Gini
5
Карта сайта