Telegram Media Extractor Bot is a Scala 3 application that retrieves media links from Telegram messages and downloads them using browser emulation with Selenium. It then posts the downloaded media to integrations such as Telegram, Twitter, and Mastodon. The bot supports non-complex Twitter posts and experimental Instagram posts, including videos, images, and Reels. Direct links to JPEG and MP4 files are also supported. For private or restricted posts on Instagram and Twitter, authorization via WEB_CLIENT_COOKIES
may be required.
Warning: This bot makes it very easy to quickly download memes and funny pictures from Instagram and Twitter and repost them to your groups. Use responsibly and respect copyright laws!
- JPEG images
- GIFs (stored and downloaded as MP4)
- Videos (MP4)
- Telegram: Posts media to a group or chat using
TELEGRAM_TARGET_BOT_API_KEY
andTELEGRAM_TARGET_CHAT_ID
. - Twitter: Posts media using
TWITTER_API_KEY
,TWITTER_API_SECRET
,TWITTER_ACCESS_TOKEN
, andTWITTER_ACCESS_TOKEN_SECRET
. - Mastodon: Posts media using
MASTODON_INSTANCE_NAME
andMASTODON_ACCESS_TOKEN
.
- Send a media URL to the bot via Telegram (e.g.,
https://x.com/example/status/1234567890
). - The bot validates the user ID against
TELEGRAM_VALID_USERS
. - If valid, the bot uses Selenium to download and upload media to the configured platforms.
- Enhanced edge-case handling for Twitter media
- Instagram integration refinement
- Scala 3 installed
- Selenium WebDriver configured
- API Keys for Telegram, Twitter, and Mastodon
Configure the following variables:
Variable Name | Description |
---|---|
TELEGRAM_BOT_API_KEY |
API key for the Telegram bot |
TELEGRAM_VALID_USERS |
Comma-separated list of allowed user IDs |
TELEGRAM_TARGET_BOT_API_KEY |
(Optional) API key for posting media to a Telegram group |
TELEGRAM_TARGET_CHAT_ID |
(Optional) Target Telegram group chat ID |
WEB_CLIENT_COOKIES |
(Optional) Cookies for authentication (e.g., Instagram, private Twitter posts) |
TWITTER_API_KEY |
(Optional) Twitter API key |
TWITTER_API_SECRET |
(Optional) Twitter API secret |
TWITTER_ACCESS_TOKEN |
(Optional) Twitter access token |
TWITTER_ACCESS_TOKEN_SECRET |
(Optional) Twitter access token secret |
MASTODON_INSTANCE_NAME |
(Optional) Base URL of the Mastodon instance |
MASTODON_ACCESS_TOKEN |
(Optional) Mastodon access token |
- Clone the repository:
git clone [email protected]:UnknownNPC/telegram-media-extractor-bot.git cd telegram-media-extractor-bot
- Configure environment variables in your shell or
.env
file. - Build the project:
sbt compile
Run the bot:
sbt run
- Create a
.env
file with environment variables.TELEGRAM_BOT_API_KEY=your_bot_api_key TELEGRAM_VALID_USERS=user1,user2 TELEGRAM_TARGET_BOT_API_KEY=your_target_bot_api_key TELEGRAM_TARGET_CHAT_ID=your_chat_id WEB_CLIENT_COOKIES="key:value;key1:value1" TWITTER_API_KEY=your_twitter_api_key TWITTER_API_SECRET=your_twitter_api_secret TWITTER_ACCESS_TOKEN=your_twitter_access_token TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret MASTODON_INSTANCE_NAME=mastodon.example.com MASTODON_ACCESS_TOKEN=your_mastodon_access_token
- Run the bot:
docker-compose --env-file .env up
- To run in detached mode:
docker-compose --env-file .env up -d
- Check logs:
docker-compose logs telegram-media-extractor-bot
- Stop the bot:
docker-compose down
- Fork the repository.
- Create a feature branch.
- Submit a pull request with a detailed description of changes.
For issues or feature requests, use the issue tracker.