Skip to content

Beesonn/MediaSaveBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

63 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 MediaSaveBot

Telegram Bot Go Version License GitHub Stars GitHub Forks

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


✨ Features

πŸ“₯ Multi-Platform Media Downloads

  • πŸ“Έ Instagram - Photos, videos, carousels, reels
  • πŸ“Œ Pinterest - Pins, boards, high-quality images
  • 🎡 Spotify - Tracks, albums, playlists with metadata
  • 🎬 YouTube - Videos, shorts, audio extraction

πŸ€– Smart Bot Features

  • ⚑ 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

πŸ” Advanced Functionality

  • βœ… 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

πŸš€ Quick Start

Prerequisites

  • Go 1.24.0 or higher
  • MongoDB 4.4+ (optional, for user tracking)
  • Telegram Bot Token (create via @BotFather)

Installation

  1. Clone the Repository

    git clone https://github.com/Beesonn/MediaSaveBot.git
    cd MediaSaveBot
  2. Install Dependencies

    go mod download
    go mod tidy
  3. 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"
  4. Run the Bot

    go run main.go

πŸ“‹ Commands

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

🎯 How to Use

Download from Instagram

  1. Send any Instagram link (instagram.com or instagr.am)
  2. Bot automatically detects and downloads
  3. Receive media with captions
Example: https://www.instagram.com/p/ABC123XYZ/

Download from Pinterest

  1. Send Pinterest link (pinterest.com or pin.it)
  2. Instant high-quality image download
  3. Multiple images in one go
Example: https://www.pinterest.com/pin/123456789/

Download Spotify Music

  1. Send Spotify track, album, or playlist link
  2. Bot shows found tracks count
  3. Downloads with artist & title metadata
  4. Handles playlists with batch processing
Example: https://open.spotify.com/track/ABC123XYZ

Admin: Broadcast Messages

  1. Reply to any message with /broadcast
  2. Message sends to all active users
  3. Real-time progress shows
  4. Use πŸ›‘ button to stop

πŸ“‚ Project Structure

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

πŸ”§ Configuration

Environment Variables

# ⚠️ REQUIRED
TOKEN="your-telegram-bot-token"

# Optional but recommended
MONGODB_URI="mongodb://username:password@localhost:27017"
ADMIN="123456789 987654321 111111111"  # Space-separated admin IDs

Setup Steps

  1. Get Telegram Bot Token

    • Chat with @BotFather on Telegram
    • Create new bot with /newbot
    • Copy the token
  2. Setup MongoDB (Optional)

    # Using Docker
    docker run -d -p 27017:27017 --name mongodb mongo:latest
    
    # Connection string: mongodb://localhost:27017
  3. Set Admin IDs

    • Get your Telegram User ID from @userinfobot
    • Add to ADMIN environment variable

πŸ“Š Supported Platforms

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

πŸ—οΈ Architecture

Handler Flow

User sends link
    ↓
/HandleMessage detects platform (regex)
    ↓
Platform-specific handler (Instagram/Pinterest/Spotify)
    ↓
dlkitgo library processes download
    ↓
Send media back to user

Admin Operations

Admin sends /broadcast
    ↓
Database fetches all users
    ↓
Loop through users with batch sending
    ↓
Real-time progress updates
    ↓
User can stop with callback button

Database Schema

// MongoDB - media_save_bot.users
{
  _id: ObjectId(),
  user_id: 123456789,        // Telegram User ID
  name: "John Doe"           // User's first name
}

πŸ” Security Features

βœ… 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


πŸ“¦ Dependencies

// 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

πŸ’» System Requirements

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+)

πŸš€ Deployment

Local Development

go run main.go

Docker Deployment

FROM 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"]

Build & Run

docker build -t mediasavebot .
docker run -e TOKEN="your-token" mediasavebot

πŸ†˜ Troubleshooting

Bot doesn't respond

  • βœ… Check if TOKEN environment variable is set
  • βœ… Verify token is valid from @BotFather
  • βœ… Check internet connection

Download fails

  • βœ… Verify the link format is correct
  • βœ… Ensure media still exists on the platform
  • βœ… Check if bot has sufficient permissions

MongoDB connection error

  • βœ… Verify MONGODB_URI format: mongodb://host:port
  • βœ… Check if MongoDB service is running
  • βœ… Database is optional; bot works without it

Admin commands don't work

  • βœ… Verify your User ID is in ADMIN variable
  • βœ… Make sure ID format is correct (digits only)
  • βœ… Restart bot after changing ADMIN IDs

πŸ“ž Support

Get Help


🀝 Contributing

We welcome contributions! Here's how:

  1. Fork the repository

    git clone https://github.com/YOUR-USERNAME/MediaSaveBot.git
  2. Create feature branch

    git checkout -b feature/amazing-feature
  3. Make your changes

    git add .
    git commit -m "Add amazing feature"
  4. Push to branch

    git push origin feature/amazing-feature
  5. Open Pull Request

    • Describe your changes clearly
    • Link any related issues
    • Include screenshots/examples

πŸ“ License

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...

🌟 Show Your Support

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

Give us a Star! ⭐

https://github.com/Beesonn/MediaSaveBot

πŸ“ˆ Project Statistics

  • Language: Go 100%
  • License: MIT
  • Created: March 2026
  • Last Updated: April 2026
  • Status: Active Development βœ…

πŸ”— Quick Links

Link Purpose
πŸ€– Telegram Bot Try the bot live
πŸ’¬ Support Group Get help & discuss
πŸ“’ Updates Channel Latest updates
πŸ› Issues Report problems
🍴 Fork Contribute code

πŸ“§ Contact


Made with ❀️ by Beesonn

⬆ back to top

About

MediaSaveBot - A powerful Telegram bot for downloading media from Instagram, Pinterest, Spotify, and YouTube. Built with Go and gotgbot.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages