Skip to content

Плагин автоматического повтора

npmJSRJSR Score

Плагин, который ловит ошибки с полем retry_after (ошибки превышения лимита запросов), ждёт указанное время и повторяет API-запрос.

Установка

bash
npm install @gramio/auto-retry
bash
yarn add @gramio/auto-retry
bash
pnpm add @gramio/auto-retry
bash
bun install @gramio/auto-retry

Использование

ts
import { Bot } from "gramio";
import { autoRetry } from "@gramio/auto-retry";

const bot = new Bot(process.env.BOT_TOKEN as string)
    .extend(autoRetry())
    .command("start", async (context) => {
        for (let index = 0; index < 100; index++) {
            await context.reply(`сообщение ${index}`);
        }
    })
    .onStart(console.log);

bot.start();