aetrnm / components

Set of useful components for grammY

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🪄 Components for grammY

🚧 Under development. Please do not use in production yet

Set of useful components for grammY.

Documentation »

Install

Node

// TODO

Deno

// TODO

Usage

// TODO: add imports after publishing

// Extend bot context type
export type MyContext = Context & WebAppDataFlavor;

// Create a bot, specify the extended context
const bot = new Bot<MyContext>(""); // <-- put your authentication token between the ""

bot.command("start", async (ctx) => {
  const keyboard = new Keyboard();

  // Sending the component to the user
  keyboard.webApp("Click to pick", new TimePicker().build());

  await ctx.reply("Hey, pick a time!", {
    reply_markup: keyboard,
  });
});

// Handle time selected by a user
bot.filter(TimePicker.match(), (ctx) => {
  const { time } = ctx.webAppData;

  return ctx.reply(`You chose ${time.getUTCHours()}:${time.getUTCMinutes()}`);
});

bot.start();

Component List

Repository contents

  • Packages
    • components - Package that provides all the components
      • web - Module that creates buttons of web components
      • keyboard - Module that implements keyboard components
  • Apps

About

Set of useful components for grammY


Languages

Language:TypeScript 59.9%Language:Vue 36.0%Language:HTML 3.9%Language:Shell 0.2%