From e3a5f1a67b58d213dad3bf657196c704dce49cad Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Wed, 2 Oct 2024 22:39:36 +0530 Subject: [PATCH] Change rate limit config Don't send a message and use the chat as key when possible --- bot.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bot.js b/bot.js index 6682c04..134c55c 100644 --- a/bot.js +++ b/bot.js @@ -9,11 +9,10 @@ const { limit } = require("@grammyjs/ratelimiter"); const bot = new Telegraf(BOT_API_KEY); bot.catch((err) => console.log(err)); bot.use(limit({ - // default config: 5 messages per 5 seconds - timeFrame: RATE_TIMEFRAME ?? 5000, - limit: RATE_LIMIT ?? 5, - - onLimitExceeded: (ctx, next) => ctx.reply('Too many requests!'), + // default config: 1 message per 1 second + timeFrame: RATE_TIMEFRAME ?? 1000, + limit: RATE_LIMIT ?? 1, + keyGenerator: (ctx) => ctx.chat?.id.toString() ?? ctx.from?.id.toString(), })) const data = [