Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ A simple italian Telegram bot to see your grades, homework and everything else o
- [ ] Get a notify if there's an **upcoming test** or everything else.

## Installation

- Install the dependencies with your package manager (click [here](https://en.m.wikipedia.org/wiki/List_of_software_package_management_systems) for a list) , skip if you already have them.

$ sudo apt-get install git
$ sudo apt-get install php7.0 php7.0-curl apache2

- Install the bot files, if you already installed dependencies start from here.

$ git clone https://github.com/iDoppioclick/ArgoBot
$ mv ArgoBot/ /var/www/html/
$ sudo chown -R www-data:www-data /var/www/html/ArgoBot

- Then, edit the ```_config.php``` file with the requested values, like the API Token (Generated by [BotFather](https://t.me/BotFather)), the database name, user and password.

- Then, edit the ```config.php``` file with the requested values, like the API Token (Generated by [BotFather](https://t.me/BotFather)), the database name, user and password.

- Import ```database.sql``` in your MySQL database, this will create the structure of the table ```Utenti```

- Visit https://api.telegram.org/botYOURTOKEN/setWebhook?url=https://yourserverip/ArgoBot/index.php

Expand Down
49 changes: 48 additions & 1 deletion src/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,54 @@
cb_reply($cbid, $cbtext, false, $cbmid, $gradesText, $tastiera);
}

if($cbdata == "Today"){
$gradesText = "";
$todayRaw = $user->oggiScuola();
$argomentiText = "";
$compitiText = "";
$votiText = "";
$promemoriaText = "";
if (count($todayRaw)==0) {
$todayText = "<i>Nessuna informazione da visualizzare.</i>";
}
else {
foreach ($todayRaw AS $thisEvento) {
if ($thisEvento['tipo']=="ARG") {
$argomentiText .= "<i>".$thisEvento['dati']['desMateria']."</i>: ".$thisEvento['dati']['desArgomento']."\n";
}
elseif ($thisEvento['tipo']=="COM") {
$compitiText .= "<i>".$thisEvento['dati']['desMateria']."</i>: ".$thisEvento['dati']['desCompiti']."\n";
}
elseif ($thisEvento['tipo']=="VOT") {
$votiText .= "<i>".$thisEvento['dati']['desMateria']."</i>: <b>".$thisEvento['dati']['codVoto']."</b>\n";
}
elseif ($thisEvento['tipo']=="PRO") {
$promemoriaText .= "<i>".$thisEvento['dati']['desMittente']."</i>: ".$thisEvento['dati']['desAnnotazioni']."\n";
}
}
if (!empty($argomentiText)) {
$todayText .= "\xF0\x9F\x93\x92 <b>Argomenti</b>\n".$argomentiText."\n";;
}
if (!empty($compitiText)) {
$todayText .= "\xf0\x9f\x93\x9a <b>Compiti</b>\n".$compitiText."\n";
}
if (!empty($votiText)) {
$todayText .= "\xf0\x9f\x96\x8a <b>Voti</b>\n".$votiText."\n";
}
if (!empty($promemoriaText)) {
$todayText .= "\xf0\x9f\x93\x9d <b>Promemoria</b>\n".$promemoriaText."\n";
}
}
$kb = array();
$kb[] = array(
array(
"text" => "\xf0\x9f\x94\x99 Torna indietro",
"callback_data" => "Panel"
)
);
cb_reply($cbid, $cbtext, false, $cbmid, "\xf0\x9f\x93\x85 <b>Sommario di oggi</b>\n\n$todayText", $kb);
}

/*if($msg == "/panel"){
$panel[] = array(
array(
Expand Down Expand Up @@ -401,4 +449,3 @@
sm($chatID, "\xf0\x9f\x93\x98 <b>Benvenuto nel pannello!</b>\nScegli cosa vuoi fare.\n\n\xe2\x84\xb9\xef\xb8\x8f <i>Hai effettuato il login, se vuoi disconnetterti clicca su \"Impostazioni\", e poi su \"Disconnettiti\".</i>", $panel);

}*/

27 changes: 14 additions & 13 deletions src/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ function isLogged($userID){
}

function getMonth($month){
if($month == 01 || $month == 1) return 'gennaio';
if($month == 02 || $month == 2) return 'febbraio';
if($month == 03 || $month == 3) return 'marzo';
if($month == 04 || $month == 4) return 'aprile';
if($month == 05 || $month == 5) return 'maggio';
if($month == 06 || $month == 6) return 'giugno';
if($month == 07 || $month == 7) return 'luglio';
if($month == 08 || $month == 8) return 'agosto';
if($month == 09 || $month == 9) return 'settembre';
if($month == 10 || $month == 10) return 'ottobre';
if($month == 11 || $month == 11) return 'novembre';
if($month == 12 || $month == 12) return 'dicembre';
$month = intval($month);
if($month == 1) return 'gennaio';
if($month == 2) return 'febbraio';
if($month == 3) return 'marzo';
if($month == 4) return 'aprile';
if($month == 5) return 'maggio';
if($month == 6) return 'giugno';
if($month == 7) return 'luglio';
if($month == 8) return 'agosto';
if($month == 9) return 'settembre';
if($month == 10) return 'ottobre';
if($month == 11) return 'novembre';
if($month == 12) return 'dicembre';
}

function getNumberEmoji($number){
Expand Down Expand Up @@ -151,4 +152,4 @@ function getNumberEmoji($number){
$q->execute(array(':id' => $userID));
}
}
}
}
32 changes: 32 additions & 0 deletions src/database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

CREATE TABLE `Utenti` (
`IDU` int(11) NOT NULL,
`ID` int(11) NOT NULL,
`Stato` varchar(200) NOT NULL DEFAULT '-',
`SchoolCode` varchar(7) DEFAULT NULL,
`Username` varchar(200) DEFAULT NULL,
`AuthToken` varchar(500) DEFAULT '-',
`LoggedIn` varchar(2) DEFAULT 'No',
`GPost` varchar(2) NOT NULL DEFAULT 'Si',
`GPostStatus` varchar(7) NOT NULL DEFAULT '-'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `Utenti`
ADD PRIMARY KEY (`IDU`);

ALTER TABLE `Utenti`
MODIFY `IDU` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;