Creates an in-memory sliding window rate limiter middleware.
Prevents flood limits and excessive requests by throttling updates per user or chat.
Configuration options for the rate limiter.
A MiddlewareFn ready to be used with app.use().
app.use()
// Limit each user to max 3 messages per 2 secondsapp.use(rateLimit({ windowMs: 2000, limit: 3, onLimitExceeded: async (ctx) => { await ctx.reply("Slow down! Please wait a moment."); },})); Copy
// Limit each user to max 3 messages per 2 secondsapp.use(rateLimit({ windowMs: 2000, limit: 3, onLimitExceeded: async (ctx) => { await ctx.reply("Slow down! Please wait a moment."); },}));
Creates an in-memory sliding window rate limiter middleware.
Prevents flood limits and excessive requests by throttling updates per user or chat.