This commit is contained in:
2022-01-11 15:33:36 +03:00
2 changed files with 23 additions and 8 deletions

View File

@@ -74,13 +74,21 @@ void telegramMsgParse(String msg) {
void sendTelegramMsg() { void sendTelegramMsg() {
String sabject = sCmd.next(); String sabject = sCmd.next();
String msg = sCmd.next(); String msg = sCmd.next();
String ID_name = "";
String ID_value = "";
if (sabject == "often") { if (sabject == "often") {
msg.replace("#", " "); msg.replace("#", " ");
msg.replace("%date%", timeNow->getDateTimeDotFormated()); msg.replace("%date%", timeNow->getDateTimeDotFormated());
msg.replace("%weekday%", timeNow->getWeekday()); msg.replace("%weekday%", timeNow->getWeekday());
msg.replace("%IP%", jsonReadStr(configSetupJson, F("ip"))); msg.replace("%IP%", jsonReadStr(configSetupJson, F("ip")));
msg.replace("%name%", jsonReadStr(configSetupJson, F("name"))); msg.replace("%name%", jsonReadStr(configSetupJson, F("name")));
if (msg.indexOf("_") != -1) {
ID_name = deleteBeforeDelimiter(msg, "_");
ID_name = deleteAfterDelimiter(ID_name, "_");
ID_value = getValue(ID_name);
msg.replace(ID_name, ID_value);
}
msg.replace("_", " ");
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg); myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg); SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);
} else { } else {
@@ -93,6 +101,13 @@ void sendTelegramMsg() {
msg.replace("%weekday%", timeNow->getWeekday()); msg.replace("%weekday%", timeNow->getWeekday());
msg.replace("%IP%", jsonReadStr(configSetupJson, F("ip"))); msg.replace("%IP%", jsonReadStr(configSetupJson, F("ip")));
msg.replace("%name%", jsonReadStr(configSetupJson, F("name"))); msg.replace("%name%", jsonReadStr(configSetupJson, F("name")));
if (msg.indexOf("_") != -1) {
ID_name = deleteBeforeDelimiter(msg, "_");
ID_name = deleteAfterDelimiter(ID_name, "_");
ID_value = getValue(ID_name);
msg.replace(ID_name, ID_value);
}
msg.replace("_", " ");
myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg); myBot->sendMessage(jsonReadInt(configSetupJson, "chatId"), msg);
SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg); SerialPrint("<-", F("Telegram"), "chat ID: " + String(jsonReadInt(configSetupJson, "chatId")) + ", msg: " + msg);

View File

@@ -24,7 +24,7 @@ void ImpulsOutClass::loop() {
currentMillis = millis(); currentMillis = millis();
difference = currentMillis - prevMillis; difference = currentMillis - prevMillis;
if (_impulsCountBuf > 0) { if (_impulsCountBuf > 0) {
if (difference > _impulsPeriod) { if (difference >= _impulsPeriod) {
_impulsCountBuf--; _impulsCountBuf--;
prevMillis = millis(); prevMillis = millis();
yield(); yield();