Skip to content

Commit 74f39db

Browse files
committed
retabbing
1 parent 5958034 commit 74f39db

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
UniversalTelegramBot::UniversalTelegramBot(String token, Client &client) {
3939
_token = token;
4040
#ifdef ARDUINO_ESP8266_RELEASE_2_5_0
41-
//client->setInsecure();
41+
//client->setInsecure();
4242
#endif
4343
this->client = &client;
4444
}
@@ -51,19 +51,19 @@ String UniversalTelegramBot::sendGetToTelegram(String command) {
5151
// Connect with api.telegram.org if not already connected
5252
if (!client->connected()) {
5353
#ifdef _debug
54-
Serial.println(F("[BOT]Connecting to server"));
55-
#endif
54+
Serial.println(F("[BOT]Connecting to server"));
55+
#endif
5656
if (!client->connect(HOST, SSL_PORT)) {
5757
#ifdef _debug
58-
Serial.println(F("[BOT]Conection error"));
59-
#endif
58+
Serial.println(F("[BOT]Conection error"));
59+
#endif
6060
}
6161
}
6262
if (client->connected()) {
6363

6464
#ifdef _debug
65-
Serial.println(F(".... connected to server"));
66-
#endif
65+
Serial.println(F(".... connected to server"));
66+
#endif
6767

6868
String a = "";
6969
char c;
@@ -104,12 +104,12 @@ String UniversalTelegramBot::sendPostToTelegram(String command, JsonObject paylo
104104
// Connect with api.telegram.org if not already connected
105105
if (!client->connected()) {
106106
#ifdef _debug
107-
Serial.println(F("[BOT Client]Connecting to server"));
108-
#endif
107+
Serial.println(F("[BOT Client]Connecting to server"));
108+
#endif
109109
if (!client->connect(HOST, SSL_PORT)) {
110110
#ifdef _debug
111-
Serial.println(F("[BOT Client]Conection error"));
112-
#endif
111+
Serial.println(F("[BOT Client]Conection error"));
112+
#endif
113113
}
114114
}
115115
if (client->connected()) {
@@ -180,7 +180,7 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
180180
String contentType, String chat_id, int fileSize,
181181
MoreDataAvailable moreDataAvailableCallback,
182182
GetNextByte getNextByteCallback,
183-
GetNextBuffer getNextBufferCallback,
183+
GetNextBuffer getNextBufferCallback,
184184
GetNextBufferLen getNextBufferLenCallback) {
185185

186186
String body = "";
@@ -195,12 +195,12 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
195195
// Connect with api.telegram.org if not already connected
196196
if (!client->connected()) {
197197
#ifdef _debug
198-
Serial.println(F("[BOT Client]Connecting to server"));
199-
#endif
198+
Serial.println(F("[BOT Client]Connecting to server"));
199+
#endif
200200
if (!client->connect(HOST, SSL_PORT)) {
201201
#ifdef _debug
202-
Serial.println(F("[BOT Client]Conection error"));
203-
#endif
202+
Serial.println(F("[BOT Client]Conection error"));
203+
#endif
204204
}
205205
}
206206
if (client->connected()) {
@@ -230,29 +230,29 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
230230

231231
int contentLength = fileSize + start_request.length() + end_request.length();
232232
#ifdef _debug
233-
Serial.println("Content-Length: " + String(contentLength));
234-
#endif
233+
Serial.println("Content-Length: " + String(contentLength));
234+
#endif
235235
client->print("Content-Length: ");
236236
client->println(String(contentLength));
237237
client->println("Content-Type: multipart/form-data; boundary=" + boundry);
238238
client->println("");
239239
client->print(start_request);
240240

241241
#ifdef _debug
242-
Serial.print("Start request: " + start_request);
243-
#endif
242+
Serial.print("Start request: " + start_request);
243+
#endif
244244

245245
if (getNextByteCallback == nullptr) {
246246
while (moreDataAvailableCallback()) {
247247
client->write((const uint8_t *)getNextBufferCallback(), getNextBufferLenCallback());
248248
#ifdef _debug
249-
Serial.println(F("Sending photo from buffer"));
250-
#endif
249+
Serial.println(F("Sending photo from buffer"));
250+
#endif
251251
}
252252
} else {
253253
#ifdef _debug
254-
Serial.println(F("Sending photo by binary"));
255-
#endif
254+
Serial.println(F("Sending photo by binary"));
255+
#endif
256256
byte buffer[512];
257257
int count = 0;
258258
char ch;
@@ -279,8 +279,8 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
279279

280280
client->print(end_request);
281281
#ifdef _debug
282-
Serial.print("End request: " + end_request);
283-
#endif
282+
Serial.print("End request: " + end_request);
283+
#endif
284284
int ch_count = 0;
285285
now = millis();
286286

@@ -351,7 +351,7 @@ bool UniversalTelegramBot::getMe() {
351351
int UniversalTelegramBot::getUpdates(long offset) {
352352

353353
#ifdef _debug
354-
Serial.println(F("GET Update Messages"));
354+
Serial.println(F("GET Update Messages"));
355355
#endif
356356
String command = "bot" + _token + "/getUpdates?offset=" + String(offset) + "&limit=" + String(HANDLE_MESSAGES);
357357
if (longPoll > 0) {
@@ -361,8 +361,8 @@ int UniversalTelegramBot::getUpdates(long offset) {
361361

362362
if (response == "") {
363363
#ifdef _debug
364-
Serial.println(F("Received empty string in response!"));
365-
#endif
364+
Serial.println(F("Received empty string in response!"));
365+
#endif
366366
// close the client as there's nothing to do with an empty string
367367
closeClient();
368368
return 0;
@@ -376,19 +376,19 @@ int UniversalTelegramBot::getUpdates(long offset) {
376376
// Parse response into Json object
377377
DynamicJsonDocument doc(maxMessageLength);
378378
DeserializationError error = deserializeJson(doc, response);
379-
#ifdef _debug
380-
Serial.print(F("GetUpdates parsed jsonDoc: "));
381-
serializeJson(doc, Serial);
382-
Serial.println();
383-
#endif
384-
379+
#ifdef _debug
380+
Serial.print(F("GetUpdates parsed jsonDoc: "));
381+
serializeJson(doc, Serial);
382+
Serial.println();
383+
#endif
384+
385385
JsonObject obj = doc.as<JsonObject>(); //there is nothing better right now
386386
if (!error) {
387387
#ifdef _debug
388-
Serial.print(F("GetUpdates parsed jsonObj: "));
389-
serializeJson(obj, Serial);
390-
Serial.println();
391-
#endif
388+
Serial.print(F("GetUpdates parsed jsonObj: "));
389+
serializeJson(obj, Serial);
390+
Serial.println();
391+
#endif
392392
if (obj.containsKey("result")) {
393393
int resultArrayLength = doc["result"].size();
394394
if (resultArrayLength > 0) {
@@ -403,27 +403,27 @@ int UniversalTelegramBot::getUpdates(long offset) {
403403
return newMessageIndex;
404404
} else {
405405
#ifdef _debug
406-
Serial.println(F("no new messages"));
407-
#endif
406+
Serial.println(F("no new messages"));
407+
#endif
408408
}
409409
} else {
410410
#ifdef _debug
411-
Serial.println(F("Response contained no 'result'"));
412-
#endif
411+
Serial.println(F("Response contained no 'result'"));
412+
#endif
413413
}
414414
} else { // Parsing failed
415415
if (response.length() < 2) { // Too short a message. Maybe a connection issue
416416
#ifdef _debug
417-
Serial.println(F("Parsing error: Message too short"));
418-
#endif
417+
Serial.println(F("Parsing error: Message too short"));
418+
#endif
419419
} else {
420420
// Buffer may not be big enough, increase buffer or reduce max number of
421421
// messages
422422
#ifdef _debug
423-
Serial.print(F("Failed to parse update, the message could be too "
423+
Serial.print(F("Failed to parse update, the message could be too "
424424
"big for the buffer. Error code: "));
425-
Serial.println(error.c_str()); // debug print of parsing error
426-
#endif
425+
Serial.println(error.c_str()); // debug print of parsing error
426+
#endif
427427
}
428428
}
429429
// Close the client as no response is to be given
@@ -517,7 +517,7 @@ bool UniversalTelegramBot::sendSimpleMessage(String chat_id, String text,
517517

518518
bool sent = false;
519519
#ifdef _debug
520-
Serial.println(F("sendSimpleMessage: SEND Simple Message"));
520+
Serial.println(F("sendSimpleMessage: SEND Simple Message"));
521521
#endif
522522
long sttime = millis();
523523

@@ -527,8 +527,8 @@ bool UniversalTelegramBot::sendSimpleMessage(String chat_id, String text,
527527
"&text=" + text + "&parse_mode=" + parse_mode;
528528
String response = sendGetToTelegram(command);
529529
#ifdef _debug
530-
Serial.println(response);
531-
#endif
530+
Serial.println(response);
531+
#endif
532532
sent = checkForOkResponse(response);
533533
if (sent) break;
534534
}
@@ -614,8 +614,8 @@ bool UniversalTelegramBot::sendPostMessage(JsonObject payload) {
614614
bool sent = false;
615615
#ifdef _debug
616616
Serial.print(F("sendPostMessage: SEND Post Message: "));
617-
serializeJson(payload, Serial);
618-
Serial.println();
617+
serializeJson(payload, Serial);
618+
Serial.println();
619619
#endif
620620
long sttime = millis();
621621

@@ -624,8 +624,8 @@ bool UniversalTelegramBot::sendPostMessage(JsonObject payload) {
624624
String command = "bot" + _token + "/sendMessage";
625625
String response = sendPostToTelegram(command, payload);
626626
#ifdef _debug
627-
Serial.println(response);
628-
#endif
627+
Serial.println(response);
628+
#endif
629629
sent = checkForOkResponse(response);
630630
if (sent) break;
631631
}
@@ -640,7 +640,7 @@ String UniversalTelegramBot::sendPostPhoto(JsonObject payload) {
640640
bool sent = false;
641641
String response = "";
642642
#ifdef _debug
643-
Serial.println(F("sendPostPhoto: SEND Post Photo"));
643+
Serial.println(F("sendPostPhoto: SEND Post Photo"));
644644
#endif
645645
long sttime = millis();
646646

@@ -649,8 +649,8 @@ String UniversalTelegramBot::sendPostPhoto(JsonObject payload) {
649649
String command = "bot" + _token + "/sendPhoto";
650650
response = sendPostToTelegram(command, payload);
651651
#ifdef _debug
652-
Serial.println(response);
653-
#endif
652+
Serial.println(response);
653+
#endif
654654
sent = checkForOkResponse(response);
655655
if (sent) break;
656656

@@ -667,15 +667,15 @@ String UniversalTelegramBot::sendPhotoByBinary(
667667
GetNextByte getNextByteCallback, GetNextBuffer getNextBufferCallback, GetNextBufferLen getNextBufferLenCallback) {
668668

669669
#ifdef _debug
670-
Serial.println(F("sendPhotoByBinary: SEND Photo"));
670+
Serial.println(F("sendPhotoByBinary: SEND Photo"));
671671
#endif
672672

673673
String response = sendMultipartFormDataToTelegram("sendPhoto", "photo", "img.jpg",
674674
contentType, chat_id, fileSize,
675675
moreDataAvailableCallback, getNextByteCallback, getNextBufferCallback, getNextBufferLenCallback);
676676

677677
#ifdef _debug
678-
Serial.println(response);
678+
Serial.println(response);
679679
#endif
680680

681681
return response;
@@ -727,7 +727,7 @@ bool UniversalTelegramBot::sendChatAction(String chat_id, String text) {
727727

728728
bool sent = false;
729729
#ifdef _debug
730-
Serial.println(F("SEND Chat Action Message"));
730+
Serial.println(F("SEND Chat Action Message"));
731731
#endif
732732
long sttime = millis();
733733

@@ -738,8 +738,8 @@ bool UniversalTelegramBot::sendChatAction(String chat_id, String text) {
738738
String response = sendGetToTelegram(command);
739739

740740
#ifdef _debug
741-
Serial.println(response);
742-
#endif
741+
Serial.println(response);
742+
#endif
743743
sent = checkForOkResponse(response);
744744

745745
if (sent) break;
@@ -754,9 +754,9 @@ bool UniversalTelegramBot::sendChatAction(String chat_id, String text) {
754754
void UniversalTelegramBot::closeClient() {
755755
if (client->connected()) {
756756
#ifdef _debug
757-
Serial.println(F("Closing client"));
758-
#endif
759-
client->stop();
757+
Serial.println(F("Closing client"));
758+
#endif
759+
client->stop();
760760
}
761761
}
762762

0 commit comments

Comments
 (0)