From 81e5562343467c8bd5d363eae9a86bfd6639ada6 Mon Sep 17 00:00:00 2001 From: Everton Catto Heckler Date: Wed, 25 Sep 2019 14:50:23 -0300 Subject: [PATCH 1/3] =?UTF-8?q?corre=C3=A7=C3=A3o=20problema=20#1=20e=20ad?= =?UTF-8?q?d=20mensagen=20love?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.js | 80 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/bot.js b/bot.js index 6da30c5..782a9a6 100644 --- a/bot.js +++ b/bot.js @@ -1,42 +1,52 @@ 'use strict'; -module.exports = function() -{ - const TelegramBot = require( `node-telegram-bot-api` ) +module.exports = function () { + const TelegramBot = require('node-telegram-bot-api') - const TOKEN = `INSIRA AQUI O TOKEN` //ENTRE AS ASPAS DEVE SER INSERIDO O TOKEN ADQUIRIDO AO CRIAR UM BOT COM O BotFather - const bot = new TelegramBot( TOKEN, { polling: true } ) + //ENTRE AS ASPAS DEVE SER INSERIDO O TOKEN ADQUIRIDO AO CRIAR UM BOT COM O BotFather + const TOKEN = '633210668:AAFpPGDiGZV9NXY0u4mERxWkS_sdkIQEEQU' + const CHAT_ID = '-375279573' + const bot = new TelegramBot(TOKEN, { polling: true }) + bot.onText(/\/echo (.+)/, (msg, match) => { + + const resp = match[1]; + + bot.sendMessage(CHAT_ID, resp); + }); + + var date = new Date; + + bot.onText(/\/love/, function onLoveText(msg) { + + const opts = { - bot.onText(/\/echo (.+)/, (msg, match) => { - const chatId = msg.chat.id; - const resp = match[1]; - - bot.sendMessage(chatId, resp); - }); - - var date = new Date; - console.log(date.toString());//Exibe no console todo o retorno de Date - - //Evento que pega o texto '/hora' no chat e retorna uma resposta/ - bot.onText(/\/hora/, (msg) => { - const chatId = msg.chat.id; - const resp = date.toString(); - - bot.sendMessage(chatId, resp); - }); - - //Ao entrar um novo membro no grupo captura o primeiro nome e junta em uma mensagem de boas vindas - bot.on('new_chat_members', (msg) => { - bot.sendMessage(msg.chat.id, `Olá ${msg.from.first_name}, seja bem vindo ao devBage!! - O objetivo do grupo é juntar todo o povo de TI da cidade e região em um único lugar indiferente de Instituição/Empresa/etc. - Nosso foco aqui é formar uma comunidade de TI para tirar duvidas, compartilhar conhecimento, organizar/divulgar eventos, entre outras coisas. Além disso temos o nosso código de conduta que pode ser acessado no link: - https://github.com/devbage/codigo-de-conduta`) - }) - - //Ao sair um membro do grupo, captura o primeiro nome e junta em uma mensagem de despedida - bot.on('left_chat_member', (msg) => { - bot.sendMessage(msg.chat.id, `Está cedo para ir embora ${msg.from.first_name}! :( `) - }) + reply_to_message_id: msg.message_id, + reply_markup: JSON.stringify({ + keyboard: [ + ['Sim, você é o bot da minha vida ❤'], + ['Não, desculpe, há outro ...'] + ] + }) + }; + + bot.sendMessage(msg.chat.id, 'Do you love me?', opts); + }); + + bot.on('new_chat_members', (msg) => { + + bot.sendMessage(msg.chat.id, `Olá ${msg.new_chat_participant.first_name}, seja bem vindo ao devBage!! ` + + ` O objetivo do grupo é juntar todo o povo de TI da cidade e região em um único ` + + ` lugar indiferente de Instituição/Empresa/etc.` + + ` Nosso foco aqui é formar uma comunidade de TI para tirar duvidas, compartilhar conhecimento, ` + + `organizar/divulgar eventos, entre outras coisas. Além disso temos o nosso código de conduta que ` + + `pode ser acessado no link: https://github.com/devbage/codigo-de-conduta`) + }) + + bot.on('left_chat_member', (msg) => { + + console.log(msg); + bot.sendMessage(msg.chat.id, `Está cedo para ir embora ${msg.left_chat_participant.first_name}! NÓS VAMOS TE RESGATAR !!! :( `) + }) } \ No newline at end of file From bb8983e6e4e4140887fd132fa121b8ef6cb93d5b Mon Sep 17 00:00:00 2001 From: Everton Catto Heckler <36872146+EvertonChBG@users.noreply.github.com> Date: Wed, 25 Sep 2019 14:55:07 -0300 Subject: [PATCH 2/3] Update bot.js --- bot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index 782a9a6..bbd63d2 100644 --- a/bot.js +++ b/bot.js @@ -4,8 +4,8 @@ module.exports = function () { const TelegramBot = require('node-telegram-bot-api') //ENTRE AS ASPAS DEVE SER INSERIDO O TOKEN ADQUIRIDO AO CRIAR UM BOT COM O BotFather - const TOKEN = '633210668:AAFpPGDiGZV9NXY0u4mERxWkS_sdkIQEEQU' - const CHAT_ID = '-375279573' + const TOKEN = '' + const CHAT_ID = '' const bot = new TelegramBot(TOKEN, { polling: true }) bot.onText(/\/echo (.+)/, (msg, match) => { @@ -49,4 +49,4 @@ module.exports = function () { bot.sendMessage(msg.chat.id, `Está cedo para ir embora ${msg.left_chat_participant.first_name}! NÓS VAMOS TE RESGATAR !!! :( `) }) -} \ No newline at end of file +} From dae5796149fe6f32f0ed14ba585f59e5450aec29 Mon Sep 17 00:00:00 2001 From: Everton Catto Heckler <36872146+EvertonChBG@users.noreply.github.com> Date: Thu, 26 Sep 2019 09:42:56 -0300 Subject: [PATCH 3/3] Update bot.js --- bot.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/bot.js b/bot.js index bbd63d2..a4b1836 100644 --- a/bot.js +++ b/bot.js @@ -17,22 +17,6 @@ module.exports = function () { var date = new Date; - bot.onText(/\/love/, function onLoveText(msg) { - - const opts = { - - reply_to_message_id: msg.message_id, - reply_markup: JSON.stringify({ - keyboard: [ - ['Sim, você é o bot da minha vida ❤'], - ['Não, desculpe, há outro ...'] - ] - }) - }; - - bot.sendMessage(msg.chat.id, 'Do you love me?', opts); - }); - bot.on('new_chat_members', (msg) => { bot.sendMessage(msg.chat.id, `Olá ${msg.new_chat_participant.first_name}, seja bem vindo ao devBage!! ` +