|
qTbot 0.2.123.6f57966
qTbot is base back end library for your c++ Qt projects.
|
The IBot class Base interface for all chat-bot objects. More...
#include <ibot.h>


Classes | |
| struct | RequestData |
| The RequestData class is a simple wrapper of a request object with the path of the response. If the path of the response is empty, then the response will be saved in RAM. More... | |
Public Types | |
| 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 | |
| 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. | |
Public Member Functions | |
| IBot () | |
| IBot default constructor. Initializes the network access manager and the request executor. | |
| ~IBot () | |
| ~IBot destructor. Cancels pending requests and frees all network resources. | |
| virtual bool | login (const QByteArray &token)=0 |
| login This method gets basic information of the bot from the remote server. | |
| virtual void | logout () |
| logout This method removes the login token of the bot. | |
| virtual bool | sendMessage (const QVariant &chatId, const QString &text, iRequest::RequestPriority priority=iRequest::NormalPriority)=0 |
| sendMessage This method sends text to the selected chat. | |
| virtual bool | deleteMessage (const QVariant &chatId, const QVariant &messageId)=0 |
| deleteMessage This is the main method to delete messages. | |
| virtual QFuture< QByteArray > | getFile (const QString &fileId, FileType fileType=Ram)=0 |
| Get a file by its ID. | |
| virtual bool | sendFile (const QFileInfo &file, const QVariant &chatId)=0 |
| sendFile This method sends the selected file to the chat. | |
| virtual bool | sendFile (const QByteArray &file, const QString &fileName, const QVariant &chatId)=0 |
| sendFile This method sends a file that is saved as a byte array. | |
| 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. | |
| virtual void | setProcessed (const QSet< unsigned long long > &newProcessed) |
| setProcessed This method sets a new 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. | |
Protected Member Functions | |
| virtual QString | makeUrl (const QSharedPointer< iRequest > &request) const =0 |
| makeUrl This method prepares a prefix url for http requests. | |
| 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. | |
| virtual void | handleIncomeNewUpdate (const QSharedPointer< iUpdate > &) |
| handleIncomeNewUpdate This method just emits the sigReceiveUpdate signal. | |
Static Protected Member Functions | |
| 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 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.
| qTbot::IBot::IBot | ( | ) |
| qTbot::IBot::~IBot | ( | ) |
|
protectedvirtual |
|
pure virtual |
deleteMessage This is the main method to delete messages.
| chatId | This is the chat id where the message will be removed. |
| messageId | This is the removed message id. |
Implemented in qTbot::ITelegramBot.
|
pure virtual |
Get a file by its ID.
This function allows you to retrieve a file by its ID.
| fileId | The ID of the file to retrieve. |
| fileType | This is a saving way, by Default will be used a FileType::Ram |
Implemented in qTbot::ITelegramBot.
|
protectedvirtual |
handleIncomeNewUpdate This method just emits the sigReceiveUpdate signal.
Reimplemented in qTbot::ITelegramBot.
Definition at line 207 of file ibot.cpp.


|
protected |
|
pure virtual |
login This method gets basic information of the bot from the remote server.
| token | This is the token value for login |
Implemented in qTbot::ITelegramBot, and qTbot::TelegramRestBot.

|
virtual |
logout This method removes the login token of the bot.
Reimplemented in qTbot::TelegramRestBot.
Definition at line 32 of file ibot.cpp.


|
inlinestaticprotected |
|
inlinestaticprotected |
|
protectedpure virtual |
makeUrl This method prepares a prefix url for http requests.
| request | - This is the request object for which the url will be prepared. |
Implemented in qTbot::ITelegramBot.

|
protected |
|
protected |
markMessageAsUnprocessed This method adds the message into the not processed messages store.
| message | This is the message that needs to be unprocessed. |
Definition at line 195 of file ibot.cpp.


|
protected |
markMessageAsUnprocessed This method adds the message into the not processed messages store.
| messageID | This is the id of the message that needs to be unprocessed. |
| const QString & qTbot::IBot::name | ( | ) | const |
| int qTbot::IBot::parallelActiveNetworkThreads | ( | ) | const |
| QSet< unsigned long long > qTbot::IBot::processed | ( | ) | const |
| int qTbot::IBot::reqestLimitPerSecond | ( | ) | const |
|
pure virtual |
sendFile This method sends a file that is saved as a byte array.
| file | This is the file source data. |
| fileName | This is the name of the file. |
| chatId | This is the chat of the receiver. |
Implemented in qTbot::ITelegramBot.

|
pure virtual |
sendFile This method sends the selected file to the chat.
| file | This is a file that you want to send. |
| chatId | id of the chat. |
Implemented in qTbot::ITelegramBot.
|
pure virtual |
sendMessage This method sends text to the selected chat.
| chatId | This is the selected chat id |
| text | This is the text that needs to be sent. |
| priority | This is the priority of the request in the send queue. |
Implemented in qTbot::ITelegramBot.
|
protected |
|
protected |
sendRequest This method sends a custom request to the server.
| rquest | This is the message that will be sent to the server. |
| pathToResult | This is the path to the file where the received data will be saved. |
| void qTbot::IBot::setName | ( | const QString & | newName | ) |
setName This method sets new value for the IBot::name field.
| newName | This is new value of the IBot::name property |
Definition at line 343 of file ibot.cpp.

| void qTbot::IBot::setParallelActiveNetworkThreads | ( | int | newParallelActiveNetworkThreads | ) |
|
virtual |
setProcessed This method sets a new list of processed messages.
| newProcessed | list of processed messages. |
Reimplemented in qTbot::TelegramRestBot.
Definition at line 335 of file ibot.cpp.

| void qTbot::IBot::setReqestLimitPerSecond | ( | int | newReqestLimitPerSecond | ) |
|
protected |
setToken This is the setter of the IBot::token value.
| newToken | This is the new value of the token. |
Definition at line 40 of file ibot.cpp.

|
signal |
sigReceiveUpdate emitted when the bot receives any updates from users.

|
signal |
sigStopRequire just a custom event to stop the bot if you use services.
| QDateTime qTbot::IBot::startTime | ( | ) | const |
| QSharedPointer< iUpdate > qTbot::IBot::takeNextUnreadUpdate | ( | ) |
| const QByteArray & qTbot::IBot::token | ( | ) | const |
| unsigned long long qTbot::IBot::totalSentRequests | ( | ) | const |