Simple and powerful Telegram Bot API express.js middleware.
npm i telegram-bot-api-express --save
- express
- body-parser
const express = require('express');
const telegramBotExpress = require('telegram-bot-api-express');
const app = express();
app.use(telegramExpress({
token: 'YOUR_TELEGRAM_BOT_TOKEN',
domain: 'http://127.0.0.1',
privateEvents: {
// Listen for any kind of message. There are different kinds of messages.
['message']: (bot, message) => {
bot.sendMessage(message.chat.id, 'Hello World');
},
// Matches "/echo [whatever]"
[/\/echo (.+)/]: (bot, message) => {
bot.sendChatAction(message.chat.id, 'typing');
bot.sendMessage(message.chat.id, 'PONG');
},
},
onError(bot, error) {
console.error(error);
}
}).middleware);
app.listen(8080, () => {});
Make native types and use those types:
edited_message_text
bot_command
reply_to_message
mention
channel_post
auth_by_contact
error
See tests directory
Using Ava.
npm test