telebot-ts API Documentation - v1.0.0
    Preparing search index...

    Function rateLimit

    • Creates an in-memory sliding window rate limiter middleware.

      Prevents flood limits and excessive requests by throttling updates per user or chat.

      Parameters

      Returns MiddlewareFn

      A MiddlewareFn ready to be used with app.use().

      // Limit each user to max 3 messages per 2 seconds
      app.use(rateLimit({
      windowMs: 2000,
      limit: 3,
      onLimitExceeded: async (ctx) => {
      await ctx.reply("Slow down! Please wait a moment.");
      },
      }));