mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
telegram
This commit is contained in:
@@ -54,6 +54,7 @@ extern String configSetupJson; //все настройки
|
|||||||
extern String configLiveJson; //все данные с датчиков (связан с mqtt)
|
extern String configLiveJson; //все данные с датчиков (связан с mqtt)
|
||||||
extern String configStoreJson; //все данные которые должны сохраняться
|
extern String configStoreJson; //все данные которые должны сохраняться
|
||||||
extern String configOptionJson; //для трансфера
|
extern String configOptionJson; //для трансфера
|
||||||
|
extern String telegramMsgJson;
|
||||||
extern String getValue(String& key);
|
extern String getValue(String& key);
|
||||||
|
|
||||||
// Mqtt
|
// Mqtt
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ String configSetupJson = "{}";
|
|||||||
String configLiveJson = "{}";
|
String configLiveJson = "{}";
|
||||||
String configStoreJson = "{}";
|
String configStoreJson = "{}";
|
||||||
String configOptionJson = "{}";
|
String configOptionJson = "{}";
|
||||||
|
String telegramMsgJson = "{}";
|
||||||
|
|
||||||
// Mqtt
|
// Mqtt
|
||||||
String chipId = "";
|
String chipId = "";
|
||||||
|
|||||||
@@ -70,24 +70,22 @@ void telegramMsgParse(String msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendTelegramMsg() {
|
void sendTelegramMsg() {
|
||||||
|
String id = sCmd.next();
|
||||||
String msg = sCmd.next();
|
String msg = sCmd.next();
|
||||||
String type = sCmd.next();
|
|
||||||
msg.replace("#", " ");
|
msg.replace("#", " ");
|
||||||
if (type == "1") {
|
if (id == "often") {
|
||||||
static String prevMsg;
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||||
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String prevMsg = jsonReadStr(telegramMsgJson, id);
|
||||||
if (prevMsg != msg) {
|
if (prevMsg != msg) {
|
||||||
prevMsg = msg;
|
jsonWriteStr(telegramMsgJson, id, msg);
|
||||||
if (msg != "na") {
|
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
|
||||||
}
|
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == "2") {
|
|
||||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool isTelegramEnabled() {
|
bool isTelegramEnabled() {
|
||||||
return jsonReadBool(configSetupJson, "telegonof");
|
return jsonReadBool(configSetupJson, "telegonof");
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ void web_init() {
|
|||||||
|
|
||||||
if (request->hasArg(F("addPreset"))) {
|
if (request->hasArg(F("addPreset"))) {
|
||||||
addPreset2(request->getParam(F("addPreset"))->value().toInt());
|
addPreset2(request->getParam(F("addPreset"))->value().toInt());
|
||||||
if (FLASH_SIZE_1MB) {
|
#ifdef FLASH_SIZE_1MB
|
||||||
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Присеты не доступны, модуль на 1mb</p></font></div>"));
|
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Присеты не доступны, модуль на 1mb</p></font></div>"));
|
||||||
}
|
#else
|
||||||
else {
|
|
||||||
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
jsonWriteStr(configSetupJson, F("warning1"), F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||||
}
|
#endif
|
||||||
request->redirect(F("/?set.device"));
|
request->redirect(F("/?set.device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user