grammyjs / commands

Work-in-progress plugin for managing commands with grammY.
https://grammy.dev
MIT License
12 stars 2 forks source link

feat: add automatic filtering #2

Closed roziscoding closed 1 year ago

roziscoding commented 1 year ago

Major redesign to better support filtering. Proposed usage:

import { Bot } from "./src/deps.deno.ts";
import { Commands } from "./src/plugin.ts";

const bot = new Bot("...");

const cmds = new Commands();

cmds.command("start", "Initializes bot configuration")
  .localize("pt", "start", "Inicializa as configurações do bot")
  .addToScope({ type: "all_private_chats" }, (ctx) => ctx.reply(`Hello, ${ctx.chat.first_name}!`))
  .addToScope({ type: "all_group_chats" }, (ctx) => ctx.reply(`Hello, members of ${ctx.chat.title}!`));

await cmds.setCommands(bot);

bot.use(cmds);
bot.start();