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);
34 if (auto&& tupdate = update.dynamicCast<qTbot::TelegramUpdate>()) {
36 if (tupdate->contains(tupdate->MessageUpdate)) {
38 if (auto&& tmsg = tupdate->message()) {
39 if (tmsg->contains(tmsg->Document)) {
40 bot.getFile(tmsg->documents()->fileId(), qTbot::ITelegramBot::Local).then([](const QByteArray& path){
41 qInfo() <<
"file save into " << path;
42 }).onFailed([](const std::exception& exception){
44 qCritical() <<
"exception :" << exception.what();
48 if (tmsg->contains(tmsg->Image)) {
49 bot.getFile(tmsg->image()->fileId(), qTbot::ITelegramBot::Local).then([](const QByteArray& path){
50 qInfo() <<
"file save into " << path;
51 }).onFailed([](const std::exception& exception){
53 qCritical() <<
"exception :" << exception.what();
57 if (tmsg->contains(tmsg->Audio)) {
58 bot.getFile(tmsg->audio()->fileId(), qTbot::ITelegramBot::Local).then([](const QByteArray& path){
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++) {
68 bot.sendMessage(tmsg->chatId(), QString(
" message N %0").arg(i), qTbot::iRequest::LowPriority);
71 bot.sendSpecificMessageWithKeyboard(qTbot::TelegramArgs{tmsg->chatId(),
"I see it", tmsg->messageId()},
72 {{{
"test_button", [tmsg, &bot](const QString& queryId, const QVariant& msgId){
75 auto&& args = qTbot::TelegramArgs{tmsg->chatId(),
76 "I see it. Presed count: " + QString::number(index++),
82 auto&& keyboard = qTbot::KeyboardOnMessage{
83 {{
"test_button", [](auto , auto ){}},
84 {
"test_button 2", [](auto , auto ){}}}};
86 bot.editSpecificMessageWithKeyboard(msgId,
92 bot.sendSpecificMessageWithKeyboard(qTbot::TelegramArgs{tmsg->chatId(),
"I see it", tmsg->messageId()},
94 {
"test_button"},}}, true, true);
105 if (!bot.login(
"6349356184:AAFotw9EC46sgAQrkGQ_jeHPyv3EAapZXcM")) {
106 qCritical() <<
"failed to login!";
int main(int argc, char *argv[])