Telegram Bot Api Client  0.6.1
Client_for_accessing_Telegram's_Bot_API
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
TelegramBotClient Class Reference

Public Member Functions

 TelegramBotClient (String token, Client &sslPollClient, Client &sslPostClient, TBC_CALLBACK_RECEIVE_SIGNATURE, TBC_CALLBACK_ERROR_SIGNATURE)
 Constructor. More...
 
 TelegramBotClient (String token, Client &sslPollClient, Client &sslPostClient)
 Constructor. More...
 
 TelegramBotClient (String token, Client &sslPollClient)
 Constructor. More...
 
 ~TelegramBotClient ()
 Destructor. More...
 
void begin (TBC_CALLBACK_RECEIVE_SIGNATURE, TBC_CALLBACK_ERROR_SIGNATURE)
 Alias for setCallbacks following Arduino convention. More...
 
void setCallbacks (TBC_CALLBACK_RECEIVE_SIGNATURE, TBC_CALLBACK_ERROR_SIGNATURE)
 Sets callbacks. More...
 
bool loop ()
 Handles client background tasks. More...
 
void postMessage (long chatId, String text, TBCKeyBoard &keyBoard)
 Post a message. More...
 
void postMessage (long chatId, String text)
 Post a message. More...
 
void pollSuccess (JwcProcessError err, JsonObject &json)
 Callback called by JSONWebClient. More...
 
void pollError (JwcProcessError err, Client *client)
 Callback called by JSONWebClient. More...
 
void postSuccess (JwcProcessError err, JsonObject &json)
 Callback called by JSONWebClient. More...
 
void postError (JwcProcessError err, Client *client)
 Callback called by JSONWebClient. More...
 

Static Public Member Functions

static void callbackPollSuccess (void *obj, JwcProcessError err, JsonObject &json)
 
static void callbackPollError (void *obj, JwcProcessError err, Client *client)
 
static void callbackPostSuccess (void *obj, JwcProcessError err, JsonObject &json)
 
static void callbackPostError (void *obj, JwcProcessError err, Client *client)
 

Private Member Functions

void startPolling ()
 Starts polling. More...
 
void startPosting (String Message)
 Starts posting a message. More...
 

Private Attributes

long LastUpdateId = 0
 
String Token
 
bool Parallel = false
 
JsonWebClientSslPollClient
 
JsonWebClientSslPostClient
 
 TBC_CALLBACK_RECEIVE_SIGNATURE
 
 TBC_CALLBACK_ERROR_SIGNATURE
 

Constructor & Destructor Documentation

◆ TelegramBotClient() [1/3]

TelegramBotClient::TelegramBotClient ( String  token,
Client &  sslPollClient,
Client &  sslPostClient,
TBC_CALLBACK_RECEIVE_SIGNATURE  ,
TBC_CALLBACK_ERROR_SIGNATURE   
)

Constructor.

Constructor, initializing all members including callbacks using different clients for posting and polling

Parameters
tokensecure token for your bot provided by BotFather.
sslPollClientSSL client used for polling messages from remote server
sslPostClientSSL client used for posting messages to remote server
TBC_CALLBACK_RECEIVE_SIGNATURECallback called on receiving a message
TBC_CALLBACK_ERROR_SIGNATURECallback called on error while receiving

◆ TelegramBotClient() [2/3]

TelegramBotClient::TelegramBotClient ( String  token,
Client &  sslPollClient,
Client &  sslPostClient 
)
inline

Constructor.

Constructor, initializing only members no callbacks using different clients for posting and polling

Parameters
tokensecure token for your bot provided by BotFather.
sslPollClientSSL client used for polling messages from remote server
sslPostClientSSL client used for posting messages to remote server

◆ TelegramBotClient() [3/3]

TelegramBotClient::TelegramBotClient ( String  token,
Client &  sslPollClient 
)
inline

Constructor.

Constructor, initializing only members no callbacks using the same client for posting and polling

Parameters
tokensecure token for your bot provided by BotFather.
sslPollClientSSL client used for polling messages from remote server
sslPostClientSSL client used for posting messages to remote server

◆ ~TelegramBotClient()

TelegramBotClient::~TelegramBotClient ( )

Destructor.

Destructor

Member Function Documentation

◆ begin()

void TelegramBotClient::begin ( TBC_CALLBACK_RECEIVE_SIGNATURE  ,
TBC_CALLBACK_ERROR_SIGNATURE   
)

Alias for setCallbacks following Arduino convention.

