mirror of
https://github.com/QuasarApp/qTbot.git
synced 2025-04-26 05:44:32 +00:00
fix build of library
This commit is contained in:
parent
4479664879
commit
5a874398b5
@ -26,8 +26,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
srand(time(0));
|
||||
|
||||
QList<QSharedPointer<qTbot::iFile> > filesStack;
|
||||
QObject::connect(&bot, &qTbot::TelegramRestBot::sigReceiveUpdate, [&bot, &filesStack](auto){
|
||||
QObject::connect(&bot, &qTbot::TelegramRestBot::sigReceiveUpdate, [&bot](auto){
|
||||
while(auto&& update = bot.takeNextUnreadUpdate()) {
|
||||
|
||||
if (auto&& tupdate = update.dynamicCast<qTbot::TelegramUpdate>()) {
|
||||
@ -36,15 +35,21 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (auto&& tmsg = tupdate->message()) {
|
||||
if (tmsg->contains(tmsg->Document)) {
|
||||
filesStack.push_back(bot.getFile(tmsg->documents()->fileId(), qTbot::iFile::Local));
|
||||
bot.getFile(tmsg->documents()->fileId(), qTbot::ITelegramBot::Local).then([](const QByteArray& path){
|
||||
qInfo() << "fole save into " << path;
|
||||
});
|
||||
}
|
||||
|
||||
if (tmsg->contains(tmsg->Image)) {
|
||||
filesStack.push_back(bot.getFile(tmsg->image()->fileId(), qTbot::iFile::Local));
|
||||
bot.getFile(tmsg->image()->fileId(), qTbot::ITelegramBot::Local).then([](const QByteArray& path){
|
||||
qInfo() << "fole save into " << path;
|
||||
});
|
||||
}
|
||||
|
||||
if (tmsg->contains(tmsg->Audio)) {
|
||||
filesStack.push_back(bot.getFile(tmsg->audio()->fileId(), qTbot::iFile::Local));
|
||||
bot.getFile(tmsg->audio()->fileId(), qTbot::ITelegramBot::Local).then([](const QByteArray& path){
|
||||
qInfo() << "fole save into " << path;
|
||||
});
|
||||
}
|
||||
|
||||
bot.sendSpecificMessageWithKeyboard(qTbot::TelegramArgs{tmsg->chatId(), "I see it", tmsg->messageId()},
|
||||
@ -78,6 +83,9 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
});
|
||||
|
||||
bot.login("6349356184:AAFotw9EC46sgAQrkGQ_jeHPyv3EAapZXcM");
|
||||
if (!bot.login("6349356184:AAFotw9EC46sgAQrkGQ_jeHPyv3EAapZXcM")) {
|
||||
qCritical() << "failed to login!";
|
||||
return 1;
|
||||
}
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ IBot::sendRequest(const QSharedPointer<iRequest> &rquest) {
|
||||
}
|
||||
|
||||
auto&& promise = QSharedPointer<QPromise<QByteArray>>::create();
|
||||
promise->start();
|
||||
|
||||
networkReplay->connect(networkReplay, &QNetworkReply::finished, [promise](){
|
||||
promise->finish();
|
||||
@ -144,6 +145,7 @@ QFuture<QByteArray> IBot::sendRequest(const QSharedPointer<iRequest> &rquest, co
|
||||
}
|
||||
|
||||
auto&& promise = QSharedPointer<QPromise<QByteArray>>::create();
|
||||
promise->start();
|
||||
|
||||
networkReplay->connect(networkReplay, &QNetworkReply::finished, [promise, pathToResult](){
|
||||
|
||||
|
@ -296,7 +296,6 @@ QFuture<QByteArray> ITelegramBot::getFile(const QString &fileId, FileType fileTy
|
||||
if (fileType == FileType::Ram) {
|
||||
QFile localFile(localFilePath);
|
||||
if (localFile.open(QIODevice::ReadOnly)) {
|
||||
QPromise<QByteArray> fileDataResult;
|
||||
fileDataResult.addResult(localFile.readAll());
|
||||
localFile.close();
|
||||
}
|
||||
@ -339,6 +338,8 @@ QFuture<QByteArray> ITelegramBot::getFile(const QString &fileId, FileType fileTy
|
||||
}
|
||||
|
||||
auto longWay = QSharedPointer<QPromise<QByteArray>>::create();
|
||||
longWay->start();
|
||||
|
||||
auto&& future = getFileMeta(fileId);
|
||||
if (!future.isValid()) {
|
||||
return {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user