gringobot
gringobot copied to clipboard
account for telegram rate limiting
sometimes during startup after some unexpected termination (like when I forget to pay the GCP account, the cluster gets some workloads disabled, and when I pay they come back up), we get this error multiple times:
{"level":30,"time":1660134420391,"pid":1,"hostname":"gringobot-6b8d987846-kdv99","msg":"Bot is running."}
{"level":30,"time":1660134430926,"pid":1,"hostname":"gringobot-6b8d987846-kdv99","msg":"Creating message deletion interval for chat \"-1001578006520\"."}
{"level":30,"time":1660134431023,"pid":1,"hostname":"gringobot-6b8d987846-kdv99","msg":"Creating message deletion interval for chat \"-1001241627505\"."}
/app/node_modules/telegraf/lib/core/network/client.js:258
throw new error_1.default(data, { method, payload });
^
TelegramError: 429: Too Many Requests: retry after 6
at Telegram.callApi (/app/node_modules/telegraf/lib/core/network/client.js:258:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
response: {
ok: false,
error_code: 429,
description: 'Too Many Requests: retry after 6',
parameters: { retry_after: 6 }
},
on: {
method: 'setMyCommands',
this error terminates the container, which then when launched again will run in the same issue until the rate limiting is over
the error message is always on the setMyCommands method, but my guess is that it happens after the runMessageRecycling starts spinning up multiple promises to delete certain messages: https://github.com/armand1m/gringobot/blob/main/src/autoDeleteMessages.ts#L68-L72