https://github.com/quasarapp/qtbot
https://github.com/quasarapp/qtbot
bot chatbot qt telegram-bot
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/quasarapp/qtbot
- Owner: QuasarApp
- License: gpl-3.0
- Created: 2023-09-28T15:53:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-02T19:15:27.000Z (6 months ago)
- Last Synced: 2026-01-09T07:49:29.895Z (6 months ago)
- Topics: bot, chatbot, qt, telegram-bot
- Language: C++
- Homepage: https://quasarapp.ddns.net:3031/docs/QuasarApp/qTbot/latest/
- Size: 346 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# qTbot
This is Qt library for working with chat bots.
At this time This library supports next platforms:
* Telegram Rest (80%) - implemented only processing and sending messages and download files.
## Build and Include
* cd yourRepo
* git submodule add https://github.com/QuasarApp/qTbot.git # add the repository of qTbot into your repo like submodule
* git submodule update --init --recursive
* Include in your CMakeLists.txt file the main CMakeLists.txt file of qTbot library
```cmake
add_subdirectory(qTbot)
```
* link the qTbot library to your target
```cmake
target_link_libraries(yourApp PUBLIC qTbot)
```
* rebuild yuor project
## Using
```cpp
#include
#include
#include
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()) {
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();
}
```