qTbot 0.87.9547b0c
qTbot is base back end library for your c++ Qt projects.
qTbot::TelegramRestBot Class Reference

The TelegramRestBot class Is Rest implementation base on the Update API telegram method. More...

#include <telegramrestbot.h>

Public Member Functions

 TelegramRestBot ()
 
 ~TelegramRestBot ()
 
bool login (const QByteArray &token) override
 login This method get bae information of the bot from remote server.
 
void logout () override
 login This method remove login token of bot.
 
int updateDelay () const
 updateDelay This is interval "how many msec bot will be wait for sent next request of updates" By defaul is 1000 msecs.
 
void setUpdateDelay (int newUpdateDelay)
 setUpdateDelay This method sets new value for the TelegramRestBot::updateDelay property.
 
void setProcessed (const QSet< unsigned long long > &newProcessed) override
 setProcessed This method sets new list of processed mesages.
 
- Public Member Functions inherited from qTbot::ITelegramBot
 ITelegramBot ()
 
 ~ITelegramBot ()
 
bool sendMessage (const QVariant &chatId, const QString &text) override
 sendMessage This method sents text to the selected chat.
 
bool sendLocationRequest (const QVariant &chatId, const QString &text, const QString &buttonText, bool onetimeKeyboard)
 sendLocationRequest This method setn into chat button that will automaticaly sent geo location to bot.
 
bool sendSelfContactRequest (const QVariant &chatId, const QString &text, const QString &buttonText, bool onetimeKeyboard)
 sendSelfContactRequest This method sent into chat button that will automaticaly sent self contact information to bot.
 
bool sendSpecificMessage (const TelegramArgs &args, const qTbot::ExtraJsonObjects &extraObjects={})
 Sends a specific message to a chat.
 
bool sendSpecificMessageWithKeyboard (const TelegramArgs &args, const KeyboardOnMessage &keyboard)
 Sends a specific message with a custom keyboard to a chat. This function sends a specific message to a chat with a custom keyboard. The message can contain text and additional settings to customize its behavior.
 
bool sendSpecificMessageWithKeyboard (const TelegramArgs &args, const QList< QList< QString > > &keyboard, bool onTimeKeyboard=false, bool autoResizeKeyboard=true)
 Sends a specific message with a custom keyboard to a chat.
 
bool deleteMessage (const QVariant &chatId, const QVariant &messageId) override
 deleteMessage This is main method to delete messages.
 
bool editSpecificMessageWithKeyboard (const QVariant &messageId, const TelegramArgs &args, const QList< QList< QString > > &keyboard={}, bool onTimeKeyboard=false, bool autoResizeKeyboard=false)
 Edits a specific message with a custom keyboard in a chat.
 
bool editSpecificMessageWithKeyboard (const QVariant &messageId, const TelegramArgs &args, const KeyboardOnMessage &keyboard={})
 Edits a specific message with a custom keyboard in a chat.
 
bool editMessageKeyboard (const QVariant &messageId, const QVariant &chatId, const KeyboardOnMessage &keyboard={}, const QString &callBackQueryId="")
 Edits a keyboard of message in a chat.
 
bool editSpecificMessage (const QVariant &messageId, const TelegramArgs &args)
 Edits a specific message in a chat.
 
QSharedPointer< iFilegetFile (const QString &fileId, iFile::Type fileType=iFile::Type::Ram) override
 Get a file by its ID.
 
QSharedPointer< QNetworkReplygetFileMeta (const QString &fileId, const QWeakPointer< iFile > &receiver={nullptr})
 getFileMeta This method receive meta information of the file.
 
bool sendFile (const QFileInfo &file, const QVariant &chatId) override
 send file .
 
bool sendFile (const QByteArray &file, const QString &fileName, const QVariant &chatId) override
 sendFile This method setns a file that saved as a bytearray.
 
bool sendFileMessage (const TelegramArgs &args, const QFileInfo &file)
 sendFileMessage This method sents a message with file.
 
bool sendFileMessage (const TelegramArgs &args, const QByteArray &file, const QString &fileName)
 sendFileMessage This method sents a message with file.
 
bool sendPhoto (const TelegramArgs &args, const QFileInfo &photo, const KeyboardOnMessage &keyboard={})
 sendPhoto This method will send image into chat with chatId
 
bool sendPhoto (const TelegramArgs &args, const QByteArray &photo, const QString &fileName, const KeyboardOnMessage &keyboard={})
 sendPhoto This method will send image into chat with chatId
 
bool sendFileById (const QString &fileID, const QVariant &chatId)
 sendFileById This is specific method of the telegram bot. sents file by id.
 
bool sendLocation (const TelegramArgs &args, float latitude, float longitude, const KeyboardOnMessage &keyboard={})
 sendLocation This method sents locatin to user.
 
bool sendContact (const TelegramArgs &args, const QString &phone, const QString &firstName, const QString &secondName="")
 sendContact This method sents a contact data.
 
unsigned long long id () const
 id This method return bots id number.
 
const QStringusername () const
 username This is bots login
 
int gelLastMessageId (unsigned long long &chatId) const
 gelLastMessageId this method returns last sendet message id.
 
- Public Member Functions inherited from qTbot::IBot
 IBot ()
 
 ~IBot ()
 
const QByteArraytoken () const
 token This is token value for authication on the remote server (bot)
 
const QStringname () const
 name This is name of the bot. usualy it fields will be received from the server after autication.
 
void setName (const QString &newName)
 setName This method sets new value for the IBot::name field.
 
