A Telegram bot that automatically downloads and replies with media content when users share links in messages. Built with TypeScript and powered by yt-dlp and gallery-dl.
Set your bot token:
# Edit docker-compose.yml and replace your Telegram Bot Token in the BOT_TOKEN environment variable
Start the bot:
docker compose up -d
Environment variables in docker-compose.yml:
| Variable | Description | Default |
|---|---|---|
BOT_TOKEN | Telegram Bot API token | Required |
MAX_FILE_SIZE | Maximum file size in bytes | 50000000 (50MB) |
DOWNLOAD_TIMEOUT | Download timeout in seconds | 300 |
RATE_LIMIT | Maximum requests per minute | 10 |
COOLDOWN | Cooldown between requests in seconds | 60 |
TMP_DIR | Temporary directory for downloads | /tmp/tgmr |
SUPPORTED_DOMAINS | Comma-separated list of domains | youtube.com,youtu.be,... |
COOKIES_FILE | Default cookies file (fallback) | '' |
COOKIES_FILE_* | Site-specific cookies (e.g., COOKIES_FILE_YOUTUBE) | '' |
To handle rate limiting and authentication for different platforms, you can configure cookies per site:
Create a cookies directory in your project:
mkdir cookies
Add your cookie files for different sites. You can export cookies from your browser using extensions like "Get cookies.txt" or similar:
cookies/
├── youtube.txt # YouTube cookies
├── instagram.txt # Instagram cookies
├── twitter.txt # Twitter/X cookies
└── default.txt # Default fallback cookies
Configure the cookie files in docker-compose.yml:
environment:
# Default fallback for all sites
- COOKIES_FILE=/cookies/default.txt
# Site-specific cookies
- COOKIES_FILE_YOUTUBE=/cookies/youtube.txt
- COOKIES_FILE_INSTAGRAM=/cookies/instagram.txt
- COOKIES_FILE_TWITTER=/cookies/twitter.txt # Used for both twitter.com and x.com
volumes:
- ./cookies:/cookies # Yt-dlp updates cookies
Special cases:
COOKIES_FILE_YOUTUBE works for both youtube.com and youtu.beCOOKIES_FILE_TWITTER works for both twitter.com and x.comCOOKIES_FILE_SITENAME where SITENAME is the domain without the extensionCOOKIES_FILE serves as a fallback for sites without specific cookie filesNote: Keep your cookie files secure as they contain sensitive authentication data.
/start - Introduction message/help - Usage instructionsyarn install
yarn build
yarn dev
tgmr/
├── src/
│ ├── bot/ # Bot initialization and core logic
│ ├── config/ # Configuration management
│ ├── handlers/ # Message and command handlers
│ ├── services/ # Media download and processing
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Helper functions
└── dist/ # Compiled JavaScript
MIT License
Content type
Image
Digest
sha256:7ed9cb79c…
Size
410.8 MB
Last updated
19 days ago
docker pull realies/tgmr:sha-5f7dd8a