Skip to content

GrandpaAcademy/telegram_file_store_bot

Repository files navigation

Telegram Store Bot

A powerful Telegram bot that allows admins to store and share files with unique links and forced channel membership.

Features

  • 📁 File Storage: Store photos, videos, documents, and audio files
  • 🔗 Unique Share Links: Generate t.me/bot?start=6digit links for each file
  • 🔒 Forced Channel Membership: Users must join specified channels to access content
  • 📝 Custom Captions: Add captions to shared files
  • 🔘 Custom Buttons: Add buttons with URLs to shared files
  • 📊 Statistics: Track file views and user statistics
  • 👥 Admin Management: Multiple admin support
  • 🗃️ JSON Database: Simple file-based storage

Setup

1. Prerequisites

  • Python 3.12 or higher
  • A Telegram bot token from @BotFather

2. Installation

# Clone or download the project
cd store

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

3. Configuration

  1. Edit config.json:
    • Replace YOUR_BOT_TOKEN_HERE with your bot token
    • Add your user ID to admin_ids array
    • Configure forced_channels with your channel details
    • Set your bot_username
{
    "bot_token": "1234567890:ABCdefGHIjklMNOpqrsTUVwxyz",
    "admin_ids": [123456789],
    "forced_channels": [
        {
            "id": "@yourchannel",
            "name": "Your Channel",
            "invite_link": "https://t.me/yourchannel"
        }
    ],
    "bot_username": "your_bot_username"
}

4. Run the Bot

# Activate virtual environment
source venv/bin/activate

# Run the bot
python main.py

Usage

Admin Commands

  • /save -c <caption> -b <button_text> -u <url> - Save file with options (reply to media)
  • /save - Quick save file (reply to media)
  • /list - List your saved files
  • /delete <code> - Delete a file by its 6-digit code
  • /stats - View bot statistics
  • /help - Show help message

Examples

  1. Save a file with caption and button:

    (Reply to a photo/video/document)
    /save -c Welcome to our channel! -b Visit Website -u https://example.com
    
  2. Quick save:

    (Reply to any media)
    /save
    
  3. Delete a file:

    /delete 123456
    

Sharing Files

Files are shared using links in the format:

t.me/your_bot_username?start=123456

Users must join all configured channels before they can access the shared content.

File Structure

store/
├── main.py              # Main bot application
├── config_manager.py    # Configuration management
├── database.py          # JSON database operations
├── channel_checker.py   # Channel membership verification
├── file_handler.py      # File operations and admin commands
├── config.json          # Bot configuration
├── store_data.json      # Database file (auto-created)
├── requirements.txt     # Python dependencies
├── pyproject.toml       # Project configuration
└── README.md           # This file

Security Notes

  • Keep your bot token secure
  • Only add trusted users as admins
  • Regularly backup your store_data.json file
  • Monitor bot usage through the stats command

Troubleshooting

  1. Bot not responding: Check if the bot token is correct
  2. Channel check failing: Ensure the bot is admin in the channels
  3. Files not sending: Files may be deleted from Telegram servers
  4. Permission errors: Verify admin IDs in config.json

License

This project is open source. Feel free to modify and distribute.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published