From 67ea06c65dc9cdc44748a334ec4d2f907e38bf60 Mon Sep 17 00:00:00 2001 From: Alessandro Date: Thu, 19 Mar 2020 12:31:27 +0100 Subject: [PATCH] Aggiunta bozza status --- README.md | 6 ++++++ ThiReMaBot.txt | 1 + bot.js | 32 ++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e071fac..e0bdbd3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +![SWE Telegram CI](https://github.com/RedRoundRobin/swe-telegram/workflows/SWE%20Telegram%20CI/badge.svg) + +![Repository Checker](https://github.com/RedRoundRobin/swe-telegram/workflows/Repository%20Checker/badge.svg) + +[![Coverage Status](https://coveralls.io/repos/github/RedRoundRobin/swe-telegram/badge.svg?branch=develop)](https://coveralls.io/github/RedRoundRobin/swe-telegram?branch=develop) + ![RedRounRobinLogo](https://i.imgur.com/3Dcv4vs.png) # Telegram Bot - ThiReMa diff --git a/ThiReMaBot.txt b/ThiReMaBot.txt index e013e25..7a2f553 100644 --- a/ThiReMaBot.txt +++ b/ThiReMaBot.txt @@ -10,6 +10,7 @@ Comandi: info - Comandi supportati login - Login al sistema ThiReMa test - Test di invio token A2F a giovanni +status - Controllo lo status dell'utente Istruzioni per avviarlo: diff --git a/bot.js b/bot.js index 9f05ecd..128683d 100644 --- a/bot.js +++ b/bot.js @@ -2,9 +2,10 @@ const Telegraf = require('telegraf'); //richieste http const axios = require('axios'); -//tokenbot e crazione bot +//tokenbot e creazione bot const tokenBot = "1120382460:AAG2TTBT-GqHcIfGzH_TYOvCZFI0pMEu88c"; const bot = new Telegraf(tokenBot); +const http = require('http'); function sum(a, b) { return a + b; @@ -13,7 +14,8 @@ module.exports = sum; bot.start((message) => { console.log('started:', message.from.id); - return message.reply(`Bevenuto nel bot di ThiReMa!Per vedere la lista del comandi che puoi utilizzare usa il comando /info `) + //http. + return message.reply('Ciao '+message.from.first_name+', benvenuto nel bot di ThiReMa! Per vedere la lista del comandi che puoi utilizzare usa il comando /info ') }); bot.command('login', message => { @@ -28,13 +30,11 @@ bot.command('login', message => { const data = res.data; console.log(data); if (data === 1) { - return message.reply('Account trovato, registrazione riuscita'); - } - if (data === 2) { + return message.reply('Username trovato, registrazione riuscita'); + }else if (data === 2) { return message.reply('Account giĆ  registrato, nessuna modifica apportata'); - } - if (data === 0) { - return message.reply('Account non trovato, registra il tuo account Telegram dalla web-app'); + }else if (data === 0) { + return message.reply('Username non trovato, registra il tuo Username dalla web-app'); } }) .catch(err => { @@ -44,6 +44,22 @@ bot.command('login', message => { }); +bot.command('status', message => { + const username = message.from.username; + axios + .get(`http://localhost:9999/status/${username}`) + .then(res =>{ + const data = res.data; + if(data === 0){ + //INFO UTENTE + return message.reply(''); + } + }) + .catch(err => { + console.log(err); + return message.reply('Errore nel controllo dei dati'); + }); +}); bot.command('info', ({ reply }) => reply(` 1) Login: /login `