- Open Telegram and search for @BotFather
- Send the command
/newbot - Choose a name for your bot (e.g., "Media Server Bot")
- Choose a username (must end with
bot, e.g.,my_media_server_bot) - Save the token you receive (looks like:
7990136467:AAFFnLkly3EDl_BruaqdbIgjBAmgiYBvupg)
- Go to https://my.telegram.org
- Log in with your phone number
- Click on "API Development Tools"
- Create a new application if you haven't already
- Save your API ID and API Hash
- Create the bot directory:
mkdir -p telegram-media-bot
cd telegram-media-bot- Create necessary files:
telegram_media_bot.py (copy from repository)
requirements.txt:
telethon==1.36.0
cryptg==0.4.0
python-socks[asyncio]==2.4.3
python-dotenv==1.0.0
Dockerfile:
FROM python:3.9-slim
WORKDIR /app
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy bot script
COPY telegram_media_bot.py .
# Create directories
RUN mkdir -p /media/movies /media/tv /media/temp /app/session
# Run bot
CMD ["python", "telegram_media_bot.py"]- Create
.envfile:
# Telegram credentials
TELEGRAM_API_ID=YOUR_API_ID_HERE
TELEGRAM_API_HASH=YOUR_API_HASH_HERE
TELEGRAM_BOT_TOKEN=YOUR_BOT_TOKEN_HERE
# Paths
MOVIES_PATH=/media/movies
TV_PATH=/media/tv
TEMP_PATH=/media/temp
# Authorized users (comma separated, leave empty for admin mode)
AUTHORIZED_USERS=
# Bot settings
MAX_CONCURRENT_DOWNLOADS=3
MIN_FREE_SPACE_GB=5
WARNING_THRESHOLD_GB=10
SPACE_CHECK_INTERVAL=30- For Docker Compose, add to your
docker compose.yml:
telegram-media-bot:
build:
context: ./telegram-media-bot
dockerfile: Dockerfile
container_name: telegram-media-bot
security_opt:
- no-new-privileges:true
environment:
- TELEGRAM_API_ID=${TELEGRAM_API_ID}
- TELEGRAM_API_HASH=${TELEGRAM_API_HASH}
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
- MOVIES_PATH=/media/movies
- TV_PATH=/media/tv
- TEMP_PATH=/media/temp
- AUTHORIZED_USERS=${AUTHORIZED_USERS}
- TZ=${TZ}
- PUID=${PUID}
- PGID=${PGID}
volumes:
- ${MEDIA_PATH}/movies:/media/movies
- ${MEDIA_PATH}/tv:/media/tv
- ./telegram-media-bot/session:/app/session
- ./telegram-media-bot/temp:/media/temp
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.enable=true"docker compose up -d telegram-media-botpip install -r requirements.txt
python telegram_media_bot.py- Open Telegram and search for your bot using the username you chose
- Send
/start - The first user automatically becomes admin
- Note your user ID and add it to
AUTHORIZED_USERSin.envfor permanent access
- Forward a video file from any channel to the bot
- Choose if it's a Movie or TV Show
- For TV Shows without season info, select the season
- Wait for download with progress bar!
-
📁 Smart folder organization
- Movies:
/movies/Movie Name (Year)/file.mp4 - TV Shows:
/tv/Series Name/Season 01/file.mp4
- Movies:
-
🔄 Queue management
- Concurrent download limit
- Automatic queue processing
- Space-aware queue
-
💾 Space monitoring
- Minimum space threshold
- Warning levels
- Automatic space checking
-
👥 Multi-user support
- User whitelist
- Admin privileges
- Per-user download management
- Verify token in
.envfile - Check logs:
docker logs telegram-media-bot
- Verify PUID and PGID in
.envare correct - Check destination folder permissions
- Large files take time
- Speed depends on Telegram servers
- Wait a few minutes for automatic scanning
- Or force a manual scan from your media server dashboard