Skip to content

Source code of the GitWatcherBot Telegram Bot - Hourly checks for new stars, forks, watchers, issues and pull requests

License

Notifications You must be signed in to change notification settings

baderouaich/GitWatcherBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License Docs Language

Goal

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).

GitWatcherBot

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.

Demo Image

Run your own version of the Bot

  1. Clone the repository
  2. Acquire a new Bot token from @BotFather and store it in res/BOT_TOKEN.txt.
  3. 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:

    1. 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; }
    2. Open Telegram app. Then, search for “userinfobot”, click Start button and it will prompt the bot to display your user ID
  4. Build & Run your Bot detached from the console with the build_and_run.sh script
  5. Congratulations! your Bot is now running in the background. To stop your Bot, run pkill GitWatcherBot

Requirements

  • 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)

CI Status

Operating system Build status
Ubuntu Debug (x64) Ubuntu
Ubuntu Release (x64) Ubuntu