Telegram bot that captures frames from an IP camera via RTSP and sends them to the group when a command is received.
- Python 3.8+
- IP camera with RTSP stream
- Telegram bot configured via @BotFather
git clone <repository-url>
cd IpCameraTelegramBotCopy the example environment file and fill in your values:
cp .env.example .envThen edit .env with your actual credentials:
TELEGRAM_TOKEN=your_bot_token_here # Token from @BotFather
TELEGRAM_GROUP_ID=-1234567890 # ID of the Telegram group (negative number)
ALLOWED_USER_1=111111111 # Telegram user ID allowed to trigger the bot
ALLOWED_USER_2=222222222 # Second allowed user ID
CAMERA_RTSP_URL=rtsp://username:password@192.168.x.x:554/11 # IP camera RTSP stream URLHow to get these values:
- TELEGRAM_TOKEN — Talk to @BotFather on Telegram and create a bot.
- TELEGRAM_GROUP_ID — Add @userinfobot to your group and it will show the group ID.
- ALLOWED_USER_1 / 2 — Forward any message from the user to @userinfobot to get their ID.
- CAMERA_RTSP_URL — Check your camera's manual or admin panel for the RTSP stream URL format.
Note: The
.envfile contains sensitive credentials. It is listed in.gitignoreand must never be committed to the repository.
pip install -r requirements.txtpython watcher.pypython -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python watcher.pyIn the Telegram group, send any text message. The bot will reply with a frame captured from the camera.
Only users listed in ALLOWED_USER_1 and ALLOWED_USER_2 can trigger the bot, but if you want to let more users trigger the bot you'll only need to add their values on the .env and then add them on the ALLOWED_USERS.