Skip to content

Latest commit

Β 

History

58 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 auto-filter-bot-v1

A powerful Telegram media search bot β€” search movies and files directly in PM or any group, with paginated results, auto-delete, broadcast, user tracking, and deep-link file delivery.


✨ Features

Feature Description
πŸ’¬ PM Search Type any name β†’ paginated file buttons β†’ tap to receive instantly
πŸ‘₯ Group Search Results shown in group β†’ tap β†’ file delivered to your PM via deep-link
πŸ”— Deep-Link Delivery Group buttons use t.me/bot?start=<file_id> β€” works even if user never started bot
β—€β–Ά Prev / Next Pages Pagination with live page counter β€” only the searcher can press PREV/NEXT
πŸ—‘ Auto-Delete Files auto-delete after configurable time to avoid copyright issues
πŸ“Œ Save Reminder Users instructed to forward to Saved Messages before deletion
πŸ‘€ User Tracking Every /start user is saved to DB; new users trigger a log channel notification
πŸ“’ Broadcast Send any message (text, photo, video, etc.) to all registered users
πŸ“‘ Auto Index New files posted in watched channels saved to DB instantly
πŸ›  Admin Commands Full suite: /index, /setskip, /total, /users, /broadcast, /delete, /channel, /logs
🌐 Inline Mode Search via @bot query in any chat
πŸ”’ Force Subscribe Optionally require users to join a channel before access
🌍 Always Alive Built-in aiohttp web server β€” compatible with Render & Koyeb (no sleep)

πŸ–Ό Preview

Group Search

User: Kumki

