mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Добавил событие об успешной отправке
This commit is contained in:
@@ -9,14 +9,16 @@ public:
|
||||
String _token;
|
||||
String _chatID;
|
||||
|
||||
TelegramLT(String parameters) : IoTItem(parameters) {
|
||||
TelegramLT(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
jsonRead(parameters, "token", _token);
|
||||
jsonRead(parameters, "chatID", _chatID);
|
||||
}
|
||||
|
||||
void sendTelegramMsg(bool often, String msg)
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECTED && (often || !often && _prevMsg != msg)) {
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECTED && (often || !often && _prevMsg != msg))
|
||||
{
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
http.begin(client, "http://live-control.com/iotm/telegram.php");
|
||||
@@ -27,12 +29,16 @@ public:
|
||||
SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg);
|
||||
SerialPrint("->", F("Telegram"), "chat ID: " + _chatID + ", server: " + httpResponseCode);
|
||||
|
||||
if (!strstr(payload.c_str(), "{\"ok\":true")) {
|
||||
value.valD = 1;
|
||||
if (!strstr(payload.c_str(), "{\"ok\":true"))
|
||||
{
|
||||
value.valD = 0;
|
||||
Serial.printf("Telegram error, msg from server: %s\n", payload.c_str());
|
||||
regEvent(value.valD, payload);
|
||||
} else {
|
||||
value.valD = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value.valD = 1;
|
||||
regEvent(value.valD, payload);
|
||||
}
|
||||
http.end();
|
||||
_prevMsg = msg;
|
||||
@@ -41,7 +47,8 @@ public:
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||
{
|
||||
if (param.size() == 1) {
|
||||
if (param.size() == 1)
|
||||
{
|
||||
String strTmp;
|
||||
if (param[0].isDecimal && param[0].valS == "")
|
||||
strTmp = param[0].valD;
|
||||
|
||||
Reference in New Issue
Block a user