Parameters
[in]TBC_CALLBACK_RECEIVE_SIGNATURECallback called on receiving a message
[in]TBC_CALLBACK_ERROR_SIGNATURECallback called on error while receiving
Returns
Nothing

Alias for setCallbacks following Arduino convention sets callbacks

◆ loop()

bool TelegramBotClient::loop ( )

Handles client background tasks.

Returns
Return true is an action was needed and performed

Handles client background tasks, shall be calles in every main loop()

◆ pollError()

void TelegramBotClient::pollError ( JwcProcessError  err,
Client *  client 
)

Callback called by JSONWebClient.

Parameters
[in]errError Code from JwcProcessError
[in]clientClient that causes the problem.
Returns
Nothing

This is an internal method called by underlying JSONWebClient

Note
Do not call this method.

◆ pollSuccess()

void TelegramBotClient::pollSuccess ( JwcProcessError  err,
JsonObject &  json 
)

Callback called by JSONWebClient.

Parameters
[in]errError Code from JwcProcessError
[in]jsonJsonObject generated by ArduinoJSON
Returns
Nothing

This is an internal method called by underlying JSONWebClient

Note
Do not call this method.

◆ postError()

void TelegramBotClient::postError ( JwcProcessError  err,
Client *  client 
)

Callback called by JSONWebClient.

Parameters
[in]errError Code from JwcProcessError
[in]clientClient that causes the problem.
Returns
Nothing

This is an internal method called by underlying JSONWebClient

Note
Do not call this method.

◆ postMessage() [1/2]

void TelegramBotClient::postMessage ( long  chatId,
String  text,
TBCKeyBoard keyBoard 
)

Post a message.

Parameters
[in]chatIdId of the chat the message shall be sent to.
[in]textText of the message
[in]keyBoardOptional. Keyboard to be send with this message.
Returns
Nothing

Post a message to a given chat. (Only text messages and custom keyboards are supported, yet.)

◆ postMessage() [2/2]

void TelegramBotClient::postMessage ( long  chatId,
String  text 
)
inline

Post a message.

Parameters
[in]chatIdId of the chat the message shall be sent to.
[in]textText of the message
Returns
Nothing

Post a message to a given chat. (Only text messages and custom keyboards are supported, yet.)

◆ postSuccess()

void TelegramBotClient::postSuccess ( JwcProcessError  err,
JsonObject &  json 
)

Callback called by JSONWebClient.

Parameters
[in]errError Code from JwcProcessError
[in]jsonJsonObject generated by ArduinoJSON
Returns
Nothing

This is an internal method called by underlying JSONWebClient

Note
Do not call this method.

◆ setCallbacks()

void TelegramBotClient::setCallbacks ( TBC_CALLBACK_RECEIVE_SIGNATURE  ,
TBC_CALLBACK_ERROR_SIGNATURE   
)

Sets callbacks.

Parameters
[in]TBC_CALLBACK_RECEIVE_SIGNATURECallback called on receiving a message
[in]TBC_CALLBACK_ERROR_SIGNATURECallback called on error while receiving
Returns
Nothing

sets callbacks for receiving message and error handling

◆ startPolling()

void TelegramBotClient::startPolling ( )
private

Starts polling.

Returns
Nothing

Starts the polling by open a http long call

◆ startPosting()

void TelegramBotClient::startPosting ( String  Message)
private

Starts posting a message.

Parameters
[in]TheMessage to post as json string
Returns
Nothing

Start the posting of a message by open a http post call

Member Data Documentation

◆ LastUpdateId

long TelegramBotClient::LastUpdateId = 0
private

Id of last update, used to generate a call returning only messages more recent than the last received.

◆ Parallel

bool TelegramBotClient::Parallel = false
private

Indicates if the client uses two underlying client objects allowing posting while keeping the poll call open in parallel.

◆ SslPollClient

JsonWebClient* TelegramBotClient::SslPollClient
private

Underlying client for polling.

◆ SslPostClient

JsonWebClient* TelegramBotClient::SslPostClient
private

Underlying client for posting. In case of parallel mode it uses the same Client object than SslPollClient

◆ TBC_CALLBACK_ERROR_SIGNATURE

TelegramBotClient::TBC_CALLBACK_ERROR_SIGNATURE
private

Callback called on error

◆ TBC_CALLBACK_RECEIVE_SIGNATURE

TelegramBotClient::TBC_CALLBACK_RECEIVE_SIGNATURE
private

Callback called on receiving a message

◆ Token

String TelegramBotClient::Token
private

Secure Token provided by BotFather


The documentation for this class was generated from the following files: