qTbot 0.2.102.bb22a69
qTbot is base back end library for your c++ Qt projects.
|
The ITelegramBot class This is base implementation of the all telegramm bots. More...
#include <itelegrambot.h>
Public Member Functions | |
ITelegramBot () | |
~ITelegramBot () | |
bool | login (const QByteArray &token) override |
login This method get bae information of the bot from remote server. | |
bool | sendMessage (const QVariant &chatId, const QString &text, iRequest::RequestPriority priority=iRequest::NormalPriority) 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. | |
QFuture< QByteArray > | getFile (const QString &fileId, FileType fileType=FileType::Ram) override |
getFile This method sent request to get a file by id. The files can be saved into local storage if the Type choosed as Local. | |
QFuture< QByteArray > | getFileMeta (const QString &fileId) |
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 QString & | username () 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 () | |
virtual void | logout () |
login This method remove login token of bot. | |
const QByteArray & | token () const |
token This is token value for authication on the remote server (bot) | |
const QString & | name () 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< iUpdate > | takeNextUnreadUpdate () |
takeNextUnreadUpdate This method take a unread update and mark them as read. | |
QSet< unsigned long long > | processed () 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. | |
int | reqestLimitPerSecond () const |
reqestLimitPerSecond this is request performence limitation. by default is 20 requests per second | |
void | setReqestLimitPerSecond (int newReqestLimitPerSecond) |
setReqestLimitPerSecond this method sets new limitation of bot performance. | |
int | parallelActiveNetworkThreads () const |
parallelActiveNetworkThreads | |
void | setParallelActiveNetworkThreads (int newParallelActiveNetworkThreads) |
setParallelActiveNetworkThreads | |
unsigned long long | totalSentRequests () const |
totalSentRequests This is total prepared requests count of bot from the start. | |
QDateTime | startTime () const |
startTime this is time when bol wil started. | |
Protected Member Functions | |
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< 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 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 | |
QFuture< QByteArray > | sendRequest (const QSharedPointer< iRequest > &rquest) |
sendRequest This method sent custom requests to the server. | |
QFuture< QByteArray > | sendRequest (const QSharedPointer< iRequest > &rquest, const QString &pathToResult) |
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. | |
Additional Inherited Members | |
Public Types inherited from qTbot::IBot | |
enum | FileType { Ram , Local } |
The FileType enum is is file types, deffine how we should download a file - as a local object in file system or into virtual memory. More... | |
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. | |
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. | |
The ITelegramBot class This is base implementation of the all telegramm bots.
Definition at line 34 of file itelegrambot.h.
qTbot::ITelegramBot::ITelegramBot | ( | ) |
Definition at line 41 of file itelegrambot.cpp.
qTbot::ITelegramBot::~ITelegramBot | ( | ) |
Definition at line 45 of file itelegrambot.cpp.
|
overridevirtual |
deleteMessage This is main method to delete messages.
chatId | This is cahat id wher will be removed message. |
messageId | This is removed message id. |
Implements qTbot::IBot.
Definition at line 132 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::editMessageKeyboard | ( | const QVariant & | messageId, |
const QVariant & | chatId, | ||
const KeyboardOnMessage & | keyboard = {} , |
||
const QString & | callBackQueryId = "" |
||
) |
Edits a keyboard of message in a chat.
This function allows you to edit a keyboard of specific message.
messageId | The unique identifier of the message to edit. |
chatId | The unique identifier of the chat containing the message. |
keyboard | A list of maps where each map represents a button with a callback function (optional). |
callBackQueryId | The unique identifier for callback queries triggered by the edited message (optional). |
Definition at line 238 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::editSpecificMessage | ( | const QVariant & | messageId, |
const TelegramArgs & | args | ||
) |
Edits a specific message in a chat.
This function allows you to edit a specific message in a chat. You can update the message's text and customize its behavior as needed.
messageId | The unique identifier of the message to edit. |
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
Definition at line 256 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::editSpecificMessageWithKeyboard | ( | const QVariant & | messageId, |
const TelegramArgs & | args, | ||
const KeyboardOnMessage & | keyboard = {} |
||
) |
Edits a specific message with a custom keyboard in a chat.
This function allows you to edit a specific message in a chat with a custom keyboard. You can update the message's text and customize its behavior as needed.
messageId | The unique identifier of the message to edit. |
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
keyboard | A list of maps where each map represents a button with a callback function (optional). |
Definition at line 219 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::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.
This function allows you to edit a specific message in a chat with a custom keyboard. You can update the message's text and customize its behavior as needed.
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
messageId | The unique identifier of the message to edit. |
keyboard | A list of lists containing the new keyboard buttons to display (optional). |
onTimeKeyboard | Set to true to display the keyboard only once (optional). |
autoResizeKeyboard | Set to true to automatically resize the keyboard (optional). |
Definition at line 145 of file itelegrambot.cpp.
gelLastMessageId this method returns last sendet message id.
chatId | chat id, when you want to get last message id. |
Definition at line 640 of file itelegrambot.cpp.
|
overridevirtual |
getFile This method sent request to get a file by id. The files can be saved into local storage if the Type choosed as Local.
fileId | This is Telegram file id. |
fileType | this is type of file. Depends of this argument future will be contains deffrent result if it is Local type then future will contains link to local file path else file source as bytes. |
Implements qTbot::IBot.
Definition at line 291 of file itelegrambot.cpp.
|
protected |
getFileInfoByUniqueId return a local saved meta information about the file.
id | This is id of the file. |
Definition at line 513 of file itelegrambot.cpp.
QFuture< QByteArray > qTbot::ITelegramBot::getFileMeta | ( | const QString & | fileId | ) |
getFileMeta This method receive meta information of the file.
fileId | This is id of the file. |
Definition at line 377 of file itelegrambot.cpp.
getFileSizeByUniqueId This method return size of the file by id
id | This is id of required file. |
Definition at line 505 of file itelegrambot.cpp.
|
overrideprotectedvirtual |
handleIncomeNewUpdate This method just emit the sigReceiveUpdate signal.
Reimplemented from qTbot::IBot.
Definition at line 523 of file itelegrambot.cpp.
id This method return bots id number.
Definition at line 644 of file itelegrambot.cpp.
|
overridevirtual |
login This method get bae information of the bot from remote server.
token | This is token value for login |
Implements qTbot::IBot.
Reimplemented in qTbot::TelegramRestBot.
Definition at line 48 of file itelegrambot.cpp.
|
overrideprotectedvirtual |
makeUrl This method prepare a prefix url for http requests.
request | - This is request object for that will be prepared url. |
Implements qTbot::IBot.
Definition at line 628 of file itelegrambot.cpp.
|
protectedvirtual |
onRequestError This method invokent when telegram server sent error responce. Default implementation just print error message on the console.
ansverWithError | - This is ansver object with error descriptions. and codes errors. |
Definition at line 517 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendContact | ( | const TelegramArgs & | args, |
const QString & | phone, | ||
const QString & | firstName, | ||
const QString & | secondName = "" |
||
) |
sendContact This method sents a contact data.
args | base arguments of message. |
firstName | This is first name of contact. |
phone | This is phone number of contact. |
secondName | This is second name of user. |
Definition at line 492 of file itelegrambot.cpp.
|
overridevirtual |
sendFile This method setns a file that saved as a bytearray.
file | This is file source. |
fileName | This is name of file. |
chatId | This is chat of the receivers. |
Implements qTbot::IBot.
Definition at line 391 of file itelegrambot.cpp.
|
overridevirtual |
send file .
file | This is a file that you want to send. |
chatId | id of the chat. |
Implements qTbot::IBot.
Definition at line 387 of file itelegrambot.cpp.
sendFileById This is specific method of the telegram bot. sents file by id.
fileID | This is file id. |
chatId | chat that should receive a file. |
Definition at line 464 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendFileMessage | ( | const TelegramArgs & | args, |
const QByteArray & | file, | ||
const QString & | fileName | ||
) |
sendFileMessage This method sents a message with file.
file | This is data that will be sents as a file with name fileName. |
fileName | This is name of the file. |
args | This is general arguments of the message, include a chatID. |
Definition at line 408 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendFileMessage | ( | const TelegramArgs & | args, |
const QFileInfo & | file | ||
) |
sendFileMessage This method sents a message with file.
file | This is path to sents file. |
args | This is general arguments of the message, include a chatID. |
Definition at line 395 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendLocation | ( | const TelegramArgs & | args, |
float | latitude, | ||
float | longitude, | ||
const KeyboardOnMessage & | keyboard = {} |
||
) |
sendLocation This method sents locatin to user.
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
latitude | |
longitude | |
keyboard | A list of maps where each map represents a button with a callback function (optional). |
Definition at line 474 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::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.
chatId | |
text | message text |
buttonText | Text on the button |
Definition at line 75 of file itelegrambot.cpp.
|
overridevirtual |
sendMessage This method sents text to the selected chat.
chatId | This is selected chat id |
text | This is text that neet to sent. |
Implements qTbot::IBot.
Definition at line 67 of file itelegrambot.cpp.
|
protectedvirtual |
sendMessageRequest This method invoke when bot will be sent eny messages into chat.
rquest | This is a message request. |
msgIdCB | call back function for the get a sent message id |
Definition at line 539 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendPhoto | ( | const TelegramArgs & | args, |
const QByteArray & | photo, | ||
const QString & | fileName, | ||
const KeyboardOnMessage & | keyboard = {} |
||
) |
sendPhoto This method will send image into chat with chatId
photo | this is photo data. |
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
fileName | This is dispalyed name of photo. |
keyboard | A list of maps where each map represents a button with a callback function (optional). |
Definition at line 439 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendPhoto | ( | const TelegramArgs & | args, |
const QFileInfo & | photo, | ||
const KeyboardOnMessage & | keyboard = {} |
||
) |
sendPhoto This method will send image into chat with chatId
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
photo | this is photo path. |
keyboard | A list of maps where each map represents a button with a callback function (optional). |
Definition at line 423 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::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.
chatId | |
text | message text |
buttonText | Text on the button |
Definition at line 95 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::sendSpecificMessage | ( | const TelegramArgs & | args, |
const qTbot::ExtraJsonObjects & | extraObjects = {} |
||
) |
Sends a specific message to a chat.
This function sends a specific message to a chat. You can include text and additional objects as needed to customize the message's content and behavior.
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
extraObjects | A map containing additional objects associated with the message (optional). |
Definition at line 112 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::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.
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
keyboard | A list of maps where each map represents a button with a callback function. |
Definition at line 127 of file itelegrambot.cpp.
bool qTbot::ITelegramBot::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.
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.
args | - This is structure with general arguments of the tellegram message. Use This structure for sets target and another arguments. |
keyboard | A list of lists containing the keyboard buttons to display. |
onTimeKeyboard | Set to true to display the keyboard only once. |
autoResizeKeyboard | Set to true to automatically resize the keyboard. |
Definition at line 276 of file itelegrambot.cpp.
setId This method sets new value for the ITelegramBot::id property.
newId | this is new value of the ITelegramBot::id property. |
Definition at line 632 of file itelegrambot.cpp.
setUsername This method sets new value for the ITelegramBot::username property.
newUsername | this is new value of the ITelegramBot::username property. |
Definition at line 624 of file itelegrambot.cpp.