mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
telegram
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
"telegramApi": "1416711569:AAEI0j83GmXqwzb_gnK1B0Am0gDwZoJt5xo",
|
||||||
"telegonof": "0",
|
"telegonof": "0",
|
||||||
"teleginput": "0",
|
"teleginput": "0",
|
||||||
|
"autos": "1",
|
||||||
"weblogin": "admin",
|
"weblogin": "admin",
|
||||||
"webpass": "admin",
|
"webpass": "admin",
|
||||||
"MqttIn": "0",
|
"MqttIn": "0",
|
||||||
|
|||||||
Binary file not shown.
@@ -39,6 +39,16 @@
|
|||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "checkbox",
|
||||||
|
"name": "autos",
|
||||||
|
"title": "Автоматически брать chat ID из входящих сообщений",
|
||||||
|
"action": "/set?autos=[[autos]]",
|
||||||
|
"state": "{{autos}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hr"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "h4",
|
"type": "h4",
|
||||||
"title": "Telegram chat ID"
|
"title": "Telegram chat ID"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ bool getInfo(FSInfo& info) {
|
|||||||
void getFSInfo() {
|
void getFSInfo() {
|
||||||
FSInfo buf;
|
FSInfo buf;
|
||||||
if (getInfo(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 totalBytes = buf.totalBytes; // всего
|
||||||
size_t usedBytes = buf.usedBytes; // использовано
|
size_t usedBytes = buf.usedBytes; // использовано
|
||||||
|
|||||||
@@ -35,8 +35,10 @@ void handleTelegram() {
|
|||||||
prevMillis = millis();
|
prevMillis = millis();
|
||||||
if (myBot->getNewMessage(msg)) {
|
if (myBot->getNewMessage(msg)) {
|
||||||
SerialPrint("->", "Telegram", "chat ID: " + String(msg.sender.id) + ", msg: " + String(msg.text));
|
SerialPrint("->", "Telegram", "chat ID: " + String(msg.sender.id) + ", msg: " + String(msg.text));
|
||||||
jsonWriteInt(configSetupJson, "chatId", msg.sender.id);
|
if (jsonReadBool(configSetupJson, "autos")) {
|
||||||
saveConfig();
|
jsonWriteInt(configSetupJson, "chatId", msg.sender.id);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
telegramMsgParse(String(msg.text));
|
telegramMsgParse(String(msg.text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +63,7 @@ void telegramMsgParse(String msg) {
|
|||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), list);
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + "\n" + list);
|
||||||
} else {
|
} 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"));
|
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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,6 +255,12 @@ void web_init() {
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
request->send(200);
|
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")) {
|
if (request->hasArg("chatId")) {
|
||||||
jsonWriteStr(configSetupJson, "chatId", request->getParam("chatId")->value());
|
jsonWriteStr(configSetupJson, "chatId", request->getParam("chatId")->value());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|||||||
@@ -62,15 +62,15 @@ void LoggingClass::execute(String keyOrValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loggingValue != "") {
|
if (loggingValue != "") {
|
||||||
if (cnt >= _maxPoints) { //удаляем старую строку и добавляем новую
|
if (cnt >= _maxPoints) { //удаляем старую строку и добавляем новую
|
||||||
String logData = readFile(filename, 20480); //10240
|
String logData = readFile(filename, 20480); //10240
|
||||||
SerialPrint("I", "Logging", "Free heap " + String(ESP.getFreeHeap()));
|
SerialPrint("I", "Logging", "Free heap " + String(ESP.getFreeHeap()));
|
||||||
if (logData == "large") {
|
if (logData == "large") {
|
||||||
SerialPrint("E", "Logging", "File is very large");
|
SerialPrint("E", "Logging", "File is very large");
|
||||||
}
|
}
|
||||||
//for (int i = 0; i < 5; i++) {
|
|
||||||
logData = deleteBeforeDelimiter(logData, "\r\n");
|
logData = deleteBeforeDelimiter(logData, "\r\n");
|
||||||
//}
|
|
||||||
if (timeNow->hasTimeSynced()) {
|
if (timeNow->hasTimeSynced()) {
|
||||||
logData += timeNow->getTimeUnix() + " " + loggingValue + "\r\n";
|
logData += timeNow->getTimeUnix() + " " + loggingValue + "\r\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user