mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
telegram
This commit is contained in:
@@ -10,7 +10,7 @@ WiFiClient espClient;
|
||||
PubSubClient mqtt(espClient);
|
||||
StringCommand sCmd;
|
||||
AsyncWebServer server(80);
|
||||
OneWire *oneWire;
|
||||
OneWire* oneWire;
|
||||
DallasTemperature sensors;
|
||||
|
||||
/*
|
||||
@@ -25,6 +25,7 @@ String configSetupJson = "{}";
|
||||
String configLiveJson = "{}";
|
||||
String configStoreJson = "{}";
|
||||
String configOptionJson = "{}";
|
||||
String telegramMsgJson = "{}";
|
||||
|
||||
// Mqtt
|
||||
String chipId = "";
|
||||
@@ -70,7 +71,7 @@ String presetName;
|
||||
String serverIP;
|
||||
|
||||
// Scenario
|
||||
int scenario_line_status[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
int scenario_line_status[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
int lastVersion;
|
||||
|
||||
boolean busScanFlag = false;
|
||||
|
||||
@@ -70,23 +70,21 @@ void telegramMsgParse(String msg) {
|
||||
}
|
||||
|
||||
void sendTelegramMsg() {
|
||||
String id = sCmd.next();
|
||||
String msg = sCmd.next();
|
||||
String type = sCmd.next();
|
||||
msg.replace("#", " ");
|
||||
if (type == "1") {
|
||||
static String prevMsg;
|
||||
if (prevMsg != msg) {
|
||||
prevMsg = msg;
|
||||
if (msg != "na") {
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||
}
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||
}
|
||||
}
|
||||
else if (type == "2") {
|
||||
if (id == "often") {
|
||||
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) {
|
||||
jsonWriteStr(telegramMsgJson, id, msg);
|
||||
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
|
||||
SerialPrint("<-", "Telegram", "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isTelegramEnabled() {
|
||||
|
||||
11
src/Web.cpp
11
src/Web.cpp
@@ -26,12 +26,11 @@ void web_init() {
|
||||
|
||||
if (request->hasArg(F("addPreset"))) {
|
||||
addPreset2(request->getParam(F("addPreset"))->value().toInt());
|
||||
if (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>"));
|
||||
}
|
||||
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>"));
|
||||
}
|
||||
#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>"));
|
||||
#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>"));
|
||||
#endif
|
||||
request->redirect(F("/?set.device"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user