13 #ifndef TelegramBotClient_h 14 #define TelegramBotClient_h 19 #include <ArduinoJson.h> 22 #define TELEGRAMHOST F("api.telegram.org") 23 #define TELEGRAMPORT 443 24 #define POLLINGTIMEOUT 600 25 #define USERAGENTSTRING F("telegrambotclient /0.1") 30 #define TBC_CALLBACK_RECEIVE_SIGNATURE std::function<void(TelegramProcessError, JwcProcessError, Message*)> callbackReceive 31 #define TBC_CALLBACK_ERROR_SIGNATURE std::function<void(TelegramProcessError, JwcProcessError)> callbackError 33 #define TBC_CALLBACK_RECEIVE_SIGNATURE void (*callbackReceive)(TelegramProcessError, JwcProcessError, Message*) 34 #define TBC_CALLBACK_ERROR_SIGNATURE void (*callbackError)(TelegramProcessError, JwcProcessError) 68 static String TelegramProcessErrorString[] = {
"Ok",
"JcwPollErr",
"JcwPostErr",
"RetPollErr",
"RetPostErr"};
72 return TelegramProcessErrorString[(-1) * (
int) err];
222 TBCKeyBoard (uint count,
bool oneTime =
false,
bool resize =
false);
248 const String
get(
const uint row,
const uint col);
258 const int length (
const uint row);
364 Client& sslPollClient,
365 Client& sslPostClient,
379 Client& sslPollClient,
380 Client& sslPostClient)
392 Client& sslPollClient)
513 static void callbackPollSuccess (
void* obj,
JwcProcessError err, JsonObject& json)
515 if (obj == 0)
return;
519 static void callbackPollError(
void* obj,
JwcProcessError err, Client* client)
521 if (obj == 0)
return;
525 static void callbackPostSuccess (
void* obj,
JwcProcessError err, JsonObject& json)
527 if (obj == 0)
return;
531 static void callbackPostError(
void* obj,
JwcProcessError err, Client* client)
533 if (obj == 0)
return;
Definition: JsonWebClient.h:136
long ChatId
Definition: TelegramBotClient.h:129
TBCKeyBoard & push(uint count, const String buttons[])
Adds a row to the keyboard.
Definition: TelegramBotClient.cpp:292
Definition: TelegramBotClient.h:164
Definition: TelegramBotClient.h:307
String Text
Definition: TelegramBotClient.h:142
Definition: TelegramBotClient.h:187
~TelegramBotClient()
Destructor.
Definition: TelegramBotClient.cpp:25
TBCKeyBoard(uint count, bool oneTime=false, bool resize=false)
Constructor.
Definition: TelegramBotClient.cpp:269
bool loop()
Handles client background tasks.
Definition: TelegramBotClient.cpp:50
void startPosting(String Message)
Starts posting a message.
Definition: TelegramBotClient.cpp:184
TelegramBotClient(String token, Client &sslPollClient, Client &sslPostClient, TBC_CALLBACK_RECEIVE_SIGNATURE, TBC_CALLBACK_ERROR_SIGNATURE)
Constructor.
Definition: TelegramBotClient.cpp:3
long FromId
Definition: TelegramBotClient.h:107
String Token
Definition: TelegramBotClient.h:315
void pollError(JwcProcessError err, Client *client)
Callback called by JSONWebClient.
Definition: TelegramBotClient.cpp:150
String ChatFirstName
Definition: TelegramBotClient.h:132
Definition: TelegramBotClient.h:93
void setCallbacks(TBC_CALLBACK_RECEIVE_SIGNATURE, TBC_CALLBACK_ERROR_SIGNATURE)
Sets callbacks.
Definition: TelegramBotClient.cpp:31
void postMessage(long chatId, String text)
Post a message.
Definition: TelegramBotClient.h:461
JsonWebClient * SslPollClient
Definition: TelegramBotClient.h:321
const int length()
Length of keyboard.
Definition: TelegramBotClient.cpp:319
~TBCKeyBoard()
Destructor.
Definition: TelegramBotClient.cpp:282
JsonWebClient * SslPostClient
Definition: TelegramBotClient.h:325
long LastUpdateId
Definition: TelegramBotClient.h:313
String FromLanguageCode
Definition: TelegramBotClient.h:121
String ChatType
Definition: TelegramBotClient.h:138
String FromFirstName
Definition: TelegramBotClient.h:114
TelegramBotClient(String token, Client &sslPollClient)
Constructor.
Definition: TelegramBotClient.h:390
void postSuccess(JwcProcessError err, JsonObject &json)
Callback called by JSONWebClient.
Definition: TelegramBotClient.cpp:254
long MessageId
Definition: TelegramBotClient.h:104
bool FromIsBot
Definition: TelegramBotClient.h:110
const bool getOneTime()
Gets value of OneTime.
Definition: TelegramBotClient.h:276
const bool getResize()
Gets value of Resize.
Definition: TelegramBotClient.h:286
void postMessage(long chatId, String text, TBCKeyBoard &keyBoard)
Post a message.
Definition: TelegramBotClient.cpp:211
void begin(TBC_CALLBACK_RECEIVE_SIGNATURE, TBC_CALLBACK_ERROR_SIGNATURE)
Alias for setCallbacks following Arduino convention.
Definition: TelegramBotClient.cpp:40
String FromLastName
Definition: TelegramBotClient.h:117
String ChatLastName
Definition: TelegramBotClient.h:135
bool Parallel
Definition: TelegramBotClient.h:319
bool OneTime
Definition: TelegramBotClient.h:203
long UpdateId
Definition: TelegramBotClient.h:101
TelegramBotClient(String token, Client &sslPollClient, Client &sslPostClient)
Constructor.
Definition: TelegramBotClient.h:377
bool Resize
Definition: TelegramBotClient.h:213
TBC_CALLBACK_RECEIVE_SIGNATURE
Definition: TelegramBotClient.h:346
void pollSuccess(JwcProcessError err, JsonObject &json)
Callback called by JSONWebClient.
Definition: TelegramBotClient.cpp:98
void startPolling()
Starts polling.
Definition: TelegramBotClient.cpp:68
TBC_CALLBACK_ERROR_SIGNATURE
Definition: TelegramBotClient.h:348
void postError(JwcProcessError err, Client *client)
Callback called by JSONWebClient.
Definition: TelegramBotClient.cpp:259
long Date
Definition: TelegramBotClient.h:146
Header of a simple web client receiving json uses an underlying implementation of Client interface...