diff --git a/data/config.json b/data/config.json index 1e32fc2a..139fc773 100644 --- a/data/config.json +++ b/data/config.json @@ -21,6 +21,7 @@ "telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo", "telegonof": "0", "teleginput": "0", + "autos": "1", "weblogin": "admin", "webpass": "admin", "MqttIn": "0", diff --git a/data/set.telegram.json.gz b/data/set.telegram.json.gz index 8386cf09..e8810e9b 100644 Binary files a/data/set.telegram.json.gz and b/data/set.telegram.json.gz differ diff --git a/data_ungzip/set.telegram.json b/data_ungzip/set.telegram.json index a0857838..7b07378c 100644 --- a/data_ungzip/set.telegram.json +++ b/data_ungzip/set.telegram.json @@ -39,6 +39,16 @@ { "type": "hr" }, + { + "type": "checkbox", + "name": "autos", + "title": "Автоматически брать chat ID из входящих сообщений", + "action": "/set?autos=[[autos]]", + "state": "{{autos}}" + }, + { + "type": "hr" + }, { "type": "h4", "title": "Telegram chat ID" diff --git a/src/FileSystem.cpp b/src/FileSystem.cpp index a73e6657..4db0d187 100644 --- a/src/FileSystem.cpp +++ b/src/FileSystem.cpp @@ -10,7 +10,7 @@ bool getInfo(FSInfo& info) { void getFSInfo() { FSInfo buf; if (getInfo(buf)) { - SerialPrint("I", F("FS"), F("Get FS info completed")); + //SerialPrint("I", F("FS"), F("Get FS info completed")); size_t totalBytes = buf.totalBytes; // всего size_t usedBytes = buf.usedBytes; // использовано diff --git a/src/Telegram.cpp b/src/Telegram.cpp index 49b45e7d..3e069988 100644 --- a/src/Telegram.cpp +++ b/src/Telegram.cpp @@ -35,8 +35,10 @@ void handleTelegram() { prevMillis = millis(); if (myBot->getNewMessage(msg)) { SerialPrint("->", "Telegram", "chat ID: " + String(msg.sender.id) + ", msg: " + String(msg.text)); - jsonWriteInt(configSetupJson, "chatId", msg.sender.id); - saveConfig(); + if (jsonReadBool(configSetupJson, "autos")) { + jsonWriteInt(configSetupJson, "chatId", msg.sender.id); + saveConfig(); + } telegramMsgParse(String(msg.text)); } } @@ -61,6 +63,7 @@ void telegramMsgParse(String msg) { myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list); SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list); } else { + myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), "ID: " + chipId + ", Name: " + jsonReadStr(configSetupJson, F("name"))); myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), F("Wrong order, use /all to get all values, /get_id to get value, or /set_id_value to set value")); } } diff --git a/src/Web.cpp b/src/Web.cpp index a1ed35ea..50343648 100644 --- a/src/Web.cpp +++ b/src/Web.cpp @@ -255,6 +255,12 @@ void web_init() { saveConfig(); request->send(200); } + if (request->hasArg("autos")) { + bool value = request->getParam("autos")->value().toInt(); + jsonWriteBool(configSetupJson, "autos", value); + saveConfig(); + request->send(200); + } if (request->hasArg("chatId")) { jsonWriteStr(configSetupJson, "chatId", request->getParam("chatId")->value()); saveConfig(); diff --git a/src/items/vLogging.cpp b/src/items/vLogging.cpp index 51f8a3f7..9edf1710 100644 --- a/src/items/vLogging.cpp +++ b/src/items/vLogging.cpp @@ -62,15 +62,15 @@ void LoggingClass::execute(String keyOrValue) { } if (loggingValue != "") { - if (cnt >= _maxPoints) { //удаляем старую строку и добавляем новую + if (cnt >= _maxPoints) { //удаляем старую строку и добавляем новую String logData = readFile(filename, 20480); //10240 SerialPrint("I", "Logging", "Free heap " + String(ESP.getFreeHeap())); if (logData == "large") { SerialPrint("E", "Logging", "File is very large"); } - //for (int i = 0; i < 5; i++) { + logData = deleteBeforeDelimiter(logData, "\r\n"); - //} + if (timeNow->hasTimeSynced()) { logData += timeNow->getTimeUnix() + " " + loggingValue + "\r\n";