11#include <QCoreApplication>
18int main(
int argc,
char *argv[]) {
20 QCoreApplication::setOrganizationName(
"QuasarApp");
21 QCoreApplication::setOrganizationDomain(
"https://github.com/QuasarApp");
22 QCoreApplication::setApplicationName(
"qTbotExample");
24 QCoreApplication app(argc, argv);
36 if (tupdate->contains(tupdate->MessageUpdate)) {
38 if (
auto&& tmsg = tupdate->message()) {
39 if (tmsg->contains(tmsg->Document)) {
41 qInfo() <<
"file save into " << path;
42 }).onFailed([](
const std::exception& exception){
44 qCritical() <<
"exception :" << exception.what();
48 if (tmsg->contains(tmsg->Image)) {
50 qInfo() <<
"file save into " << path;
51 }).onFailed([](
const std::exception& exception){
53 qCritical() <<
"exception :" << exception.what();
57 if (tmsg->contains(tmsg->Audio)) {
59 qInfo() <<
"file save into " << path;
60 }).onFailed([](
const std::exception& exception){
62 qCritical() <<
"exception :" << exception.what();
66 if (tmsg->text() ==
"spam") {
67 for (
int i = 0 ; i < 1000; i++) {
72 {{{
"test_button", [tmsg, &bot](
const QString& queryId,
const QVariant& msgId){
76 "I see it. Presed count: " + QString::number(index++),
83 {{
"test_button", [](auto , auto ){}},
84 {
"test_button 2", [](auto , auto ){}}}};
94 {
"test_button"},}},
true,
true);
105 if (!bot.
login(
"6349356184:AAFotw9EC46sgAQrkGQ_jeHPyv3EAapZXcM")) {
106 qCritical() <<
"failed to login!";
void sigReceiveUpdate(const QSharedPointer< qTbot::iUpdate > &)
sigReceiveUpdate emitted when the bot receives any updates from users.
@ Local
Local file type. The file will be saved in the internal file storage. This file type can use the file...
void setReqestLimitPerSecond(int newReqestLimitPerSecond)
setReqestLimitPerSecond This method sets a new limitation of the bot performance.
QSharedPointer< iUpdate > takeNextUnreadUpdate()
takeNextUnreadUpdate This method takes an unread update and marks it as read.
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...
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 ...
bool sendMessage(const QVariant &chatId, const QString &text, iRequest::RequestPriority priority=iRequest::NormalPriority) override
sendMessage This method sends text to the selected chat.
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 TelegramRestBot class Is the rest implementation base on the getUpdates (long polling) telegram m...
bool login(const QByteArray &token) override
login This method gets basic information of the bot from the remote server and starts the long pollin...
The TelegramUpdate class contains base information about updates from telegram.
@ LowPriority
LowPriority the request has a low priority.
int main(int argc, char *argv[])
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.