Skip to main content
TT-Bot uses environment variables for all configuration. Create a .env file in the project root based on .env.example.

Bot Configuration

Core bot settings for Telegram integration.
BOT_TOKEN
string
required
Telegram bot token from @BotFatherExample: 12345:abcde
STATS_BOT_TOKEN
string
required
Token for the statistics botExample: 12345:abcde
TG_SERVER
string
default:"https://api.telegram.org"
Telegram API server URL. Use custom Bot API server if self-hosting.Example: http://telegram-bot-api:8081
TELEGRAM_API_ID
integer
required
Telegram API ID from my.telegram.orgExample: 1234567
TELEGRAM_API_HASH
string
required
Telegram API hash from my.telegram.orgExample: abc123
ADMIN_IDS
array
required
JSON array of Telegram user IDs with admin privilegesExample: [1234567, 7654321]
SECOND_IDS
array
default:"[]"
JSON array of additional user IDs with secondary admin privilegesExample: [1234567]
STORAGE_CHANNEL_ID
integer
Channel ID for uploading videos to get file_id. Enables file caching.Example: 12345

API Configuration

External API settings for third-party integrations.
RAPIDAPI_KEY
string
required
RapidAPI key for Instagram downloads. Get from RapidAPIExample: abcde12345fgh67890ijklmnopqrstu
BOTSTAT
string
API key for bot statistics serviceExample: abcdefg12345
MONETAG_URL
string
Monetag monetization link URLExample: https://example.com/your-monetag-link/

Database Configuration

PostgreSQL connection settings.
DB_URL
string
required
PostgreSQL connection URL. Automatically converted to use asyncpg driver.Format: postgresql://user:password@host:port/databaseExample: postgresql://postgres:postgres@db/ttbot-db

Proxy Configuration

Proxy rotation settings for bypassing rate limits and regional restrictions.
PROXY_FILE
string
Path to file containing proxy URLs (one per line). See Proxy Setup for format.Example: proxies.txt
PROXY_DATA_ONLY
boolean
default:"false"
When true, use proxies only for API requests, not media downloads. Improves download speed.Example: false
PROXY_INCLUDE_HOST
boolean
default:"false"
When true, include direct host connection (no proxy) in round-robin rotation.Example: false

Retry Configuration

Three-part retry strategy with proxy rotation. Each part has independent retry limits.
URL_RESOLVE_MAX_RETRIES
integer
default:"3"
Maximum retries for Part 1: URL resolution (short URLs to full URLs)Example: 3
VIDEO_INFO_MAX_RETRIES
integer
default:"3"
Maximum retries for Part 2: Video info extraction (metadata and video data)Example: 3
DOWNLOAD_MAX_RETRIES
integer
default:"3"
Maximum retries for Part 3: Download (video/images/music download)Example: 3

Performance Configuration

Resource management and optimization settings.
MAX_USER_QUEUE_SIZE
integer
default:"0"
Maximum concurrent videos per user in queue. 0 = no limit.Example: 0
STREAMING_DURATION_THRESHOLD
integer
default:"300"
Use streaming for videos longer than this (seconds). 0 = never stream.Example: 300
MAX_VIDEO_DURATION
integer
default:"0"
Maximum video duration in seconds. 0 = no limit.Example: 0

Logging Configuration

Application logging settings.
LOG_LEVEL
string
default:"INFO"
Logging verbosity level.Options: DEBUG, INFO, WARNING, ERROR, CRITICALExample: INFO

Statistics Configuration

Settings for the statistics bot.
STATS_IDS
array
required
JSON array of user IDs who can access statisticsExample: [-1234567]
STATS_CHAT
string
required
Chat ID where statistics are postedExample: -1234567
STATS_MESSAGE_ID
string
required
Message ID for hourly statistics updatesExample: 23
DAILY_STATS_MESSAGE_ID
string
required
Message ID for daily statistics updatesExample: 24
JOIN_LOGS
string
required
Chat ID for join/leave logsExample: -1234567

Optional Configuration

Additional optional settings.
YTDLP_COOKIES
string
Path to Netscape cookies file for yt-dlp. Used for authenticated requests.Example: cookies.txt

Environment File Example

.env
# Telegram Bot API
TG_SERVER=http://telegram-bot-api:8081
TELEGRAM_API_ID=1234567
TELEGRAM_API_HASH=abc123

# Database
DB_URL=postgresql://postgres:postgres@db/ttbot-db

# Bot tokens
BOT_TOKEN=12345:abcde
STATS_BOT_TOKEN=12345:abcde

# Access control
ADMIN_IDS=[1234567]
STATS_IDS=[-1234567]

# Instagram API
RAPIDAPI_KEY=abcde12345fgh67890ijklmnopqrstu

# Proxy settings
PROXY_FILE=proxies.txt
PROXY_DATA_ONLY=false
PROXY_INCLUDE_HOST=false

# Retry configuration
URL_RESOLVE_MAX_RETRIES=3
VIDEO_INFO_MAX_RETRIES=3
DOWNLOAD_MAX_RETRIES=3

# Performance
MAX_USER_QUEUE_SIZE=0
STREAMING_DURATION_THRESHOLD=300
MAX_VIDEO_DURATION=0

# Logging
LOG_LEVEL=INFO