QSharedPointer< iUpdatetakeNextUnreadUpdate ()
 takeNextUnreadUpdate This method take a unread update and mark them as read.
 
QSet< unsigned long longprocessed () const
 processed This method return list of processed mesages.
 

Additional Inherited Members

- Signals inherited from qTbot::IBot
void sigReceiveUpdate (const QSharedPointer< iUpdate > &)
 sigReceiveUpdate emit when but receive any updates from users.
 
void sigStopRequire ()
 sigStopRequire just custm event for stop bot if tou use services.
 
- Protected Member Functions inherited from qTbot::ITelegramBot
void setId (unsigned long long newId)
 setId This method sets new value for the ITelegramBot::id property.
 
void setUsername (const QString &newUsername)
 setUsername This method sets new value for the ITelegramBot::username property.
 
QString makeUrl (const QSharedPointer< iRequest > &request) const override
 makeUrl This method prepare a prefix url for http requests.
 
int getFileSizeByUniqueId (const QString &id) const
 getFileSizeByUniqueId This method return size of the file by id
 
QSharedPointer< TelegramFilegetFileInfoByUniqueId (const QString &id) const
 getFileInfoByUniqueId return a local saved meta information about the file.
 
virtual void onRequestError (const QSharedPointer< TelegramUpdateAnswer > &ansverWithError) const
 onRequestError This method invokent when telegram server sent error responce. Default implementation just print error message on the console.
 
void handleIncomeNewUpdate (const QSharedPointer< iUpdate > &) override
 handleIncomeNewUpdate This method just emit the sigReceiveUpdate signal.
 
virtual bool sendMessageRequest (const QSharedPointer< iRequest > &rquest, const std::function< void(int msgId)> &msgIdCB={})
 sendMessageRequest This method invoke when bot will be sent eny messages into chat.
 
- Protected Member Functions inherited from qTbot::IBot
QSharedPointer< QNetworkReplysendRequest (const QSharedPointer< iRequest > &rquest)
 sendRequest This method sent custom requests to the server.
 
void setToken (const QByteArray &newToken)
 setToken This is setter of the IBot::token value.
 
void incomeNewUpdate (const QSharedPointer< iUpdate > &message)
 incomeNewUpdate This method save incomed messages into store.
 
void markUpdateAsProcessed (const QSharedPointer< iUpdate > &message)
 markMessageAsProcessed This method remove message from the not processed messages store.
 
void markUpdateAsUnprocessed (const QSharedPointer< iUpdate > &message)
 markMessageAsUnprocessed This method add the message into a not processed messages store.
 
void markUpdateAsUnprocessed (unsigned long long messageID)
 markMessageAsUnprocessed This method add the message into a not processed messages store.
 
virtual QString defaultFileStorageLocation () const
 defaultFileStorageLocation This method return default file storage location.
 
- Static Protected Member Functions inherited from qTbot::IBot
template<class MessageType , class ... Args>
static QSharedPointer< MessageType > makeMesasge (const QByteArray &data, Args &&...args)
 makeMesasge This is factory method tha can create a messages types.
 
template<class MessageType , class ... Args>
static QSharedPointer< MessageType > makeMesasge (const QJsonObject &data, Args &&...args)
 makeMesasge This is factory method tha can create a messages types.
 

Detailed Description

The TelegramRestBot class Is Rest implementation base on the Update API telegram method.

Definition at line 21 of file telegramrestbot.h.

Inheritance diagram for qTbot::TelegramRestBot:
Inheritance graph
Collaboration diagram for qTbot::TelegramRestBot:
Collaboration graph

Constructor & Destructor Documentation

◆ TelegramRestBot()

qTbot::TelegramRestBot::TelegramRestBot ( )

Definition at line 20 of file telegramrestbot.cpp.

◆ ~TelegramRestBot()

qTbot::TelegramRestBot::~TelegramRestBot ( )

Definition at line 23 of file telegramrestbot.cpp.

Member Function Documentation

◆ login()

bool qTbot::TelegramRestBot::login ( const QByteArray token)
overridevirtual

login This method get bae information of the bot from remote server.

Parameters
tokenThis is token value for login
Returns
true if login request sent successful else false.

Reimplemented from qTbot::ITelegramBot.

Definition at line 26 of file telegramrestbot.cpp.

Here is the call graph for this function:

◆ logout()

void qTbot::TelegramRestBot::logout ( )
overridevirtual

login This method remove login token of bot.

Reimplemented from qTbot::IBot.

Definition at line 39 of file telegramrestbot.cpp.

Here is the call graph for this function:

◆ setProcessed()

void qTbot::TelegramRestBot::setProcessed ( const QSet< unsigned long long > &  newProcessed)
overridevirtual

setProcessed This method sets new list of processed mesages.

Parameters
newProcessedlist of processed messagees.

Reimplemented from qTbot::IBot.

Definition at line 76 of file telegramrestbot.cpp.

Here is the call graph for this function:

◆ setUpdateDelay()

void qTbot::TelegramRestBot::setUpdateDelay ( int  newUpdateDelay)

setUpdateDelay This method sets new value for the TelegramRestBot::updateDelay property.

Parameters
newUpdateDelayThis is new value of the TelegramRestBot::updateDelay property.

Definition at line 72 of file telegramrestbot.cpp.

Here is the call graph for this function:

◆ updateDelay()

int qTbot::TelegramRestBot::updateDelay ( ) const

updateDelay This is interval "how many msec bot will be wait for sent next request of updates" By defaul is 1000 msecs.

Returns
a delay of update.

Definition at line 68 of file telegramrestbot.cpp.


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