38
38
#define ZERO_COPY (STR ) ((char *)STR.c_str())
39
39
#define BOT_CMD (STR ) buildCommand(F(STR))
40
40
41
- UniversalTelegramBot::UniversalTelegramBot (String token, Client &client) {
42
- _token = token;
41
+ UniversalTelegramBot::UniversalTelegramBot (const String& token, Client &client) {
42
+ updateToken ( token) ;
43
43
#ifdef ARDUINO_ESP8266_RELEASE_2_5_0
44
44
// client->setInsecure();
45
45
#endif
46
46
this ->client = &client;
47
47
}
48
48
49
- void UniversalTelegramBot::updateToken (String token) {
49
+ void UniversalTelegramBot::updateToken (const String& token) {
50
50
_token = token;
51
51
}
52
52
53
- String UniversalTelegramBot::buildCommand (String cmd) {
53
+ String UniversalTelegramBot::buildCommand (const String& cmd) {
54
54
String command;
55
55
56
56
command += F (" bot" );
@@ -61,7 +61,7 @@ String UniversalTelegramBot::buildCommand(String cmd) {
61
61
return command;
62
62
}
63
63
64
- String UniversalTelegramBot::sendGetToTelegram (String command) {
64
+ String UniversalTelegramBot::sendGetToTelegram (const String& command) {
65
65
String mess = " " ;
66
66
long now;
67
67
bool avail;
@@ -113,7 +113,7 @@ String UniversalTelegramBot::sendGetToTelegram(String command) {
113
113
return mess;
114
114
}
115
115
116
- String UniversalTelegramBot::sendPostToTelegram (String command, JsonObject payload) {
116
+ String UniversalTelegramBot::sendPostToTelegram (const String& command, JsonObject payload) {
117
117
118
118
String body = " " ;
119
119
String headers = " " ;
@@ -195,8 +195,8 @@ String UniversalTelegramBot::sendPostToTelegram(String command, JsonObject paylo
195
195
}
196
196
197
197
String UniversalTelegramBot::sendMultipartFormDataToTelegram (
198
- String command, String binaryProperyName, String fileName,
199
- String contentType, String chat_id, int fileSize,
198
+ const String& command, const String& binaryProperyName, const String& fileName,
199
+ const String& contentType, const String& chat_id, int fileSize,
200
200
MoreDataAvailable moreDataAvailableCallback,
201
201
GetNextByte getNextByteCallback,
202
202
GetNextBuffer getNextBufferCallback,
@@ -577,8 +577,8 @@ bool UniversalTelegramBot::processResult(JsonObject result, int messageIndex) {
577
577
* SendMessage - function to send message to telegram *
578
578
* (Arguments to pass: chat_id, text to transmit and markup(optional)) *
579
579
***********************************************************************/
580
- bool UniversalTelegramBot::sendSimpleMessage (String chat_id, String text,
581
- String parse_mode) {
580
+ bool UniversalTelegramBot::sendSimpleMessage (const String& chat_id, const String& text,
581
+ const String& parse_mode) {
582
582
583
583
bool sent = false ;
584
584
#ifdef _debug
@@ -606,8 +606,8 @@ bool UniversalTelegramBot::sendSimpleMessage(String chat_id, String text,
606
606
return sent;
607
607
}
608
608
609
- bool UniversalTelegramBot::sendMessage (String chat_id, String text,
610
- String parse_mode) {
609
+ bool UniversalTelegramBot::sendMessage (const String& chat_id, const String& text,
610
+ const String& parse_mode) {
611
611
612
612
DynamicJsonDocument payload (maxMessageLength);
613
613
payload[" chat_id" ] = chat_id;
@@ -620,7 +620,7 @@ bool UniversalTelegramBot::sendMessage(String chat_id, String text,
620
620
}
621
621
622
622
bool UniversalTelegramBot::sendMessageWithReplyKeyboard (
623
- String chat_id, String text, String parse_mode, String keyboard,
623
+ const String& chat_id, const String& text, const String& parse_mode, const String& keyboard,
624
624
bool resize, bool oneTime, bool selective) {
625
625
626
626
DynamicJsonDocument payload (maxMessageLength);
@@ -648,10 +648,10 @@ bool UniversalTelegramBot::sendMessageWithReplyKeyboard(
648
648
return sendPostMessage (payload.as <JsonObject>());
649
649
}
650
650
651
- bool UniversalTelegramBot::sendMessageWithInlineKeyboard (String chat_id,
652
- String text,
653
- String parse_mode,
654
- String keyboard) {
651
+ bool UniversalTelegramBot::sendMessageWithInlineKeyboard (const String& chat_id,
652
+ const String& text,
653
+ const String& parse_mode,
654
+ const String& keyboard) {
655
655
656
656
DynamicJsonDocument payload (maxMessageLength);
657
657
payload[" chat_id" ] = chat_id;
@@ -720,7 +720,7 @@ String UniversalTelegramBot::sendPostPhoto(JsonObject payload) {
720
720
}
721
721
722
722
String UniversalTelegramBot::sendPhotoByBinary (
723
- String chat_id, String contentType, int fileSize,
723
+ const String& chat_id, const String& contentType, int fileSize,
724
724
MoreDataAvailable moreDataAvailableCallback,
725
725
GetNextByte getNextByteCallback, GetNextBuffer getNextBufferCallback, GetNextBufferLen getNextBufferLenCallback) {
726
726
@@ -739,11 +739,11 @@ String UniversalTelegramBot::sendPhotoByBinary(
739
739
return response;
740
740
}
741
741
742
- String UniversalTelegramBot::sendPhoto (String chat_id, String photo,
743
- String caption,
742
+ String UniversalTelegramBot::sendPhoto (const String& chat_id, const String& photo,
743
+ const String& caption,
744
744
bool disable_notification,
745
745
int reply_to_message_id,
746
- String keyboard) {
746
+ const String& keyboard) {
747
747
748
748
DynamicJsonDocument payload (maxMessageLength);
749
749
payload[" chat_id" ] = chat_id;
@@ -766,7 +766,7 @@ String UniversalTelegramBot::sendPhoto(String chat_id, String photo,
766
766
return sendPostPhoto (payload.as <JsonObject>());
767
767
}
768
768
769
- bool UniversalTelegramBot::checkForOkResponse (String & response) {
769
+ bool UniversalTelegramBot::checkForOkResponse (const String& response) {
770
770
int last_id;
771
771
DynamicJsonDocument doc (response.length ());
772
772
deserializeJson (doc, response);
@@ -778,7 +778,7 @@ bool UniversalTelegramBot::checkForOkResponse(String &response) {
778
778
return doc[" ok" ] | false ; // default is false, but this is more explicit and clear
779
779
}
780
780
781
- bool UniversalTelegramBot::sendChatAction (String chat_id, String text) {
781
+ bool UniversalTelegramBot::sendChatAction (const String& chat_id, const String& text) {
782
782
783
783
bool sent = false ;
784
784
#ifdef _debug
0 commit comments