Skip to content

DaviNotTheGiantSlayer/IpCameraTelegramBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camera Watcher Bot

Telegram bot that captures frames from an IP camera via RTSP and sends them to the group when a command is received.

Prerequisites

  • Python 3.8+
  • IP camera with RTSP stream
  • Telegram bot configured via @BotFather

Setup

1. Clone the repository

git clone <repository-url>
cd IpCameraTelegramBot

2. Configure credentials

Copy the example environment file and fill in your values:

cp .env.example .env

Then 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 URL

How 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 .env file contains sensitive credentials. It is listed in .gitignore and must never be committed to the repository.

3. Install dependencies

pip install -r requirements.txt

4. Run

python watcher.py

Using a virtual environment

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python watcher.py

Usage

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

About

This is the code for a telegram bot that captures a frame of an ipcamera on command.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages