Saltar al contenido

tutorial de bot de telegram con ejemplo de código de nodejs

Hola usuario de nuestro sitio, descubrimos la respuesta a tu búsqueda, deslízate y la verás un poco más abajo.

Ejemplo: API de bot de telegramas de nodo

constTelegramBot=require('node-telegram-bot-api');// replace the value below with the Telegram token you receive from @BotFatherconst token ='YOUR_TELEGRAM_BOT_TOKEN';// Create a bot that uses 'polling' to fetch new updatesconst bot =newTelegramBot(token,polling:true);// Matches "/echo [whatever]"
bot.onText(//echo (.+)/,(msg, match)=>// 'msg' is the received Message from Telegram// 'match' is the result of executing the regexp above on the text content// of the messageconst chatId = msg.chat.id;const resp = match[1];// the captured "whatever"// send back the matched "whatever" to the chat
  bot.sendMessage(chatId, resp););// Listen for any kind of message. There are different kinds of// messages.
bot.on('message',(msg)=>const chatId = msg.chat.id;// send a message to the chat acknowledging receipt of their message
  bot.sendMessage(chatId,'Received your message'););

Si eres capaz, puedes dejar un enunciado acerca de qué te ha gustado de esta división.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *