diff --git a/Nodemcu-Web-Telegram-relay-controller.ino b/Nodemcu-Web-Telegram-relay-controller.ino index 953b5c0..272a54a 100644 --- a/Nodemcu-Web-Telegram-relay-controller.ino +++ b/Nodemcu-Web-Telegram-relay-controller.ino @@ -28,7 +28,7 @@ int outputQuantity = 10; //should not exceed 10 boolean outputInverted = true; //true or false // Write the text description of the output channel -String buttonText[10] = {"22. Settore 1", "24. Settore 2", "26. Settore 3", "28. Settore 4", "30. Luci esterne", "32. na", "34. na", "36. na", "38. na", "40. na"}; +String buttonText[10] = {"22. Settore 1", "24. Settore 2", "26. Settore 3", "28. Settore 4", "30. Settore 5", "32. Luci Esterne", "34. na", "36. na", "38. na", "40. na"}; int outp = 0; boolean printLastCommandOnce = false; boolean printButtonMenuOnce = false; @@ -55,17 +55,20 @@ float tempOutDeg = 0.0; float umid_aria = 0.0; -const char* ssid = "ssid"; -const char* password = "password"; +const char* ssid = "xxx"; +const char* password = "xxx"; // Initialize Telegram BOT -#define BOTtoken "aaaaaa:bbbbbbb" //"aaaa:bbbbb" //token of FlashledBOT -#define BOTname "BOTname" //"" -#define BOTusername "BOTusername"//"" +#define BOTtoken "xx:xxx" //"425354869:AAFc9Z6HVVm3EJHonQoEqscSNLwMBQTSvyY" //token of FlashledBOT +#define BOTname "xxx" //"AdreaniSpruzziniController" +#define BOTusername "xx"//"AdreaniSpruzziniControllerBot" + +const String id_proprietario = "xx"; + +String id_scrittore_messaggio = "xx"; -String id_proprietario = "0123456789"; TelegramBOT bot(BOTtoken, BOTname, BOTusername); @@ -74,12 +77,13 @@ long Bot_lasttime; //last time messages' scan has been done bool Start = false; String message_read; -String wellcome = "Bentornato"; +String wellcome = "Bentornato Fede"; String help_msg = "Comandi: /start per avviare il sistema /Hn per accendere il pin n /Ln per spegnere il led n /cicloXX per avviare un ciclo intero di XX minuti (per stazione) /stato per sapere lo stato generale dei pin /Hall per accendere tutto e /Lall per spegnere tutto"; String ip_esterno; + bool web = false; bool isCiclo = false; @@ -89,7 +93,17 @@ bool isCiclo = false; void Bot_ExecMessages() { for (int i = 1; i < bot.message[0][0].toInt() + 1; i++) { message_read = bot.message[i][5].substring(1, bot.message[i][5].length()); - id_proprietario = bot.message[i][4]; + + id_scrittore_messaggio = bot.message[i][4]; + + + if (id_proprietario != id_scrittore_messaggio) { + + bot.sendMessage(id_proprietario, "!!! ATTENZIONE FEDERICO !!!", ""); + bot.sendMessage(id_proprietario, "Accesso sospetto da parte di una persona sconosciuta", ""); + bot.sendMessage(id_proprietario, id_scrittore_messaggio, ""); + + } WiFiClient client = server.available(); @@ -238,7 +252,7 @@ void setup() { // Mac address should be different for each device in your LAN byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; - IPAddress arduino_ip ( 192, 168, 1, 177); + IPAddress arduino_ip ( 192, 168, 1, 170); IPAddress gateway_ip ( 192, 168, 1, 1); IPAddress subnet_mask(255, 255, 255, 0); @@ -708,10 +722,10 @@ void printHtmlFooter(WiFiClient client) { allOff = ""; //printing last part of the html - client.println("\n