File tree Expand file tree Collapse file tree 1 file changed +7
-24
lines changed Expand file tree Collapse file tree 1 file changed +7
-24
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,7 @@ String UniversalTelegramBot::buildCommand(const String& cmd) {
66
66
}
67
67
68
68
String UniversalTelegramBot::sendGetToTelegram (const String& command) {
69
- String mess;
70
- long now;
69
+ String body, headers;
71
70
bool avail;
72
71
73
72
// Connect with api.telegram.org if not already connected
@@ -91,30 +90,14 @@ String UniversalTelegramBot::sendGetToTelegram(const String& command) {
91
90
char c;
92
91
int ch_count = 0 ;
93
92
client->print (F (" GET /" ));
94
- client->println (command);
95
- now = millis ();
96
- avail = false ;
97
- while (millis () - now < longPoll * 1000 + waitForResponse) {
98
- while (client->available ()) {
99
- char c = client->read ();
100
- if (ch_count < maxMessageLength) {
101
- mess += c;
102
- ch_count++;
103
- }
104
- avail = true ;
105
- }
106
- if (avail) {
107
- #ifdef _debug
108
- Serial.println ();
109
- Serial.println (mess);
110
- Serial.println ();
111
- #endif
112
- break ;
113
- }
114
- }
93
+ client->print (command);
94
+ client->println (F (" HTTP/1.0" ));
95
+ client->println (F (" Host: " HOST));
96
+ client->println (F (" " ));
97
+ readHTTPAnswer (body, headers);
115
98
}
116
99
117
- return mess ;
100
+ return body ;
118
101
}
119
102
120
103
bool UniversalTelegramBot::readHTTPAnswer (String &body, String &headers) {
You can’t perform that action at this time.
0 commit comments