mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
Merge pull request #212 from biveraxe/ver4dev
Убираем зависимость от размерности ЧатИД в TelegramLT
This commit is contained in:
@@ -7,7 +7,7 @@ class TelegramLT : public IoTItem
|
|||||||
public:
|
public:
|
||||||
String _prevMsg = "";
|
String _prevMsg = "";
|
||||||
String _token;
|
String _token;
|
||||||
unsigned long _chatID;
|
String _chatID;
|
||||||
|
|
||||||
TelegramLT(String parameters) : IoTItem(parameters) {
|
TelegramLT(String parameters) : IoTItem(parameters) {
|
||||||
jsonRead(parameters, "token", _token);
|
jsonRead(parameters, "token", _token);
|
||||||
@@ -21,11 +21,11 @@ public:
|
|||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.begin(client, "http://live-control.com/iotm/telegram.php");
|
http.begin(client, "http://live-control.com/iotm/telegram.php");
|
||||||
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
String httpRequestData = "url=https://api.telegram.org/bot" + _token + "/sendmessage?chat_id=" + uint64ToString(_chatID) + "&text=" + msg;
|
String httpRequestData = "url=https://api.telegram.org/bot" + _token + "/sendmessage?chat_id=" + _chatID + "&text=" + msg;
|
||||||
int httpResponseCode = http.POST(httpRequestData);
|
int httpResponseCode = http.POST(httpRequestData);
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
SerialPrint("<-", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + ", msg: " + msg);
|
SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg);
|
||||||
SerialPrint("->", F("Telegram"), "chat ID: " + uint64ToString(_chatID) + ", server: " + httpResponseCode);
|
SerialPrint("->", F("Telegram"), "chat ID: " + _chatID + ", server: " + httpResponseCode);
|
||||||
|
|
||||||
if (!strstr(payload.c_str(), "{\"ok\":true")) {
|
if (!strstr(payload.c_str(), "{\"ok\":true")) {
|
||||||
value.valD = 1;
|
value.valD = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user