diff --git a/README.md b/README.md index e41d1a0..c130140 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,70 @@ -# CMakeProject -Template repository for cmake project -Fork me and replase qTbot to Name of your new project. +# qTbot +This is Qt library for working with chat bots. -1. Clone this repository -2. Run ./init.sh NewProjectName +At this time This library supports next platforms: +* Telegram (50%) - implemented only processing and sending messages and download files. -# This template supports next build targets: +## Build and Include +* cd yourRepo +* git submodule add https://github.com/QuasarApp/easyssl.git # add the repository of Heart into your repo like submodule +* git submodule update --init --recursive +* Include in your CMakeLists.txt file the main CMakeLists.txt file of Heart library -| Command or make target | Description | -|------|------| -| **make test** | The run tests for a project (dependet of Qt Tests, so you need to add Qt in Cmake using CMAKE_PREFIX_PATH) | -| **make doc** | The generate a documentation for a project (dependet of doxygen) | -| **make deploy** | The generate distribution for a project (dependet of CQtDeployer) | -| **make release** | The prepare Qt Installer framework repository for a project, generate a snap package and APK file for android (dependet of CQtDeployer, snapcraft, AndroidDeployer). | + ```cmake + add_subdirectory(easyssl) + ``` + +* link the Heart library to your target + ```cmake + target_link_libraries(yourLib PUBLIC easyssl) + ``` +* rebuild yuor project + + +## Using + +``` cpp + +#include <qTbot/telegramrestbot.h> +#include <qTbot/messages/telegrammsg.h> +#include <qTbot/messages/telegramupdate.h> + +int main(int argc, char *argv[]) { + + QCoreApplication app(argc, argv); + + qTbot::TelegramRestBot bot; + + QObject::connect(&bot, &qTbot::TelegramRestBot::sigReceiveUpdate, [&bot, &filesStack](auto){ + while(auto&& update = bot.takeNextUnreadUpdate()) { + + if (auto&& tupdate = update.dynamicCast<qTbot::TelegramUpdate>()) { + + if (tupdate->contains(tupdate->MessageUpdate)) { + + if (auto&& tmsg = tupdate->message()) { + if (tmsg->contains(tmsg->Document)) { + bot.getFile(tmsg->documents()->fileId(), qTbot::iFile::Local); + } + + if (tmsg->contains(tmsg->Image)) { + bot.getFile(tmsg->image()->fileId(), qTbot::iFile::Local); + } + + if (tmsg->contains(tmsg->Audio)) { + bot.getFile(tmsg->audio()->fileId(), qTbot::iFile::Local); + } + bot.sendSpecificMessage(tmsg->chatId(), "I see it - я вижу это", tmsg->messageId()); + } + + } + } + } + }); + + bot.login("6349356184:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + + return app.exec(); +} + +``` diff --git a/doxygen.conf.in b/doxygen.conf.in index b9ade0a..302e4ab 100644 --- a/doxygen.conf.in +++ b/doxygen.conf.in @@ -51,7 +51,7 @@ PROJECT_BRIEF = qTbot is base back end library for your c++ Qt projects # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = res/Logo_Web_alpha.png +PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is diff --git a/src/example/deploy/qTbot.json b/src/example/deploy/qTbot.json index 5ebe096..a178b91 100644 --- a/src/example/deploy/qTbot.json +++ b/src/example/deploy/qTbot.json @@ -4,11 +4,11 @@ "src/build/Debug/qTbotEaxample.exe" ], "clear": true, - "binPrefix": "/home/andrei/gitHub/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug", + "binPrefix": "/home/andrei/git/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug", "libDir": [ - "/media/D/builds/qTbot", + "/home/andrei/git/qTbot", "/home/andrei/Qt/6.5.2/gcc_64", - "/home/andrei/gitHub/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug" + "/home/andrei/git/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug" ], "recursiveDepth": "10", "deploySystem": false, @@ -17,11 +17,11 @@ "qif": true, "zip": true, "ignoreEnv": [ - "/media/D/builds/qTbot/Distro" + "/home/andrei/git/qTbot/Distro" ], "extraLib": "crypto", - "targetDir": "/media/D/builds/qTbot/Distro", - "deployVersion": "0.27.79b33b3", + "targetDir": "/home/andrei/git/qTbot/Distro", + "deployVersion": "0.28.fa99f10", } diff --git a/src/qTbot/src/public/qTbot/requests/telegramgetfile.cpp b/src/qTbot/src/private/requests/telegramgetfile.cpp similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramgetfile.cpp rename to src/qTbot/src/private/requests/telegramgetfile.cpp diff --git a/src/qTbot/src/public/qTbot/requests/telegramgetfile.h b/src/qTbot/src/private/requests/telegramgetfile.h similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramgetfile.h rename to src/qTbot/src/private/requests/telegramgetfile.h diff --git a/src/qTbot/src/public/qTbot/requests/telegramgetme.cpp b/src/qTbot/src/private/requests/telegramgetme.cpp similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramgetme.cpp rename to src/qTbot/src/private/requests/telegramgetme.cpp diff --git a/src/qTbot/src/public/qTbot/requests/telegramgetme.h b/src/qTbot/src/private/requests/telegramgetme.h similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramgetme.h rename to src/qTbot/src/private/requests/telegramgetme.h diff --git a/src/qTbot/src/public/qTbot/requests/telegramgetupdate.cpp b/src/qTbot/src/private/requests/telegramgetupdate.cpp similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramgetupdate.cpp rename to src/qTbot/src/private/requests/telegramgetupdate.cpp diff --git a/src/qTbot/src/public/qTbot/requests/telegramgetupdate.h b/src/qTbot/src/private/requests/telegramgetupdate.h similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramgetupdate.h rename to src/qTbot/src/private/requests/telegramgetupdate.h diff --git a/src/qTbot/src/public/qTbot/requests/telegrammdownloadfile.cpp b/src/qTbot/src/private/requests/telegrammdownloadfile.cpp similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegrammdownloadfile.cpp rename to src/qTbot/src/private/requests/telegrammdownloadfile.cpp diff --git a/src/qTbot/src/public/qTbot/requests/telegrammdownloadfile.h b/src/qTbot/src/private/requests/telegrammdownloadfile.h similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegrammdownloadfile.h rename to src/qTbot/src/private/requests/telegrammdownloadfile.h diff --git a/src/qTbot/src/public/qTbot/requests/telegramsendmsg.cpp b/src/qTbot/src/private/requests/telegramsendmsg.cpp similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramsendmsg.cpp rename to src/qTbot/src/private/requests/telegramsendmsg.cpp diff --git a/src/qTbot/src/public/qTbot/requests/telegramsendmsg.h b/src/qTbot/src/private/requests/telegramsendmsg.h similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramsendmsg.h rename to src/qTbot/src/private/requests/telegramsendmsg.h diff --git a/src/qTbot/src/public/qTbot/requests/telegramsinglerquest.cpp b/src/qTbot/src/private/requests/telegramsinglerquest.cpp similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramsinglerquest.cpp rename to src/qTbot/src/private/requests/telegramsinglerquest.cpp diff --git a/src/qTbot/src/public/qTbot/requests/telegramsinglerquest.h b/src/qTbot/src/private/requests/telegramsinglerquest.h similarity index 100% rename from src/qTbot/src/public/qTbot/requests/telegramsinglerquest.h rename to src/qTbot/src/private/requests/telegramsinglerquest.h diff --git a/src/qTbot/src/public/qTbot/global.h b/src/qTbot/src/public/qTbot/global.h index a086172..74c7214 100644 --- a/src/qTbot/src/public/qTbot/global.h +++ b/src/qTbot/src/public/qTbot/global.h @@ -10,7 +10,7 @@ #include <QtCore/qglobal.h> -#define QTBOT_VERSION "0.27.79b33b3" +#define QTBOT_VERSION "0.28.fa99f10" #if defined(QTBOT_LIBRARY) # define QTBOT_EXPORT Q_DECL_EXPORT diff --git a/src/qTbot/src/public/qTbot/itelegrambot.cpp b/src/qTbot/src/public/qTbot/itelegrambot.cpp index 0245e8e..63ba122 100644 --- a/src/qTbot/src/public/qTbot/itelegrambot.cpp +++ b/src/qTbot/src/public/qTbot/itelegrambot.cpp @@ -8,14 +8,14 @@ #include "itelegrambot.h" #include "qTbot/messages/telegramupdateanswer.h" #include "file.h" -#include "qTbot/requests/telegrammdownloadfile.h" +#include "requests/telegrammdownloadfile.h" #include "qdir.h" #include "virtualfile.h" #include <QNetworkAccessManager> -#include <qTbot/requests/telegramgetfile.h> -#include <qTbot/requests/telegramgetme.h> -#include <qTbot/requests/telegramsendmsg.h> +#include <requests/telegramgetfile.h> +#include <requests/telegramgetme.h> +#include <requests/telegramsendmsg.h> #include <QNetworkReply> #include <QSharedPointer> diff --git a/src/qTbot/src/public/qTbot/itelegrambot.h b/src/qTbot/src/public/qTbot/itelegrambot.h index ee0b37f..8431ed4 100644 --- a/src/qTbot/src/public/qTbot/itelegrambot.h +++ b/src/qTbot/src/public/qTbot/itelegrambot.h @@ -11,7 +11,6 @@ #define ITELEGRAMBOT_H #include "ibot.h" -#include "qTbot/messages/telegrammsg.h" #include <QObject> class QNetworkAccessManager; diff --git a/src/qTbot/src/public/qTbot/telegramrestbot.cpp b/src/qTbot/src/public/qTbot/telegramrestbot.cpp index 91f15b8..10d8fb9 100644 --- a/src/qTbot/src/public/qTbot/telegramrestbot.cpp +++ b/src/qTbot/src/public/qTbot/telegramrestbot.cpp @@ -8,7 +8,7 @@ #include "telegramrestbot.h" #include "qTbot/messages/telegramupdate.h" #include "qTbot/messages/telegramupdateanswer.h" -#include "qTbot/requests/telegramgetupdate.h" +#include "requests/telegramgetupdate.h" #include <QJsonArray> #include <QTimer>