|
qTbot 0.2.123.6f57966
qTbot is base back end library for your c++ Qt projects.
|
The TelegramRestBot class Is the rest implementation base on the getUpdates (long polling) telegram method. The bot receives all updates from the telegram server by requesting them periodically. More...
#include <telegramrestbot.h>


Public Member Functions | |
| TelegramRestBot () | |
| TelegramRestBot default constructor. | |
| ~TelegramRestBot () | |
| ~TelegramRestBot destructor. Stops the update polling. | |
| bool | login (const QByteArray &token) override |
| login This method gets basic information of the bot from the remote server and starts the long polling of the updates. | |
| void | logout () override |
| logout This method stops the long polling of the updates and removes the login token of the bot. | |
| int | updateDelay () const |
| updateDelay This is the interval "how many msecs the bot will wait to send the next request for updates". By default it is 1000 msecs. | |
| void | setUpdateDelay (int newUpdateDelay) |
| setUpdateDelay This method sets a new value for the TelegramRestBot::updateDelay property. | |
| void | setProcessed (const QSet< unsigned long long > &newProcessed) override |
| setProcessed This method sets a new list of processed updates. The bot will start to receive the updates from the first not processed update. | |
| Public Member Functions inherited from qTbot::ITelegramBot | |
| ITelegramBot () | |
| ITelegramBot default constructor. | |
| ~ITelegramBot () | |
| ~ITelegramBot destructor. | |
| bool | sendMessage (const QVariant &chatId, const QString &text, iRequest::RequestPriority priority=iRequest::NormalPriority) override |
| sendMessage This method sends text to the selected chat. | |
| bool | sendLocationRequest (const QVariant &chatId, const QString &text, const QString &buttonText, bool onetimeKeyboard) |
| sendLocationRequest This method sends into the chat a button that will automatically send the geo location to the bot. | |
| bool | sendSelfContactRequest (const QVariant &chatId, const QString &text, const QString &buttonText, bool onetimeKeyboard) |
| sendSelfContactRequest This method sends into the chat a button that will automatically send the user contact information to the 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 the 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. | |
| QFuture< QByteArray > | getFile (const QString &fileId, FileType fileType=FileType::Ram) override |
| getFile This method sends a request to get a file by id. The files can be saved into local storage if the type is chosen as Local. | |
| QFuture< QByteArray > | getFileMeta (const QString &fileId) |
| getFileMeta This method receives the meta information of the file. | |
| bool | sendFile (const QFileInfo &file, const QVariant &chatId) override |
| sendFile This method sends the selected file to the chat. | |
| bool | sendFile (const QByteArray &file, const QString &fileName, const QVariant &chatId) override |
| sendFile This method sends a file that is saved as a byte array. | |
| bool | sendFileMessage (const TelegramArgs &args, const QFileInfo &file) |
| sendFileMessage This method sends a message with a file. | |
| bool | sendFileMessage (const TelegramArgs &args, const QByteArray &file, const QString &fileName) |
| sendFileMessage This method sends a message with a 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. sends a file by id. | |
| bool | sendLocation (const TelegramArgs &args, float latitude, float longitude, const KeyboardOnMessage &keyboard={}) |
| sendLocation This method sends a location to the user. | |
| bool | sendContact (const TelegramArgs &args, const QString &phone, const QString &firstName, const QString &secondName="") |
| sendContact This method sends a contact data. | |
| unsigned long long | id () const |
| id This method returns the bot id number. | |
| const QString & | username () const |
| username This is the bot login | |
| int | gelLastMessageId (unsigned long long &chatId) const |
| gelLastMessageId this method returns last sent message id. | |
| Public Member Functions inherited from qTbot::IBot | |
| IBot () | |
| IBot default constructor. Initializes the network access manager and the request executor. | |
| ~IBot () | |
| ~IBot destructor. Cancels pending requests and frees all network resources. | |
| const QByteArray & | token () const |
| token This is the token value for authentication on the remote server (bot). | |
| const QString & | name () const |
| name This is the name of the bot. Usually this field is received from the server after authentication. | |
| void | setName (const QString &newName) |
| setName This method sets new value for the IBot::name field. | |
| QSharedPointer< iUpdate > | takeNextUnreadUpdate () |
| takeNextUnreadUpdate This method takes an unread update and marks it as read. | |
| QSet< unsigned long long > | processed () const |
| processed This method returns the list of processed messages. | |
| int | reqestLimitPerSecond () const |
| reqestLimitPerSecond This is the request performance limitation. By default it is 20 requests per second. | |
| void | setReqestLimitPerSecond (int newReqestLimitPerSecond) |
| setReqestLimitPerSecond This method sets a new limitation of the bot performance. | |
| int | parallelActiveNetworkThreads () const |
| parallelActiveNetworkThreads This method returns the number of parallel active network threads. | |
| void | setParallelActiveNetworkThreads (int newParallelActiveNetworkThreads) |
| setParallelActiveNetworkThreads This method sets the number of parallel active network threads. | |
| unsigned long long | totalSentRequests () const |
| totalSentRequests This is the total count of prepared requests of the bot from the start. | |
| QDateTime | startTime () const |
| startTime This is the time when the bot was started. | |
Additional Inherited Members | |
| Public Types inherited from qTbot::IBot | |
| enum | FileType { Ram , Local } |
| The FileType enum is a list of file types. It defines how a file should be downloaded - as a local object in the file system or into virtual memory. More... | |
| Signals inherited from qTbot::IBot | |
| void | sigReceiveUpdate (const QSharedPointer< qTbot::iUpdate > &) |
| sigReceiveUpdate emitted when the bot receives any updates from users. | |
| void | sigStopRequire () |
| sigStopRequire just a custom event to stop the bot if you 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 prepares a prefix url for http requests. | |
| int | getFileSizeByUniqueId (const QString &id) const |
| getFileSizeByUniqueId This method return size of the file by id | |
| QSharedPointer< TelegramFile > | getFileInfoByUniqueId (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 invoked when the telegram server sends an error response. Default implementation just print error message on the console. | |
| void | handleIncomeNewUpdate (const QSharedPointer< iUpdate > &) override |
| handleIncomeNewUpdate This method just emits 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 sends any messages into the chat. | |
| Protected Member Functions inherited from qTbot::IBot | |
| QFuture< QByteArray > | sendRequest (const QSharedPointer< iRequest > &rquest) |
| sendRequest This method sends a custom request to the server. | |
| QFuture< QByteArray > | sendRequest (const QSharedPointer< iRequest > &rquest, const QString &pathToResult) |
| sendRequest This method sends a custom request to the server. | |
| void | setToken (const QByteArray &newToken) |
| setToken This is the setter of the IBot::token value. | |
| void | incomeNewUpdate (const QSharedPointer< iUpdate > &message) |
| incomeNewUpdate This method saves incoming messages into the store. | |
| void | markUpdateAsProcessed (const QSharedPointer< iUpdate > &message) |
| markMessageAsProcessed This method removes the message from the not processed messages store. | |
| void | markUpdateAsUnprocessed (const QSharedPointer< iUpdate > &message) |
| markMessageAsUnprocessed This method adds the message into the not processed messages store. | |
| void | markUpdateAsUnprocessed (unsigned long long messageID) |
| markMessageAsUnprocessed This method adds the message into the not processed messages store. | |
| virtual QString | defaultFileStorageLocation () const |
| defaultFileStorageLocation This method returns the 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 a factory method that can create a message type from raw byte data. | |
| template<class MessageType, class ... Args> | |
| static QSharedPointer< MessageType > | makeMesasge (const QJsonObject &data, Args &&...args) |
| makeMesasge This is a factory method that can create a message type from raw json data. | |
The TelegramRestBot class Is the rest implementation base on the getUpdates (long polling) telegram method. The bot receives all updates from the telegram server by requesting them periodically.
Definition at line 22 of file telegramrestbot.h.
| qTbot::TelegramRestBot::TelegramRestBot | ( | ) |
TelegramRestBot default constructor.
Definition at line 20 of file telegramrestbot.cpp.
| qTbot::TelegramRestBot::~TelegramRestBot | ( | ) |
~TelegramRestBot destructor. Stops the update polling.
Definition at line 23 of file telegramrestbot.cpp.
|
overridevirtual |
login This method gets basic information of the bot from the remote server and starts the long polling of the updates.
| token | This is the token value for login |
Reimplemented from qTbot::ITelegramBot.
Definition at line 26 of file telegramrestbot.cpp.


|
overridevirtual |
logout This method stops the long polling of the updates and removes the login token of the bot.
Reimplemented from qTbot::IBot.
Definition at line 39 of file telegramrestbot.cpp.

|
overridevirtual |
setProcessed This method sets a new list of processed updates. The bot will start to receive the updates from the first not processed update.
| newProcessed | This is the new list of processed updates. |
Reimplemented from qTbot::IBot.
Definition at line 75 of file telegramrestbot.cpp.

| void qTbot::TelegramRestBot::setUpdateDelay | ( | int | newUpdateDelay | ) |
setUpdateDelay This method sets a new value for the TelegramRestBot::updateDelay property.
| newUpdateDelay | This is the new value of the TelegramRestBot::updateDelay property. |
Definition at line 71 of file telegramrestbot.cpp.
| int qTbot::TelegramRestBot::updateDelay | ( | ) | const |
updateDelay This is the interval "how many msecs the bot will wait to send the next request for updates". By default it is 1000 msecs.
Definition at line 67 of file telegramrestbot.cpp.