1.3.4 • Published 9 months ago

telegram-bot-api-express v1.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Telegram Bot API Express

Simple and powerful Telegram Bot API express.js middleware.

Install

npm i telegram-bot-api-express --save

Dependencies

PeerDependencies

  • express
  • body-parser

Usage

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 and use those types:

edited_message_text
bot_command
reply_to_message
mention
channel_post
auth_by_contact
message_forwards
error

Test

See tests directory

Using Ava.

npm test
1.3.4

9 months ago

1.3.3

10 months ago

1.3.2

10 months ago

1.3.1

10 months ago

1.3.0

10 months ago

1.2.0

12 months ago

1.2.3

11 months ago

1.2.2

12 months ago

1.2.1

12 months ago

1.1.3

1 year ago

1.1.1

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago