17class QNetworkAccessManager;
22class ITelegramMessage;
32typedef std::function<void(
const QString& buttonKey,
const QVariant& msgID)>
ButtonCB;
83 bool sendLocationRequest(
const QVariant &chatId,
const QString& text,
const QString &buttonText,
bool onetimeKeyboard);
93 bool sendSelfContactRequest(
const QVariant &chatId,
const QString& text,
const QString &buttonText,
bool onetimeKeyboard);
140 const QList<QList<QString> > &keyboard,
141 bool onTimeKeyboard =
false,
142 bool autoResizeKeyboard =
true);
150 bool deleteMessage(
const QVariant& chatId,
const QVariant& messageId)
override;
169 const QList<QList<QString> > &keyboard = {},
170 bool onTimeKeyboard =
false,
171 bool autoResizeKeyboard =
false);
209 const QVariant &chatId,
211 const QString &callBackQueryId =
"");
241 QFuture<QByteArray>
getFileMeta(
const QString& fileId);
243 bool sendFile(
const QFileInfo& file,
const QVariant& chatId)
override;
245 bool sendFile(
const QByteArray& file,
const QString& fileName,
const QVariant& chatId)
override;
273 const QFileInfo& photo,
286 const QByteArray& photo,
287 const QString& fileName,
296 bool sendFileById(
const QString& fileID,
const QVariant& chatId);
321 const QString& phone,
322 const QString& firstName,
323 const QString& secondName =
"");
370 unsigned long long id()
const;
391 void setId(
unsigned long long newId);
399 QString
makeUrl(
const QSharedPointer<iRequest>& request)
const override;
419 virtual void onRequestError(
const QSharedPointer<TelegramUpdateAnswer>& ansverWithError)
const;
430 const std::function<
void(
int msgId)>& msgIdCB = {});
433 void handleLogin(
const QByteArray &ansver);
434 void handleLoginErr(QNetworkReply::NetworkError err);
435 void handleFileHeader(
const QByteArray &header);
439 QString findFileInlocatStorage(
const QString& fileId)
const;
440 QHash<QString, QSharedPointer<QJsonObject> >
444 const QList<QList<QString> > &keyboard);
446 unsigned long long _id = 0;
448 QMap<QString, std::function<void(
const QString&,
const QVariant&)>> _handleButtons;
450 QHash<unsigned long long, int> _lastMessageId;
452 QHash<QString, QSharedPointer<TelegramFile>> _filesMetaInfo;
FileType
The FileType enum is a list of file types. It defines how a file should be downloaded - as a local ob...
@ Ram
Ram virtual file type. All file data will be saved into a QFuture bytes array.
const QByteArray & token() const
token This is the token value for authentication on the remote server (bot).
IBot()
IBot default constructor. Initializes the network access manager and the request executor.
bool sendFile(const QFileInfo &file, const QVariant &chatId) override
sendFile This method sends the selected file to the chat.
bool sendFileById(const QString &fileID, const QVariant &chatId)
sendFileById This is specific method of the telegram bot. sends a file by id.
int getFileSizeByUniqueId(const QString &id) const
getFileSizeByUniqueId This method return size of the file by id
bool editMessageKeyboard(const QVariant &messageId, const QVariant &chatId, const KeyboardOnMessage &keyboard={}, const QString &callBackQueryId="")
Edits a keyboard of message in a chat.
const QString & username() const
username This is the bot login
void setId(unsigned long long newId)
setId This method sets new value for the ITelegramBot::id property.
int gelLastMessageId(unsigned long long &chatId) const
gelLastMessageId this method returns last sent message id.
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...
QSharedPointer< TelegramFile > getFileInfoByUniqueId(const QString &id) const
getFileInfoByUniqueId return a local saved meta information about the file.
QFuture< QByteArray > getFileMeta(const QString &fileId)
getFileMeta This method receives the meta information of the file.
bool sendFileMessage(const TelegramArgs &args, const QFileInfo &file)
sendFileMessage This method sends a message with a file.
virtual void onRequestError(const QSharedPointer< TelegramUpdateAnswer > &ansverWithError) const
onRequestError This method invoked when the telegram server sends an error response....
bool editSpecificMessage(const QVariant &messageId, const TelegramArgs &args)
Edits a specific message in 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 ...
void handleIncomeNewUpdate(const QSharedPointer< iUpdate > &) override
handleIncomeNewUpdate This method just emits the sigReceiveUpdate signal.
ITelegramBot()
ITelegramBot default constructor.
bool sendLocation(const TelegramArgs &args, float latitude, float longitude, const KeyboardOnMessage &keyboard={})
sendLocation This method sends a location to the user.
unsigned long long id() const
id This method returns the bot id number.
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 loc...
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...
bool sendMessage(const QVariant &chatId, const QString &text, iRequest::RequestPriority priority=iRequest::NormalPriority) override
sendMessage This method sends text to the selected chat.
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.
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.
bool sendContact(const TelegramArgs &args, const QString &phone, const QString &firstName, const QString &secondName="")
sendContact This method sends a contact data.
bool sendPhoto(const TelegramArgs &args, const QFileInfo &photo, const KeyboardOnMessage &keyboard={})
sendPhoto This method will send image into chat with chatId
bool login(const QByteArray &token) override
login This method gets basic information of the bot from the remote server.
bool sendSpecificMessage(const TelegramArgs &args, const qTbot::ExtraJsonObjects &extraObjects={})
Sends a specific message 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.
The TelegramFile class is base class for all files.
The TelegramSendFile class is the base class for uploading files to the server.
The TelegramSingleRquest class Is the base class for all single request commands with arguments.
The TelegramUpdateAnswer class This is a base message from the telegram server after an update reques...
RequestPriority
The RequestPriority enum This is the list of request execution priorities on the client side.
@ NormalPriority
NormalPriority the request has a normal priority. This is the default value.
std::function< void(const QString &buttonKey, const QVariant &msgID)> ButtonCB
ButtonCB callback type for inline keyboard buttons. It is invoked with the button key and the id of t...
QHash< QString, QSharedPointer< QJsonObject > > ExtraJsonObjects
ExtraJsonObjects hash map of the extra objects of the message.
QList< QHash< QString, ButtonCB > > KeyboardOnMessage
KeyboardOnMessage type. A list of rows where each row is a map of button keys to the callback functio...
The TelegramArgs class is the base structure for all telegram message arguments.