Bot:
  πŸ”Ž Results for: Kumki
  πŸ“ Found: 9 file(s)
  πŸ‘‡ Tap a file β†’ you'll be taken to my PM where it will be sent!

  [1.59 GB]- 🎬 -Kumki 2 (2025) Tamil HQ HDRip 1080p HEVC x…
  [1.38 GB]- 🎬 -Kumki 2 (2025) Tamil HQ HDRip 720p x264 (D…
  [904.43 MB]- 🎬 -Kumki 2 (2025) Tamil HQ HDRip 720p HEVC …
  ──────────────────────────────────────────
  [πŸ—‚ 1/2]   [NEXT β–Ά]

File Caption in PM

🎬 Kumki 2 (2025) Tamil HQ HDRip 1080p HEVC x265.mkv
πŸ“¦ Size: 1.59 GB
πŸ—‚ Type: Video

⚠️ This file will be auto-deleted in 5 minute(s) to avoid copyright issues.
πŸ“Œ Forward it to your Saved Messages to keep it forever!

[πŸ’Ύ Save to Saved Messages]

New User Notification in Log Channel

πŸ‘€ New User Started Bot!

πŸ†” ID: 123456789
πŸ“› Name: John Doe
πŸ”— Username: @johndoe
πŸ“… Joined: 12 Mar 2026 β€’ 10:45 UTC

πŸ‘₯ Total Users: 142

Broadcast Progress

πŸ“’ Broadcasting…

[β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘] 40%
Done: 400/1000

βœ… Sent: 385
🚫 Blocked: 12  ← auto-removed from DB
❌ Failed: 3

[β›” Cancel]

πŸš€ Deploy

Heroku

Deploy

  1. Click the button above
  2. Fill in the required environment variables
  3. Deploy β€” uses heroku.yml (container stack) β†’ web: python main.py

Note: Switch your Heroku app to the container stack first:

heroku stack:set container -a <your-app>
git push heroku main

Render / Koyeb

  1. Connect your GitHub repo
  2. Set Start Command: python main.py
  3. Set Health Check URL: /health
  4. Add all environment variables
  5. Deploy β€” the built-in web server keeps the container alive permanently

Manual / VPS

git clone https://github.com/GouthamSER/auto-filter-bot-v1
cd auto-filter-bot-v1
pip install -r requirements.txt
cp sample.env .env
# Edit .env with your values
python main.py

βš™οΈ Environment Variables

Required

Variable Description
API_ID Get from my.telegram.org
API_HASH Get from my.telegram.org
BOT_TOKEN Get from @BotFather
DATABASE_URI MongoDB connection string (e.g. mongodb+srv://...)
ADMINS Space-separated Telegram user IDs β€” e.g. 123456 789012
CHANNELS Space-separated channel IDs the bot watches β€” e.g. -100123 -100456
LOG_CHANNEL Channel ID for bot logs + new user notifications

Optional

Variable Default Description
DATABASE_NAME MediaSearchDB MongoDB database name
COLLECTION_NAME Telegram_files MongoDB collection name
SESSION MediaSearchBot Pyrogram session name
MAX_RESULTS 10 Files shown per page
AUTO_DELETE_TIME 300 Seconds before file is deleted (300 = 5 min)
CACHE_TIME 300 Inline query cache duration in seconds
USE_CAPTION_FILTER false Also search inside file captions
AUTH_CHANNEL β€” Force users to join this channel ID before using bot
URL β€” Your app's public URL for keep-alive pings
PORT 8080 Web server port (auto-set by Render/Koyeb/Heroku)

Custom Messages (Optional)

Variable Description
START_MSG Custom welcome message. Supports {mention}, {username}, {first_name}
FORCE_SUB_MSG Message shown when user hasn't joined AUTH_CHANNEL

πŸ€– Bot Commands

Everyone

Command Description
/start Welcome message + inline search buttons

πŸ’‘ /help and /status are available as inline buttons on the start message β€” not slash commands.

Admins Only

Command Description
/index Bulk-index a channel range (two-step wizard β€” no userbot needed)
/cancelindex Abort the index wizard mid-setup
/setskip <N> Set message-ID offset before indexing (resume from a specific point)
/total Total files saved in database
/users Total registered users count
/broadcast Send a message to all users (reply to any message, or inline text)
/cancelbroadcast Stop a running broadcast mid-way
/channel List all watched/indexed channels
/delete Reply to any media message β†’ removes it from DB
/logs Download the bot log file

Setting Commands via BotFather

Open @BotFather β†’ your bot β†’ Edit Bot β†’ Edit Commands β†’ paste:

start - Start the bot / get welcome message
index - Index a channel range (wizard)
cancelindex - Abort a running index wizard
setskip - Set message-ID offset for indexing
total - Total files in the database
users - Total registered users
broadcast - Broadcast a message to all users
cancelbroadcast - Stop an in-progress broadcast
channel - List watched/indexed channels
delete - Remove a file from the database (reply to it)
logs - Get the bot log file

Or use the included script to set scoped commands automatically (regular users only see /start, admins see the full list):

export BOT_TOKEN=your_token
export ADMINS="123456789 987654321"
python set_commands.py

πŸ“’ Broadcast Usage

Option 1 β€” Copy any message (photo, video, sticker, text…):

Reply to any message with /broadcast

Option 2 β€” Inline text only:

/broadcast πŸŽ‰ New movies added! Go search now!

Bot shows a preview with recipient count and Confirm / Cancel buttons before sending. Live progress updates during send. Blocked/deactivated users are automatically removed from the database.


πŸ” Search Tips

  • Basic: type any movie or file name in PM or any group
  • Filter by type: movie name | video or song name | audio or doc name | document
  • Inline anywhere: @YourBot movie name in any chat
  • Pagination: tap β—€ PREV / NEXT β–Ά to browse all results β€” only the user who searched can press these
  • Group: results appear in the group; tapping a file delivers it to your PM

πŸ“ Project Structure

auto-filter-bot-v1/
β”œβ”€β”€ main.py                 ← Bot entry point + aiohttp web server + keep-alive
β”œβ”€β”€ config.py               ← All configuration via environment variables
β”œβ”€β”€ set_commands.py         ← One-shot script to set BotFather command scopes
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile              ← Docker image (used by Heroku container stack)
β”œβ”€β”€ heroku.yml              ← Heroku container stack config
β”œβ”€β”€ sample.env              ← Example environment variables
β”‚
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── db.py               ← MongoDB motor (Media + Users collections)
β”‚
└── plugins/
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ start.py            ← /start + deep-link file delivery + force-subscribe + help/status buttons
    β”œβ”€β”€ search.py           ← PM & group search, pagination (owner-only), auto-delete
    β”œβ”€β”€ inline.py           ← Inline mode search
    β”œβ”€β”€ channel.py          ← Auto-index new files from watched channels
    β”œβ”€β”€ users.py            ← User tracking + new user log channel notification
    β”œβ”€β”€ broadcast.py        ← /broadcast with live progress + cancel + auto-cleanup
    └── admin.py            ← /index wizard + all other admin commands

πŸ—„ Database Collections

Collection Purpose
Telegram_files All indexed media files (searchable)
users All registered users β€” used for broadcast & analytics

πŸ›  Tech Stack

  • Pyrogram v2 β€” Telegram MTProto client
  • Motor β€” Async MongoDB driver
  • aiohttp β€” Async web server (keep-alive for Render/Koyeb)
  • MongoDB Atlas β€” Cloud database (free tier works)

πŸ‘¨β€πŸ’» Credits

Role Person
Maintainer & Rewritten By GouthamSER
Original Concept Media-Search-bot

πŸ“„ License

This project is licensed under the MIT License.


Made with ❀️ by GouthamSER

About

Auto Filter Bot Telegram Easy to deploy and light weight no other modules added basics only ........

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages