Powerful
Node.js
package that allows you to
easily
interact with
Telegram API
🚀
Features
- 100% Telegram Bot API coverage
- Works with JavaScript and TypeScript
- Has 57 tests and all of them passes every build
Installation
Node.js 12.0.0 or newer is required
$ yarn add puregram
$ npm i -S puregram
Polling example
import { Telegram } from 'puregram';
const telegram = new Telegram({
token: process.env.TOKEN
});
telegram.updates.on(
'message',
(context) => context.send('Hello, World!')
);
telegram.updates.on(
'callback_query',
(context) => (
context.message.editMessageText('*You just clicked the inline button!*', {
parse_mode: 'Markdown'
})
)
);
telegram.updates.startPolling().catch(console.error);
Webhook example (express)
import express from 'express';
import { Telegram } from 'puregram';
const telegram = new Telegram({
token: process.env.TOKEN
});
const app = express();
app.use(bodyParser.json());
app.use(telegram.updates.getWebhookMiddleware());
telegram.updates.on(
'message',
(context) => context.send('Hello, World!')
);
app.listen(443, () => console.log('Webhook started handling!'));
🤖 Click to see more examples!
Packages that might be useful to you
Thanks to
Biggest thanks to Negezor for his vk-io library that helped me with this package!