A powerful Telegram bot for downloading media from Instagram, Pinterest, Spotify, and YouTube. Built with Go and gotgbot.
π Quick Start β’ β¨ Features β’ π¦ Installation β’ π¬ Support β’ β Star Us
- πΈ Instagram - Photos, videos, carousels, reels
- π Pinterest - Pins, boards, high-quality images
- π΅ Spotify - Tracks, albums, playlists with metadata
- π¬ YouTube - Videos, shorts, audio extraction
- β‘ One-Click Download - Just send a link
- π User Statistics - Track bot usage (Admin only)
- π’ Broadcast Messages - Send to all users with progress tracking
- π Stop Broadcast - Cancel active broadcasts instantly
- πΎ User Database - MongoDB integration for user tracking
- β Admin Authentication - Secure admin commands
- π Retry Mechanism - Handle Telegram flood limits
- π« Duplicate Prevention - Prevent concurrent requests per user
- βοΈ Batch Processing - Download multiple tracks at once
- π Progress Indicators - Real-time download status
- Go 1.24.0 or higher
- MongoDB 4.4+ (optional, for user tracking)
- Telegram Bot Token (create via @BotFather)
-
Clone the Repository
git clone https://github.com/Beesonn/MediaSaveBot.git cd MediaSaveBot -
Install Dependencies
go mod download go mod tidy
-
Set Environment Variables
# Required export TOKEN="your-telegram-bot-token" # Optional (for user tracking) export MONGODB_URI="mongodb://localhost:27017" # Optional (for admin commands - space-separated user IDs) export ADMIN="123456789 987654321"
-
Run the Bot
go run main.go
| Command | Description | Access | Example |
|---|---|---|---|
/start |
Initialize bot & show welcome message | Public | Send /start to the bot |
/stats |
View total active users | Admin | /stats |
/broadcast |
Send message to all users | Admin | Reply to a message with /broadcast |
- Send any Instagram link (instagram.com or instagr.am)
- Bot automatically detects and downloads
- Receive media with captions
Example: https://www.instagram.com/p/ABC123XYZ/
- Send Pinterest link (pinterest.com or pin.it)
- Instant high-quality image download
- Multiple images in one go
Example: https://www.pinterest.com/pin/123456789/
- Send Spotify track, album, or playlist link
- Bot shows found tracks count
- Downloads with artist & title metadata
- Handles playlists with batch processing
Example: https://open.spotify.com/track/ABC123XYZ
- Reply to any message with
/broadcast - Message sends to all active users
- Real-time progress shows
- Use π button to stop
MediaSaveBot/
βββ π main.go # Entry point & bot dispatcher
βββ π go.mod # Go dependencies
βββ π go.sum # Dependency checksums
βββ π LICENSE # MIT License
βββ π README.md # This file
β
βββ π€ bot/
β βββ commands.go # /start, /stats, /broadcast handlers
β βββ admin.go # Admin functions, broadcast logic
β
βββ πΎ database/
β βββ db.go # MongoDB user operations
β
βββ π οΈ utils/
βββ instagram.go # Instagram downloader
βββ pinterest.go # Pinterest downloader
βββ spotify.go # Spotify downloader
# β οΈ REQUIRED
TOKEN="your-telegram-bot-token"
# Optional but recommended
MONGODB_URI="mongodb://username:password@localhost:27017"
ADMIN="123456789 987654321 111111111" # Space-separated admin IDs-
Get Telegram Bot Token
- Chat with @BotFather on Telegram
- Create new bot with
/newbot - Copy the token
-
Setup MongoDB (Optional)
# Using Docker docker run -d -p 27017:27017 --name mongodb mongo:latest # Connection string: mongodb://localhost:27017
-
Set Admin IDs
- Get your Telegram User ID from @userinfobot
- Add to
ADMINenvironment variable
| Platform | Support | Features |
|---|---|---|
| πΈ Instagram | β Full | Photos, Videos, Carousels, Captions |
| π Pinterest | β Full | Images, High Quality, Metadata |
| π΅ Spotify | β Full | Tracks, Albums, Playlists, Audio |
| π¬ YouTube | π Planned | Video & Audio Downloads |
User sends link
β
/HandleMessage detects platform (regex)
β
Platform-specific handler (Instagram/Pinterest/Spotify)
β
dlkitgo library processes download
β
Send media back to user
Admin sends /broadcast
β
Database fetches all users
β
Loop through users with batch sending
β
Real-time progress updates
β
User can stop with callback button
// MongoDB - media_save_bot.users
{
_id: ObjectId(),
user_id: 123456789, // Telegram User ID
name: "John Doe" // User's first name
}β
Admin Authentication - Only whitelisted users can use admin commands
β
Flood Wait Handling - Automatic retry with exponential backoff
β
Rate Limiting - Prevents duplicate concurrent requests per user
β
Error Handling - Graceful degradation with user-friendly messages
β
Input Validation - Regex pattern matching for URLs
// Telegram Bot Framework
github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.34
// Media Download Kit
github.com/Beesonn/dlkitgo v1.2.4
// Database Driver
go.mongodb.org/mongo-driver v1.17.9| Component | Minimum | Recommended |
|---|---|---|
| Go | 1.21.0 | 1.24.0+ |
| RAM | 128 MB | 512 MB |
| Disk | 100 MB | 500 MB |
| Network | 512 kbps | 5 Mbps |
| OS | Linux/macOS/Windows | Linux (Ubuntu 20.04+) |
go run main.goFROM golang:1.24-alpine
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o mediasavebot .
ENV TOKEN=""
ENV MONGODB_URI=""
ENV ADMIN=""
CMD ["./mediasavebot"]docker build -t mediasavebot .
docker run -e TOKEN="your-token" mediasavebot- β
Check if
TOKENenvironment variable is set - β Verify token is valid from @BotFather
- β Check internet connection
- β Verify the link format is correct
- β Ensure media still exists on the platform
- β Check if bot has sufficient permissions
- β
Verify
MONGODB_URIformat:mongodb://host:port - β Check if MongoDB service is running
- β Database is optional; bot works without it
- β
Verify your User ID is in
ADMINvariable - β Make sure ID format is correct (digits only)
- β Restart bot after changing ADMIN IDs
- π¬ Support Group: @XBOTSUPPORTS
- π’ Updates Channel: @BeesonsBots
- π Bug Reports: GitHub Issues
We welcome contributions! Here's how:
-
Fork the repository
git clone https://github.com/YOUR-USERNAME/MediaSaveBot.git
-
Create feature branch
git checkout -b feature/amazing-feature
-
Make your changes
git add . git commit -m "Add amazing feature"
-
Push to branch
git push origin feature/amazing-feature
-
Open Pull Request
- Describe your changes clearly
- Link any related issues
- Include screenshots/examples
This project is licensed under the MIT License - see LICENSE file for details.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions...
If MediaSaveBot helps you, please consider:
- β Star this repository
- π Share with friends
- π Report bugs if you find any
- π‘ Suggest features you'd like
- π€ Contribute to the project
https://github.com/Beesonn/MediaSaveBot
- Language: Go 100%
- License: MIT
- Created: March 2026
- Last Updated: April 2026
- Status: Active Development β
| Link | Purpose |
|---|---|
| π€ Telegram Bot | Try the bot live |
| π¬ Support Group | Get help & discuss |
| π’ Updates Channel | Latest updates |
| π Issues | Report problems |
| π΄ Fork | Contribute code |
- Developer: @Beesonn
- Telegram: @XBOTSUPPORTS