B
B
Belavor2019-09-23 14:47:57
JavaScript
Belavor, 2019-09-23 14:47:57

How to make response to node-telegram-bot-api request?

when I do this, the response comes

bot.onText(/\/echo (.+)/, function (msg, match) {
    var chatId = msg.from.id; // Получаем ID отправителя
    var resp = match[1]; // Получаем текст после /echo
    bot.sendMessage(chatId, resp);
});

when i do it it doesn't work
bot.onText(/\/echo (.+)/, function (msg, match) {
    var chatId = msg.from.id; // Получаем ID отправителя
    var resp = match[1]; // Получаем текст после /echo
    var answer = 'пока!'
    bot.sendMessage(chatId, resp, answer);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
h88p, 2019-09-23
@Belavor

Why should it work if the sendMessage method takes 3 arguments: chatId (string or number), text (string), [options] (object)
The 3rd argument is optional and must be passed as an object.
What do you want to do?
API

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question