This commit is contained in:
Dmitry Borisenko
2020-12-18 14:28:31 +01:00
parent a467117df9
commit 9ac72f14e0
4 changed files with 19 additions and 20 deletions

View File

@@ -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() {