Skip to content

Commit

Permalink
correção problema devbage#1 e add mensagen love
Browse files Browse the repository at this point in the history
  • Loading branch information
Everton Catto Heckler committed Sep 25, 2019
1 parent d197e87 commit 81e5562
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions bot.js
Original file line number Diff line number Diff line change
@@ -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 !!! :( `)
})

}

0 comments on commit 81e5562

Please sign in to comment.