1
1
鏡像自 https://gitlab.com/ceda_ei/Quadnite-Bot 已同步 2025-12-15 15:20:05 +01:00

Change rate limit config

Don't send a message and use the chat as key when possible
此提交包含在:
2024-10-02 22:39:36 +05:30
父節點 cd374090f2
當前提交 e3a5f1a67b

9
bot.js
查看文件

@@ -9,11 +9,10 @@ const { limit } = require("@grammyjs/ratelimiter");
const bot = new Telegraf(BOT_API_KEY); const bot = new Telegraf(BOT_API_KEY);
bot.catch((err) => console.log(err)); bot.catch((err) => console.log(err));
bot.use(limit({ bot.use(limit({
// default config: 5 messages per 5 seconds // default config: 1 message per 1 second
timeFrame: RATE_TIMEFRAME ?? 5000, timeFrame: RATE_TIMEFRAME ?? 1000,
limit: RATE_LIMIT ?? 5, limit: RATE_LIMIT ?? 1,
keyGenerator: (ctx) => ctx.chat?.id.toString() ?? ctx.from?.id.toString(),
onLimitExceeded: (ctx, next) => ctx.reply('Too many requests!'),
})) }))
const data = [ const data = [