Skip to content

Commit

Permalink
Kurukkan
Browse files Browse the repository at this point in the history
* Index command to index all the files in a given channel (No USER_SESSION Required).
* Ability to Index Public Channels without being admin.
* Support Auto-Filter (Both in PM and in Groups)
* Added Force subscribe
  • Loading branch information
subinps committed Jul 17, 2021
1 parent c4ea628 commit 2aaddb4
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 187 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# [Media Search bot](https://github.com/Mahesh0253/Media-Search-bot)
# Modified Version Of [Media Search bot](https://github.com/Mahesh0253/Media-Search-bot)

* Index channel or group files for inline search.
* When you post file on telegram channel or group this bot will save that file in database, so you can search easily in inline mode.
* Supports document, video and audio file formats with caption support.
## Added Features
* Index command to index all the files in a given channel (No USER_SESSION Required).
* Ability to Index Public Channels without being admin.
* Support Auto-Filter (Both in PM and in Groups)
* Once files saved in Database , exists until you manually deletes. (No Worry if post gets deleted from source channel.)
* Added Force subscribe (Only channel subscribes can use the bot)

## Installation

### Watch this video to create bot - https://youtu.be/dsuTn4qV2GA
### Easy Way
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)


[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/subinps/Media-Search-bot)
### Hard Way

