Skip to content

Instantly share code, notes, and snippets.

@darvesh
Created April 18, 2022 18:47
Show Gist options
  • Select an option

  • Save darvesh/a983bc051319243f1674118d700c9fa6 to your computer and use it in GitHub Desktop.

Select an option

Save darvesh/a983bc051319243f1674118d700c9fa6 to your computer and use it in GitHub Desktop.
import { Bot, Context } from "https://deno.land/x/[email protected]/mod.ts";
import * as grammyRatelimiter from "https://raw.githubusercontent.com/grammyjs/rateLimiter/fix-wrong-type/src/rateLimiter.ts";
const token = Deno.args[0];
const bot = new Bot(token);
const MASTER = 272286804;
const filterPrivate = (ctx: Context) => ctx.chat?.type === "private";
bot.use(
grammyRatelimiter.limit({
timeFrame: 5 * 60 * 1000,
limit: 2,
storageClient: "MEMORY_STORE",
onLimitExceeded: (ctx) => {
ctx.reply("Please try again after sometime!");
},
keyGenerator: (ctx) => ctx.from?.id.toString(),
})
);
bot.filter(filterPrivate).on(":photo", async (ctx) => {
await ctx.reply(
"Thank you for the submission, good post will be featured on the channel."
);
await ctx.forwardMessage(MASTER);
});
bot.catch(console.error);
bot.start({
onStart: () => console.log("Bot is running"),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment