Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit per group rather than user #4

Open
sadikyalcin opened this issue Nov 9, 2020 · 2 comments
Open

Rate limit per group rather than user #4

sadikyalcin opened this issue Nov 9, 2020 · 2 comments

Comments

@sadikyalcin
Copy link

Is it possible to limit messages per group rather than each individual? Maybe my setup is wrong?

const { Telegraf, Extra } = require('telegraf');
const rateLimit = require('telegraf-ratelimit')

const limitConfig = {
    window: 30000,
    limit: 1,
    onLimitExceeded: (ctx, next) => ctx.reply(messages[Math.floor(Math.random() * messages.length)]),
}

const bot = new Telegraf(api);
bot.use(rateLimit(limitConfig))
@jumoog
Copy link

jumoog commented Nov 13, 2020

i have the same problem.. it's not working

@adrianbucks
Copy link

The documentation says that key defaults to user id.
On the simple bot example you can find how to change the key

keyGenerator: function (ctx) {
    return ctx.chat.id
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants