https://github.com/qertis/telegram-bot-api-express
Simple and powerful Telegram Bot API expressjs middleware.
https://github.com/qertis/telegram-bot-api-express
telegram-bot telegram-bot-api telegram-bot-api-express telegram-bot-example
Last synced: 24 days ago
JSON representation
Simple and powerful Telegram Bot API expressjs middleware.
- Host: GitHub
- URL: https://github.com/qertis/telegram-bot-api-express
- Owner: qertis
- License: mit
- Created: 2023-01-01T20:16:00.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-28T09:06:24.000Z (4 months ago)
- Last Synced: 2025-04-19T15:36:01.280Z (about 1 month ago)
- Topics: telegram-bot, telegram-bot-api, telegram-bot-api-express, telegram-bot-example
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/telegram-bot-api-express
- Size: 1020 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram Bot API Express
Simple and powerful Telegram Bot API express.js middleware.
## Install
```bash
npm i telegram-bot-api-express --save
```## Dependencies
- [node-telegram-bot-api](https://github.com/yagop/node-telegram-bot-api)## PeerDependencies
- express
- body-parser## Usage
```javascript
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, () => {});
```## More other telegram types!
Make [native types](https://core.telegram.org/bots/api) and use those types:```
edited_message_text
bot_command
reply_to_message
mention
channel_post
auth_by_contact
message_forwards
error
```## Test
> See tests directoryUsing [Ava](https://github.com/avajs/ava).
```bash
npm test
```