telegraf
Version:
📡 Modern Telegram bot framework
20 lines (16 loc) • 638 B
JavaScript
const Telegraf = require('telegraf')
const Extra = require('telegraf/extra')
const Markup = require('telegraf/markup')
const gameShortName = 'your-game'
const gameUrl = 'https://your-game.tld'
const markup = Extra.markup(
Markup.inlineKeyboard([
Markup.gameButton('🎮 Play now!'),
Markup.urlButton('Telegraf help', 'http://telegraf.js.org')
])
)
const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start(({ replyWithGame }) => replyWithGame(gameShortName))
bot.command('foo', ({ replyWithGame }) => replyWithGame(gameShortName, markup))
bot.gameQuery(({ answerGameQuery }) => answerGameQuery(gameUrl))
bot.startPolling()