qTbot 0.89.ee6949a
qTbot is base back end library for your c++ Qt projects.
qTbot::IBot Class Referenceabstract

The IBot class Base interface for all chat-bots objcts. More...

#include <ibot.h>

Signals

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.
 

Public Member Functions

 IBot ()
 
 ~IBot ()
 
virtual bool login (const QByteArray &token)=0
 login This method get bae information of the bot from remote server.
 
virtual void logout ()
 login This method remove login token of bot.
 
virtual bool sendMessage (const QVariant &chatId, const QString &text)=0
 sendMessage This method sents text to the selected chat.
 
virtual bool deleteMessage (const QVariant &chatId, const QVariant &messageId)=0
 deleteMessage This is main method to delete messages.
 
virtual QSharedPointer< iFilegetFile (const QString &fileId, iFile::Type fileType=iFile::Type::Ram)=0
 Get a file by its ID.
 
virtual bool sendFile (const QFileInfo &file, const QVariant &chatId)=0
 send file .
 
virtual bool sendFile (const QByteArray &file, const QString &fileName, const QVariant &chatId)=0
 sendFile This method setns a file that saved as a bytearray.
 
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.
 
virtual void setProcessed (const QSet< unsigned long long > &newProcessed)
 setProcessed This method sets new list of processed mesages.
 

Protected Member Functions

virtual QString makeUrl (const QSharedPointer< iRequest > &request) const =0
 makeUrl This method prepare a prefix url for http requests.
 
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.
 
virtual void handleIncomeNewUpdate (const QSharedPointer< iUpdate > &)
 handleIncomeNewUpdate This method just emit the sigReceiveUpdate signal.
 

Static Protected Member Functions

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 IBot class Base interface for all chat-bots objcts.

Definition at line 34 of file ibot.h.

Inheritance diagram for qTbot::IBot:
Inheritance graph
Collaboration diagram for qTbot::IBot:
Collaboration graph

Constructor & Destructor Documentation

◆ IBot()

qTbot::IBot::IBot ( )

Definition at line 15 of file ibot.cpp.

◆ ~IBot()

qTbot::IBot::~IBot ( )

Definition at line 20 of file ibot.cpp.

Member Function Documentation

◆ defaultFileStorageLocation()

QString qTbot::IBot::defaultFileStorageLocation ( ) const
protectedvirtual

defaultFileStorageLocation This method return default file storage location.

Returns
default file storage.

Definition at line 134 of file ibot.cpp.

Here is the caller graph for this function:

◆ deleteMessage()

virtual bool qTbot::IBot::deleteMessage ( const QVariant chatId,
const QVariant messageId 
)
pure virtual

deleteMessage This is main method to delete messages.

Parameters
chatIdThis is cahat id wher will be removed message.
messageIdThis is removed message id.
Returns
true if request was be prepared successful

Implemented in qTbot::ITelegramBot.

◆ getFile()

virtual QSharedPointer< iFile > qTbot::IBot::getFile ( const QString fileId,
iFile::Type  fileType = iFile::Type::Ram 
)
pure virtual

Get a file by its ID.

This function allows you to retrieve a file by its ID.

Parameters
fileIdThe ID of the file to retrieve.
fileTypeThis is a saving way, by Default will be used a iFile::Type::Ram
Returns
Returns true if the file retrieval operation was successfully initiated and false in case of an error.

Implemented in qTbot::ITelegramBot.

◆ handleIncomeNewUpdate()

void qTbot::IBot::handleIncomeNewUpdate ( const QSharedPointer< iUpdate > &  message)
protectedvirtual

handleIncomeNewUpdate This method just emit the sigReceiveUpdate signal.

Note
you may override this method for filter the sigReceiveUpdate signal or for handling new updates.

Reimplemented in qTbot::ITelegramBot.

Definition at line 138 of file ibot.cpp.

Here is the caller graph for this function:

◆ incomeNewUpdate()

void qTbot::IBot::incomeNewUpdate ( const QSharedPointer< iUpdate > &  message)
protected

incomeNewUpdate This method save incomed messages into store.

Definition at line 36 of file ibot.cpp.

Here is the call graph for this function:

◆ login()

virtual bool qTbot::IBot::login ( const QByteArray token)
pure virtual

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.

Implemented in qTbot::ITelegramBot, and qTbot::TelegramRestBot.

◆ logout()

void qTbot::IBot::logout ( )
virtual

login This method remove login token of bot.

Reimplemented in qTbot::TelegramRestBot.

Definition at line 24 of file ibot.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeMesasge() [1/2]

template<class MessageType , class ... Args>
static QSharedPointer< MessageType > qTbot::IBot::makeMesasge ( const QByteArray &  data,
Args &&...  args 
)
inlinestaticprotected

makeMesasge This is factory method tha can create a messages types.

Parameters
dataThis is a raw data of the ansver.
argsThis is list of arguments of the message.
Returns
message object.

Definition at line 145 of file ibot.h.

Here is the caller graph for this function:

◆ makeMesasge() [2/2]

template<class MessageType , class ... Args>
static QSharedPointer< MessageType > qTbot::IBot::makeMesasge ( const QJsonObject &  data,
Args &&...  args 
)
inlinestaticprotected

makeMesasge This is factory method tha can create a messages types.

Parameters
dataThis is a raw json data of the ansver.
argsThis is list of arguments of the message.
Returns
message object.

