JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 563
  • Score
    100M100P100Q99202F

Framework-agnostic Telegram bot keyboard builder with many cool features!

Package Exports

  • @gramio/keyboards
  • @gramio/keyboards/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@gramio/keyboards) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@gramio/keyboards

Framework-agnostic Telegram bot keyboard builder with many cool features!

Installation

npm i @gramio/keyboards

See more in Documentation

Usage (with frameworks)

Simple Keyboard

import { Keyboard } from "@gramio/keyboards";

const keyboard = new Keyboard()
    .text("first row")
    .row()
    .text("second row")
    .toJSON(); // NOTE: In gramio, you don't have to use the ".toJSON" method

Usage with Frameworks

Send via GramIO

GramIO is not ready yet...

Send via Grammy

import { Keyboard } from "@gramio/keyboards";
import { Bot } from "grammy";

const bot = new Bot(process.env.TOKEN);

const data = ["Apple", "Realme", "Tesla", "Xiaomi"];

bot.on("message", (ctx) => {
    return ctx.reply("test", {
        reply_markup: new Keyboard()
            .columns(1)
            .text("simple keyboard")
            .add(...data.map((x) => Keyboard.text(x)))
            .filter(({ button }) => button.text !== "Tesla")
            .toJSON(),
    });
});

bot.start();

Result

{
    "keyboard": [
        [
            {
                "text": "simple keyboard"
            }
        ],
        [
            {
                "text": "Apple"
            }
        ],
        [
            {
                "text": "Realme"
            }
        ],
        [
            {
                "text": "Xiaomi"
            }
        ]
    ],
    "one_time_keyboard": false,
    "is_persistent": false,
    "selective": false,
    "resize_keyboard": true
}

image