{"id":16382738,"url":"https://github.com/baderouaich/tgbotxx","last_synced_at":"2026-01-03T16:12:30.347Z","repository":{"id":196250151,"uuid":"694866121","full_name":"baderouaich/tgbotxx","owner":"baderouaich","description":"Telegram Bot C++ Library","archived":false,"fork":false,"pushed_at":"2025-02-01T21:23:38.000Z","size":56315,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T19:52:08.422Z","etag":null,"topics":["cplusplus20","mini-app","mini-apps","telegram","telegram-api-cxx","telegram-bot","telegram-bot-api","telegram-bot-api-json","telegram-bot-framework","telegram-bots","telegram-mini-app","telegram-mini-apps","telegrambot","telegrambotpp","tgbot","tgbot-cpp","tgbotxx"],"latest_commit_sha":null,"homepage":"https://baderouaich.github.io/tgbotxx/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baderouaich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-21T21:26:09.000Z","updated_at":"2025-02-01T21:22:56.000Z","dependencies_parsed_at":"2023-09-23T22:33:57.112Z","dependency_job_id":"7b7d6007-84cf-462d-97b7-3bfe3569ef4a","html_url":"https://github.com/baderouaich/tgbotxx","commit_stats":{"total_commits":437,"total_committers":3,"mean_commits":"145.66666666666666","dds":"0.10068649885583525","last_synced_commit":"f060befad21ccce8c11bfe5c4943bbdcd00be347"},"previous_names":["baderouaich/tgbotxx"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderouaich%2Ftgbotxx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderouaich%2Ftgbotxx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderouaich%2Ftgbotxx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baderouaich%2Ftgbotxx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baderouaich","download_url":"https://codeload.github.com/baderouaich/tgbotxx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244721628,"owners_count":20498984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cplusplus20","mini-app","mini-apps","telegram","telegram-api-cxx","telegram-bot","telegram-bot-api","telegram-bot-api-json","telegram-bot-framework","telegram-bots","telegram-mini-app","telegram-mini-apps","telegrambot","telegrambotpp","tgbot","tgbot-cpp","tgbotxx"],"created_at":"2024-10-11T04:06:13.584Z","updated_at":"2026-01-03T16:12:30.341Z","avatar_url":"https://github.com/baderouaich.png","language":"C++","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"\u003c!--\n\u003e **Warning**\n\u003e\n\u003e this library is still under development.\n\u003e\n ![](https://geps.dev/progress/80) \n--\u003e\n[![MIT License](https://img.shields.io/badge/license-MIT-yellow)](https://github.com/baderouaich/tgbotxx/blob/main/LICENSE)\n[![Docs](https://codedocs.xyz/doxygen/doxygen.svg)](https://baderouaich.github.io/tgbotxx)\n[![Language](https://img.shields.io/badge/C++-20-blue.svg?style=flat\u0026logo=c%2B%2B)](https://img.shields.io/badge/C++-20-blue.svg?style=flat\u0026logo=c%2B%2B)\n\n# tgbotxx\n\nTelegram Bot C++ Library\n\n## Features\n- Compatible with Telegram [Bot API 9.2 (August 15, 2025)](https://core.telegram.org/bots/api-changelog)\n- Simple, Fast and Reliable.\n- Uses [libcpr](https://github.com/libcpr/cpr) for HTTP requests and [nlohmann::json](https://github.com/nlohmann/json) for JSON parsing (Both are exposed to the user by default)\n- Cross Platform (Ubuntu, Windows and macOS)\n- Plenty of [examples](examples/)\n- MIT License\n- C++ 20\n\n\n[//]: # (### Third party libs)\n\n[//]: # (- [nlohmann-json]\u0026#40;https://github.com/nlohmann/json\u0026#41; for JSON parsing)\n\n[//]: # (- [cpr]\u0026#40;https://github.com/libcpr/cpr\u0026#41; for HTTP client)\n\n### CI Status\n\n| Operating system | Build status                                                                                                                                                                                      |\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Ubuntu (x64)     | [![Ubuntu](https://img.shields.io/github/actions/workflow/status/baderouaich/tgbotxx/build-ubuntu.yml?branch=main)](https://github.com/baderouaich/tgbotxx/actions/workflows/build-ubuntu.yml)    |\n| Windows (x64)    | [![Windows](https://img.shields.io/github/actions/workflow/status/baderouaich/tgbotxx/build-windows.yml?branch=main)](https://github.com/baderouaich/tgbotxx/actions/workflows/build-windows.yml) |\n| macOS            | [![macOS](https://img.shields.io/github/actions/workflow/status/baderouaich/tgbotxx/build-macos.yml?branch=main)](https://github.com/baderouaich/tgbotxx/actions/workflows/build-macos.yml)       | \n\n[//]: # (### Usage)\n\n[//]: # ()\n\n[//]: # (This library is using Inheritance-Based Extensibility technique providing a Bot class which you can inherit from)\n\n[//]: # (and optionally override callback events depending on your Bot needs.)\n\n[//]: # ()\n\n[//]: # (This also allows you to instantiate multiple bots in the same program. Just make sure each Bot is running on a separate)\n\n[//]: # (thread. )\n\n#### Basic sample\n\n\u003e see [examples](examples/) for more\n\n```cpp\n#include \u003ctgbotxx/tgbotxx.hpp\u003e\n#include \u003ciostream\u003e\nusing namespace tgbotxx;\n\nclass MyBot final : public Bot {\npublic:\n  MyBot() : Bot(\"Bot token here from @BotFather\") {}\n    \nprivate:\n  // Called before Bot starts receiving updates\n  void onStart() override {\n    // Initialize your code here...\n    std::cout \u003c\u003c \"Bot Started\\n\";\n  }\n  \n  // Called before Bot shuts down (triggered by Bot::stop())\n  void onStop() override {\n    // Cleanup your code here\n    std::cout \u003c\u003c \"Bot Stopped\\n\";\n  }\n  \n  // Called when Bot receives a new message of any kind\n  // NB: Ptr\u003cT\u003e = std::shared_ptr\u003cT\u003e\n  void onAnyMessage(const Ptr\u003cMessage\u003e\u0026 message) override {\n    std::string reply = \"Hi \" + message-\u003efrom-\u003efirstName + \", got your message!\";\n    api()-\u003esendMessage(message-\u003echat-\u003eid, reply);\n  }\n  \n  // override other callbacks if needed... See Bot.hpp\n};\n\nint main() {\n  MyBot bot;\n  bot.start();\n  return 0;\n}\n```\n### Examples\n\n\u003e see [examples](examples/) for more\n\n| Example                                                       | Description                                                                                                                      |                                           Preview                                           |\n|:--------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------:|\n| [WeatherBot](examples/WeatherBot)                             | Bot that displays the weather information of a city using the [weather api](https://www.weatherapi.com/).                        |          \u003cimg src=\"examples/WeatherBot/img/preview.jpg\" alt=\"preview\" width=\"200\"\u003e          |\n| [EarthquakeBot](examples/EarthquakeBot)                       | Bot that will alert you if there is a recent earthquake somewhere in the world.                                                  |         \u003cimg src=\"examples/EarthquakeBot/img/alerts.jpg\" alt=\"preview\" width=\"200\"\u003e         |\n| [QrCodeBot](examples/QrCodeBot)                               | Bot that can generate QrCode images from text and extract text from QrCode Images.                                               |           \u003cimg src=\"examples/QrCodeBot/img/encode.jpg\" alt=\"preview\" width=\"200\"\u003e           |\n| [UrlShortenerBot](examples/UrlShortenerBot)                   | Bot for shortening URLs.                                                                                                         |       \u003cimg src=\"examples/UrlShortenerBot/img/preview.jpg\" alt=\"preview\" width=\"200\"\u003e        |\n| [Inline Buttons](examples/Buttons/InlineKeyboardButton)       | Bot that uses inline keyboard buttons to interact with users.                                                                    | \u003cimg src=\"examples/Buttons/InlineKeyboardButton/img/preview.jpg\" alt=\"preview\" width=\"200\"\u003e |\n| [Keyboard Buttons](examples/Buttons/ReplyKeyboardMarkup)      | Bot that uses keyboard buttons to interact with users.                                                                           | \u003cimg src=\"examples/Buttons/ReplyKeyboardMarkup/img/preview.jpg\" alt=\"preview\" width=\"200\"\u003e  |\n| [PaidSubscriptionBot](examples/PaidSubscriptionBot)           | Bot that offers it's services for a paid subscription.                                                                           |   \u003cimg src=\"examples/PaidSubscriptionBot/photos/checkout2.jpg\" alt=\"preview\" width=\"200\"\u003e   |\n| [ThreadPoolBot](examples/ThreadPoolBot)                       | Bot that uses a ThreadPool to handle multiple requests simultaneously.                                                           |        \u003cimg src=\"examples/ThreadPoolBot/img/preview2.png\" alt=\"preview\" width=\"200\"\u003e        |\n| [GitWatcherBot](https://github.com/baderouaich/GitWatcherBot) | Real world Bot that you can use to watch repositories changes and get notified about (stars, forks, issues, watchers and pulls). |           \u003cimg src=\"https://i.ibb.co/XDXV2PZ/NEW.jpg\" alt=\"preview\" width=\"200\"\u003e            |\n\n\u003c/details\u003e\n\n### Usage (4 approaches)\n\n#### 1. `FetchContent` *(recommended)*\n\nSimply use CMake's `FetchContent` in your project's `CMakeLists.txt` as below:\n\n```cmake\ncmake_minimum_required(VERSION 3.20)\nproject(my_bot)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\ninclude(FetchContent)\nFetchContent_Declare(tgbotxx\n        GIT_REPOSITORY \"https://github.com/baderouaich/tgbotxx\"\n        GIT_TAG \"v1.2.9.2\" # Compatible with Telegram Api 9.2\n        GIT_SHALLOW TRUE\n        GIT_PROGRESS TRUE\n        EXCLUDE_FROM_ALL\n)\nFetchContent_MakeAvailable(tgbotxx)\n\nadd_executable(${PROJECT_NAME} main.cpp)\ntarget_link_libraries(${PROJECT_NAME} PUBLIC tgbotxx)\n```\n\n#### 2. `PkgConfig`: clone and install the library locally, then use PkgConfig:\n\n\u003cdetails\u003e\n  \u003csummary\u003eexample\u003c/summary\u003e\n\n```shell\ngit clone https://github.com/baderouaich/tgbotxx\ncd tgbotxx\ncmake .. -DCMAKE_BUILD_TYPE=Release\nsudo make install \n# On Windows run `make install` as administrator \n```\n\n```cmake\ncmake_minimum_required(VERSION 3.20)\nproject(my_bot)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\nfind_package(PkgConfig REQUIRED)\npkg_check_modules(tgbotxx REQUIRED tgbotxx)\n\nif (NOT tgbotxx_FOUND)\n    message(FATAL_ERROR \"Did you install tgbotxx locally?\")\nendif ()\n\nadd_executable(${PROJECT_NAME} main.cpp)\ntarget_link_directories(${PROJECT_NAME} PUBLIC ${tgbotxx_LIBRARY_DIRS})\ntarget_include_directories(${PROJECT_NAME} PUBLIC ${tgbotxx_INCLUDE_DIRS})\ntarget_compile_options(${PROJECT_NAME} PUBLIC ${tgbotxx_CFLAGS_OTHER})\ntarget_link_libraries(${PROJECT_NAME} PUBLIC ${tgbotxx_LIBRARIES})\n```\n\n\u003c/details\u003e\n\n#### 3. `find_package`: clone and install the library locally, then use find_package(tgbotxx REQUIRED):\n\n\u003cdetails\u003e\n  \u003csummary\u003eexample\u003c/summary\u003e\n\n```cmake\ncmake_minimum_required(VERSION 3.20)\nproject(my_bot)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\nfind_package(tgbotxx REQUIRED)\n\nif (NOT tgbotxx_FOUND)\n    message(FATAL_ERROR \"Did you install tgbotxx locally?\")\nendif ()\n\nadd_executable(${PROJECT_NAME} main.cpp)\ntarget_link_directories(${PROJECT_NAME} PUBLIC ${tgbotxx_LIBRARY_DIRS})\ntarget_include_directories(${PROJECT_NAME} PUBLIC ${tgbotxx_INCLUDE_DIRS})\ntarget_compile_options(${PROJECT_NAME} PUBLIC ${tgbotxx_CFLAGS_OTHER})\ntarget_link_libraries(${PROJECT_NAME} PUBLIC ${tgbotxx_LIBRARIES})\n```\n\n\u003c/details\u003e\n\n#### 4. `Submodule`: Use tgbotxx as a project submodule (without installation)\n\n\u003cdetails\u003e\n  \u003csummary\u003eexample\u003c/summary\u003e\n\nYou can also use this library as a submodule in your bot project without the need of installing it in your system.\nUse git clone or git submodule add the library:\n\n```shell\ngit submodule add https://github.com/baderouaich/tgbotxx ./lib/tgbotxx\n```\n\nor\n\n```shell\ngit clone https://github.com/baderouaich/tgbotxx ./lib/tgbotxx\n```\n\nThen add `add_subdirectory(lib/tgbotxx)` in your `CMakeLists.txt`.\n\n```cmake\ncmake_minimum_required(VERSION 3.20)\nproject(my_bot)\n\nadd_subdirectory(lib/tgbotxx) # \u003c-- clone tgbotxx in your project's lib/ directory\n\nadd_executable(${PROJECT_NAME} main.cpp)\ntarget_link_libraries(${PROJECT_NAME} PUBLIC tgbotxx) # \u003c-- link with tgbotxx\n```\n\n\u003c/details\u003e\n\n### Other actively maintained Telegram Bot C++ Libraries\n\n- [tgbot-cpp](https://github.com/reo7sp/tgbot-cpp): C++ library for Telegram bot API\n- [tgbot](https://github.com/egorpugin/tgbot): C++ library for Telegram Bot API with generated API types and methods\n\n### Refs:\n\n[Telegram Api Documentation](https://core.telegram.org/bots/api)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaderouaich%2Ftgbotxx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaderouaich%2Ftgbotxx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaderouaich%2Ftgbotxx/lists"}