SHARE
TWEET

Untitled

a guest Mar 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const TelegramBot = require('node-telegram-bot-api');
  2. //TOKEN Bot
  3. const token = '';
  4.  
  5. const bot = new TelegramBot(token, {polling: true});
  6.  
  7. bot.on('message', function(msg){
  8.    
  9.     const perms = {};
  10.     perms.can_send_message = true;
  11.     perms.can_send_media_messages = true;
  12.     perms.can_send_other_messages = true;
  13.     perms.can_can_add_web_page_previews = true;
  14.  
  15.     var chatId = msg.chat.id;
  16.     var chatitle = msg.chat.title;
  17.     var newMemberID = msg.new_chat_member.id;
  18.    
  19.     if (msg.new_chat_members != undefined){
  20.    
  21.         var nameNewMember = msg.new_chat_member.first_name;
  22.  
  23.         //Manda un mensaje de bienvenida y solicita que haga clic en el boton para verificar
  24.         bot.sendMessage(chatId, "Hola " + nameNewMember + ", bienvenido al grupo de " + chatitle + "de la UTN - FRBA\nHaga clic en el boton de abajo para verificar que no sea un robot",
  25.             { reply_markup: {
  26.                 inline_keyboard: [
  27.                     [
  28.                         {text: "No soy un bot", callback_data: 'bot'}
  29.                     ]
  30.                 ]
  31.             }});
  32.     }
  33.  
  34.     bot.on('callback_query', function onCallbackQuery(accionboton){
  35.         const data = accionboton.data
  36.         const msg = accionboton.message
  37.  
  38.         if(data == 'bot'){
  39.             bot.deleteMessage(chatId, msg.message_id);
  40.             bot.restrictChatMember(chatId, newMemberID, perms).then(function(result){
  41.                 bot.sendMessage(chatId, "Usuario verificado \u2705");
  42.             })
  43.         }
  44.     });
  45.  
  46. //Cuando aparece solo esa palabra
  47. bot.onText(/^\/empieza/, (msg) => {
  48.     //console.log(msg);
  49.     bot.sendMessage(msg.chat.id, "Las materias de 2do a 6to año empiezan el 18\nFisica 1 curso Z empieza el 25\nRecursantes empiezan el 25 de marzo\nIngresantes empiezan el 1 de Abril\n",{reply_to_message_id: msg.message_id});
  50. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top