I'm using node-telegram-bot-api
. My question - how create function like this (on screen)
I'am using this code, but code working in definite ID user How make to has been answer available everyone
// Create bot
const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot('XXXXXXXX:AAEibBwftjTEKuYd9d2X0ACeyyzTk4DLe60', {
polling: true
});
// List of id's we're waiting for
const wait = [];
// Hardcoded chat id
const chatId = 1234567;
// Ask and add to wait list
bot.sendMessage(chatId, 'What is your name?', { parse_mode: 'HTML' });
wait.push(chatId);
// On message
bot.on('message', (msg) => {
// Check we're waiting on this user
if (wait.includes(msg.chat.id)) {
// Send reply
bot.sendMessage(chatId, 'Your name: ' + msg.text );
// Remove from wait list
wait.splice(wait.indexOf(msg.chat.id), 1);
} else {
// Normal message; notify user
bot.sendMessage(chatId, 'Hi! I\'m not expecting a reply from you! How can I help?');
}
});