Definition at line 159 of file ibot.h.

◆ makeUrl()

virtual QString qTbot::IBot::makeUrl ( const QSharedPointer< iRequest > &  request) const
protectedpure virtual

makeUrl This method prepare a prefix url for http requests.

Parameters
request- This is request object for that will be prepared url.
Returns
http request prefix

Implemented in qTbot::ITelegramBot.

Here is the caller graph for this function:

◆ markUpdateAsProcessed()

void qTbot::IBot::markUpdateAsProcessed ( const QSharedPointer< iUpdate > &  message)
protected

markMessageAsProcessed This method remove message from the not processed messages store.

Parameters
messageThis is message that need to be processed.

Definition at line 122 of file ibot.cpp.

◆ markUpdateAsUnprocessed() [1/2]

void qTbot::IBot::markUpdateAsUnprocessed ( const QSharedPointer< iUpdate > &  message)
protected

markMessageAsUnprocessed This method add the message into a not processed messages store.

Parameters
messageThis is message that need to be unprocessed.
Note
this may be useful for the process edited old messages. Just call this method bofore IBot::incomeNewMessage.

Definition at line 126 of file ibot.cpp.

◆ markUpdateAsUnprocessed() [2/2]

void qTbot::IBot::markUpdateAsUnprocessed ( unsigned long long  messageID)
protected

markMessageAsUnprocessed This method add the message into a not processed messages store.

Parameters
messageThis is message that need to be unprocessed.
Note
this may be useful for the process edited old messages. Just call this method bofore IBot::incomeNewMessage.

Definition at line 130 of file ibot.cpp.

◆ name()

const QString & qTbot::IBot::name ( ) const

name This is name of the bot. usualy it fields will be received from the server after autication.

Returns
name if the bot.

Definition at line 158 of file ibot.cpp.

◆ processed()

QSet< unsigned long long > qTbot::IBot::processed ( ) const

processed This method return list of processed mesages.

Returns
list of processed messages.

Definition at line 150 of file ibot.cpp.

◆ sendFile() [1/2]

virtual bool qTbot::IBot::sendFile ( const QByteArray file,
const QString fileName,
const QVariant chatId 
)
pure virtual

sendFile This method setns a file that saved as a bytearray.

Parameters
fileThis is file source.
fileNameThis is name of file.
chatIdThis is chat of the receivers.
Returns
true if the file will sent successful.

Implemented in qTbot::ITelegramBot.

◆ sendFile() [2/2]

virtual bool qTbot::IBot::sendFile ( const QFileInfo file,
const QVariant chatId 
)
pure virtual

send file .

Parameters
fileThis is a file that you want to send.
chatIdid of the chat.
Returns
Returns true if the file sents successful.

Implemented in qTbot::ITelegramBot.

◆ sendMessage()

virtual bool qTbot::IBot::sendMessage ( const QVariant chatId,
const QString text 
)
pure virtual

sendMessage This method sents text to the selected chat.

Parameters
chatIdThis is selected chat id
textThis is text that neet to sent.
Returns
true if data sents successful else false.
Note
the specific implementations of this interface can have a different method for sending.

Implemented in qTbot::ITelegramBot.

◆ sendRequest()

QSharedPointer< QNetworkReply > qTbot::IBot::sendRequest ( const QSharedPointer< iRequest > &  rquest)
protected

sendRequest This method sent custom requests to the server.

Parameters
rquestThis is message that will be sent to server.
Returns
shared pointer to the request replay.
Note
The raplay will be removed from local storage only after error or finishing, If you want to save replay just make local copy of the shared pointer.

Definition at line 52 of file ibot.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setName()

void qTbot::IBot::setName ( const QString newName)

setName This method sets new value for the IBot::name field.

Parameters
newNameThis is new value of the IBot::name property

Definition at line 162 of file ibot.cpp.

◆ setProcessed()

void qTbot::IBot::setProcessed ( const QSet< unsigned long long > &  newProcessed)
virtual

setProcessed This method sets new list of processed mesages.

Parameters
newProcessedlist of processed messagees.

Reimplemented in qTbot::TelegramRestBot.

Definition at line 154 of file ibot.cpp.

Here is the caller graph for this function:

◆ setToken()

void qTbot::IBot::setToken ( const QByteArray newToken)
protected

setToken This is setter of the IBot::token value.

Parameters
newTokenThis is new value of the token.

Definition at line 32 of file ibot.cpp.

Here is the caller graph for this function:

◆ sigReceiveUpdate

void qTbot::IBot::sigReceiveUpdate ( const QSharedPointer< iUpdate > &  )
signal

sigReceiveUpdate emit when but receive any updates from users.

Here is the caller graph for this function:

◆ sigStopRequire

void qTbot::IBot::sigStopRequire ( )
signal

sigStopRequire just custm event for stop bot if tou use services.

◆ takeNextUnreadUpdate()

QSharedPointer< iUpdate > qTbot::IBot::takeNextUnreadUpdate ( )

takeNextUnreadUpdate This method take a unread update and mark them as read.

Returns
unread message object. If all messages is readed the return nullptr.

Definition at line 166 of file ibot.cpp.

Here is the caller graph for this function:

◆ token()

const QByteArray & qTbot::IBot::token ( ) const

token This is token value for authication on the remote server (bot)

Returns
auth toke of the bot.

Definition at line 28 of file ibot.cpp.

Here is the caller graph for this function:

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