JSPM

  • Created
  • Published
  • Downloads 1031775
  • Score
    100M100P100Q172992F
  • License MIT

grammY core package ported to Node.js

Package Exports

  • grammy

Readme

grammY for Node

If you haven't already, install Node.js.

Quickstart

Simple example

Talk to @BotFather to create a new Telegram bot and obtain a bot token.

Paste the following code into a new file example-bot.js.

import { Bot } from 'grammy'
// This works, too (CommonJS modules):
// const { Bot } = require('grammy')

// Create bot
const bot = new Bot('<your-bot-token>')

// Listen for messages
bot.command('start', ctx => ctx.reply('Welcome! Send me your pics!'))
bot.on('message:photo' ctx => ctx.reply('Nice photo!'))

// Launch!
bot.launch()

Congratulations! You have successfully created your first Telegram bot for Node.

You can run it like so:

node example-bot.js

Advanced example

TODO: create more complicated example

const token = process.env.BOT_TOKEN;
node example-bot.js