Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Aggiunta bozza status
Browse files Browse the repository at this point in the history
  • Loading branch information
aletomm committed Mar 19, 2020
1 parent 1f18503 commit 67ea06c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions ThiReMaBot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 24 additions & 8 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 => {
Expand All @@ -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 => {
Expand All @@ -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
`
Expand Down

0 comments on commit 67ea06c

Please sign in to comment.