A utility that monitors files and directories for changes and sends notifications through Telegram when changes are detected.
- Monitor multiple files and directories for changes
- Send real-time notifications via Telegram
- Include file diffs in notifications
- Ignore files based on patterns
- Easy configuration
- Available as a Debian/Ubuntu package or installable via pip
-
Install required build dependencies:
sudo apt update sudo apt install -y build-essential debhelper dh-python python3-pip
-
Build the Debian package:
git clone https://github.com/sicutdeux/file_monitor.git cd file-monitor chmod +x build_deb.sh sudo ./build_deb.sh -
Install the package:
sudo dpkg -i file-monitor-*.deb sudo apt-get install -f # To resolve any dependency issues
-
Install pip and dependencies:
sudo apt update sudo apt install -y python3-pip
-
Install the package:
pip3 install git+https://github.com/sicutdeux/file_monitor.git
If you prefer to install dependencies manually:
sudo apt update
sudo apt install -y python3-pip
sudo pip3 install python-telegram-bot watchdog colorama python-dotenvEdit the configuration file at /etc/file_monitor/file_monitor.conf:
sudo nano /etc/file_monitor/file_monitor.conf-
Create a configuration file in one of these locations:
/etc/file_monitor/file_monitor.conf~/.config/file_monitor/file_monitor.conf./file_monitor.conf(in the current working directory)
-
Use the following template:
[telegram]
# Your Telegram bot token from BotFather
bot_token = YOUR_BOT_TOKEN
# Telegram chat ID where notifications will be sent
chat_id = YOUR_CHAT_ID
[monitor]
# Comma-separated list of paths to monitor (files or directories)
paths = /path/to/file1.txt, /path/to/directory1
# Interval in seconds to check for changes
check_interval = 5
# Comma-separated list of glob patterns to ignore
# Example: *.tmp, *~, .git/*
ignore_patterns = .git/*, *.tmp, *~, __pycache__/*, *.pyc- Create a Telegram bot by talking to @BotFather
- Send a message to your bot
- Get your chat ID by visiting
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
If installed via Debian package or pip:
file-monitorWith a custom configuration file:
file-monitor --config /path/to/your/config.confgit clone https://github.com/sicutdeux/file_monitor.git
cd file-monitor
# Install dependencies
pip install -r requirements.txt
# Run directly
python -m file_monitor.file_monitorgit clone https://github.com/sicutdeux/file_monitor.git
cd file-monitor
# Make sure the scripts are executable
chmod +x bin/file-monitor
chmod +x debian/rules
chmod +x debian/postinst
chmod +x debian/postrm
# Install build dependencies
sudo apt-get update
sudo apt-get install -y debhelper dh-python python3-all python3-setuptools
# Build the package
dpkg-buildpackage -us -uc -b
# Install the package
sudo dpkg -i ../file-monitor_*.deb
sudo apt-get install -f # Fix dependencies if neededIf you encounter dependency issues, run:
sudo apt-get update
sudo apt-get install -fEnsure the configuration file has the correct permissions:
sudo chmod 640 /etc/file_monitor/file_monitor.conf
sudo chown root:root /etc/file_monitor/file_monitor.confMIT License