This small project demonstrates how to create a real world Telegram Bot using C++ and tgbotxx Telegram Bot library with SQLite3 orm database.
It is meant to run for the long term if nothing really bad went wrong, the Bot will restart after system reboot with a cron jobs script and carry on running.
The Bot will handle long polling errors that occur sometimes which can be caused usually by network issues, Telegram server not responding and more. It will also notify an admin when some issue occurs so it can be fixed in a sooner time.
The project also demonstrates how you can implement a middleware like function to handle users requests securely. As well as a thread pool to handle multiple user requests simultaneously.
Finally, it also shows how to use a SQLite3 database to store data safely with multiple threads readers and writers, as well as database backup periodically (every hour).
A Telegram Bot that notifies you when a new change is made in your repositories (issues, pull requests, stars, forks, and watches).
You can add specific repositories to your watch list and get changes notifications.
- Clone the repository
- Acquire a new Bot token from @BotFather and store it in
res/BOT_TOKEN.txt
. - Put your Telegram User ID in
res/ADMIN_USER_ID.txt
to get notifications about issues.if you don't know what is your telegram user id, there are 2 ways to get it:
- Run the bot and send a message to it, then print your id in one of the callbacks such as onAnyMessage(message) { std::cout << message->from->id << std::endl; }
- Open Telegram app. Then, search for “userinfobot”, click Start button and it will prompt the bot to display your user ID
- Build & Run your Bot detached from the console with the build_and_run.sh script
- Congratulations! your Bot is now running in the background. To stop your Bot, run
pkill GitWatcherBot
- Linux OS (Ubuntu recommended)
- cmake 3.20+
- g++-11/clang++-12 and up
- tgbotxx (will be fetched by cmake)
- sqlite3_orm (will be fetched by cmake)
Operating system | Build status |
---|---|
Ubuntu Debug (x64) | |
Ubuntu Release (x64) |