65 lines
2.5 KiB
Markdown
65 lines
2.5 KiB
Markdown

|
|
[](https://core.telegram.org/bots/api)
|
|
[](https://www.npmjs.com/package/telegraf)
|
|
[](https://www.npmjs.com/package/telegraf)
|
|
[](https://travis-ci.org/telegraf/telegraf)
|
|
[](http://standardjs.com/)
|
|
[](https://t.me/TelegrafJSChat)
|
|
|
|
## Introduction
|
|
|
|
Bots are special [Telegram](https://telegram.org) accounts designed to handle messages automatically.
|
|
Users can interact with bots by sending them command messages in private or group chats.
|
|
These accounts serve as an interface for code running somewhere on your server.
|
|
|
|
### Features
|
|
|
|
- Full [Telegram Bot API 4.7](https://core.telegram.org/bots/api) support
|
|
- [Telegram Payment Platform](https://telegram.org/blog/payments)
|
|
- [HTML5 Games](https://core.telegram.org/bots/api#games)
|
|
- [Inline mode](https://core.telegram.org/bots/api#inline-mode)
|
|
- Incredibly fast
|
|
- [now](https://now.sh)/[Firebase](https://firebase.google.com/products/functions/)/[Glitch](https://dashing-light.glitch.me)/[Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction)/[AWS **λ**](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html)/Whatever ready
|
|
- `http/https/fastify/Connect.js/express.js` compatible webhooks
|
|
- Easy to extend
|
|
- `TypeScript` typings
|
|
|
|
### Installation
|
|
|
|
```
|
|
$ npm install telegraf
|
|
```
|
|
or using `yarn`:
|
|
```
|
|
$ yarn add telegraf
|
|
```
|
|
|
|
### Documentation
|
|
|
|
[Telegraf developer docs](http://telegraf.js.org)
|
|
|
|
### Examples
|
|
|
|
```js
|
|
const Telegraf = require('telegraf')
|
|
|
|
const bot = new Telegraf(process.env.BOT_TOKEN)
|
|
bot.start((ctx) => ctx.reply('Welcome!'))
|
|
bot.help((ctx) => ctx.reply('Send me a sticker'))
|
|
bot.on('sticker', (ctx) => ctx.reply('👍'))
|
|
bot.hears('hi', (ctx) => ctx.reply('Hey there'))
|
|
bot.launch()
|
|
```
|
|
|
|
```js
|
|
const Telegraf = require('telegraf')
|
|
|
|
const bot = new Telegraf(process.env.BOT_TOKEN)
|
|
bot.command('oldschool', (ctx) => ctx.reply('Hello'))
|
|
bot.command('modern', ({ reply }) => reply('Yo'))
|
|
bot.command('hipster', Telegraf.reply('λ'))
|
|
bot.launch()
|
|
```
|
|
|
|
There's some cool [examples too](docs/examples/).
|