```bash
Expand Down Expand Up @@ -47,8 +47,7 @@ Check [`sample_info.py`](sample_info.py) before editing [`info.py`](info.py) fil
* `AUTH_USERS`: Username or ID of users to give access of inline search. Separate multiple users by space. Leave it empty if you don't want to restrict bot usage.
* `AUTH_CHANNEL`: Username or ID of channel. Without subscribing this channel users cannot use bot.
* `START_MSG`: Welcome message for start command.
* `INVITE_MSG`: Auth channel invitation message.
* `USERBOT_STRING_SESSION`: User bot string session.


## Admin commands
```
Expand All @@ -60,17 +59,20 @@ logger - Get log file
```

## Tips
* Use `index` command or run [one_time_indexer.py](one_time_indexer.py) file to save old files in the database that are not indexed yet.
* You can use `|` to separate query and file type while searching for specific type of file. For example: `Avengers | video`
* If you don't want to create a channel or group, use your chat ID / username as the channel ID. When you send a file to a bot, it will be saved in the database.

## Contributions
Contributions are welcome.

## Thanks to [Pyrogram](https://github.com/pyrogram/pyrogram)

## Thanks to
* [Pyrogram](https://github.com/pyrogram/pyrogram)
* Original [Repo](https://github.com/Mahesh0253/Media-Search-bot)


## Support
[Update Channel](https://t.me/botxupdates) and [Support Group](https://t.me/botxsupport)
Contact Me On [Telegram](https://t.me/subinps_bot)

[Update Channel](https://t.me/subin_works)

## License
Code released under [The GNU General Public License](LICENSE).
20 changes: 6 additions & 14 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "Media Search bot",
"description": "When you going to send file on telegram channel/group this bot will save that in database, So you can search that easily in inline mode",
"description": "When you going to send file on telegram channel this bot will save that in database, So you can search that easily in inline mode",
"keywords": [
"telegram",
"auto-filter",
"filter",
"best",
"indian",
"pyrogram",
Expand All @@ -12,18 +14,13 @@
"index",
"inline"
],
"website": "https://github.com/Mahesh0253/Media-Search-bot",
"repository": "https://github.com/Mahesh0253/Media-Search-bot",
"website": "https://github.com/subinps/Media-Search-bot",
"repository": "https://github.com/subinps/Media-Search-bot",
"env": {
"BOT_TOKEN": {
"description": "Your bot token.",
"value": ""
},
"USERBOT_STRING_SESSION": {
"description": "User bot string session.",
"value": "",
"required": false
},
"API_ID": {
"description": "Get this value from https://my.telegram.org",
"value": ""
Expand Down Expand Up @@ -52,12 +49,7 @@
},
"START_MSG": {
"description": "Welcome message for start command",
"value": "**Hi, I'm Media Search bot**\n\nHere you can search files in inline mode. Just press following buttons and start searching.",
"required": false
},
"INVITE_MSG": {
"description": "Auth channel invitation message",
"value": "Please join @.... to use this bot",
"value": "**Hi, I'm Media Search Bot or ypu can call me as Auto-Filter Bot**\n\nHere you can search files in Inline mode as well as PM, Use the below buttons to search files or send me the name of file to search.",
"required": false
},
"USE_CAPTION_FILTER": {
Expand Down
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyrogram.raw.all import layer
from utils import Media
from info import SESSION, API_ID, API_HASH, BOT_TOKEN

import pyromod.listen

class Bot(Client):

Expand Down
10 changes: 3 additions & 7 deletions info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

# Bot information
SESSION = environ.get('SESSION', 'Media_search')
USER_SESSION = environ.get('USER_SESSION', 'User_Bot')
API_ID = int(environ['API_ID'])
API_HASH = environ['API_HASH']
BOT_TOKEN = environ['BOT_TOKEN']
USERBOT_STRING_SESSION = environ.get('USERBOT_STRING_SESSION')

# Bot settings
CACHE_TIME = int(environ.get('CACHE_TIME', 300))
Expand All @@ -30,11 +28,9 @@

# Messages
default_start_msg = """
**Hi, I'm Media Search bot**
**Hi, I'm Media Search Bot or ypu can call me as Auto-Filter Bot**
Here you can search files in inline mode. Just press following buttons and start searching.
Here you can search files in Inline mode as well as PM, Use the below buttons to search files or send me the name of file to search.
"""

START_MSG = environ.get('START_MSG', default_start_msg)
SHARE_BUTTON_TEXT = 'Checkout {username} for searching files'
INVITE_MSG = environ.get('INVITE_MSG', 'Please join @.... to use this bot')
START_MSG = environ.get('START_MSG', default_start_msg)
46 changes: 0 additions & 46 deletions one_time_indexer.py

This file was deleted.

117 changes: 102 additions & 15 deletions plugins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,102 @@
import logging
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from info import START_MSG, CHANNELS, ADMINS, INVITE_MSG
from utils import Media

from info import START_MSG, CHANNELS, ADMINS, AUTH_CHANNEL
from utils import Media, get_file_details
from pyrogram.errors import UserNotParticipant
logger = logging.getLogger(__name__)


@Client.on_message(filters.command('start'))
async def start(bot, message):
"""Start command handler"""
if len(message.command) > 1 and message.command[1] == 'subscribe':
await message.reply(INVITE_MSG)
@Client.on_message(filters.command("start"))
async def start(bot, cmd):
usr_cmdall1 = cmd.text
if usr_cmdall1.startswith("/start subinps"):
if AUTH_CHANNEL:
invite_link = await bot.create_chat_invite_link(int(AUTH_CHANNEL))
try:
user = await bot.get_chat_member(int(AUTH_CHANNEL), cmd.from_user.id)
if user.status == "kicked":
await bot.send_message(
chat_id=cmd.from_user.id,
text="Sorry Sir, You are Banned to use me.",
parse_mode="markdown",
disable_web_page_preview=True
)
return
except UserNotParticipant:
ident, file_id = cmd.text.split("_-_-_-_")
await bot.send_message(
chat_id=cmd.from_user.id,
text="**Please Join My Updates Channel to use this Bot!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🤖 Join Updates Channel", url=invite_link.invite_link)
],
[
InlineKeyboardButton(" 🔄 Try Again", callback_data=f"checksub#{file_id}")
]
]
),
parse_mode="markdown"
)
return
except Exception:
await bot.send_message(
chat_id=cmd.from_user.id,
text="Something went Wrong.",
parse_mode="markdown",
disable_web_page_preview=True
)
return
try:
ident, file_id = cmd.text.split("_-_-_-_")
filedetails = await get_file_details(file_id)
for files in filedetails:
file_caption = files.caption
buttons = [
[
InlineKeyboardButton('Search again', switch_inline_query_current_chat=''),
InlineKeyboardButton('More Bots', url='https://t.me/subin_works/122')
]
]
await bot.send_cached_media(
chat_id=cmd.from_user.id,
file_id=file_id,
caption=file_caption,
reply_markup=InlineKeyboardMarkup(buttons)
)
except Exception as err:
await cmd.reply_text(f"Something went wrong!\n\n**Error:** `{err}`")
elif len(cmd.command) > 1 and cmd.command[1] == 'subscribe':
invite_link = await bot.create_chat_invite_link(int(AUTH_CHANNEL))
await bot.send_message(
chat_id=cmd.from_user.id,
text="**Please Join My Updates Channel to use this Bot!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🤖 Join Updates Channel", url=invite_link.invite_link)
]
]
)
)
else:
buttons = [[
InlineKeyboardButton('Search Here', switch_inline_query_current_chat=''),
InlineKeyboardButton('Go Inline', switch_inline_query=''),
]]
reply_markup = InlineKeyboardMarkup(buttons)
await message.reply(START_MSG, reply_markup=reply_markup)
await cmd.reply_text(
START_MSG,
parse_mode="Markdown",
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Search Here", switch_inline_query_current_chat=''),
InlineKeyboardButton("Other Bots", url="https://t.me/subin_works/122")
],
[
InlineKeyboardButton("About", callback_data="about")
]
]
)
)


@Client.on_message(filters.command('channel') & filters.user(ADMINS))
Expand Down Expand Up @@ -101,3 +179,12 @@ async def delete(bot, message):
await msg.edit('File is successfully deleted from database')
else:
await msg.edit('File not found in database')
@Client.on_message(filters.command('about'))
async def bot_info(bot, message):
buttons = [
[
InlineKeyboardButton('Update Channel', url='https://t.me/subin_works'),
InlineKeyboardButton('Source Code', url='https://github.com/subinps/Media-Search-bot')
]
]
await message.reply(text="<b>Developer : <a href='https://t.me/subinps_bot'>SUBIN</a>\nLanguage : <code>Python3</code>\nLibrary : <a href='https://docs.pyrogram.org/'>Pyrogram asyncio</a>\nSource Code : <a href='https://github.com/subinps/Media-Search-bot'>Click here</a>\nUpdate Channel : <a href='https://t.me/subin_works'>XTZ Bots</a> </b>", reply_markup=InlineKeyboardMarkup(buttons), disable_web_page_preview=True)
Loading

0 comments on commit 2aaddb4

Please sign in to comment.