Giter VIP home page Giter VIP logo

media-search-bot's Introduction

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

Installation

Watch this video to create bot - https://youtu.be/dsuTn4qV2GA

Easy Way

Deploy

Hard Way

# Create virtual environment
python3 -m venv env

# Activate virtual environment
env\Scripts\activate.bat # For Windows
source env/bin/activate # For Linux or MacOS

# Install Packages
pip3 install -r requirements.txt

# Edit info.py with variables as given below then run bot
python3 bot.py

Check sample_info.py before editing info.py file

Docker

docker run -d \
    -e BOT_TOKEN="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" \
    -e API_ID='12345' \
    -e API_HASH='0123456789abcdef0123456789abcdef' \
    -e CHANNELS='-10012345678' \
    -e ADMINS='123456789' \
    -e DATABASE_URI="mongodb+srv://...mongodb.net/Database?retryWrites=true&w=majority" \
    -e DATABASE_NAME=databasename \
    --restart on-failure \
    --name mediasearchbot botxtg/media-search-bot

You can also run with env file like below,

docker run -d \ 
     --env-file .env \
     --restart on-failure \
     --name mediasearchbot botxtg/media-search-bot

Variables

Required Variables

  • BOT_TOKEN: Create a bot using @BotFather, and get the Telegram API token.
  • API_ID: Get this value from telegram.org
  • API_HASH: Get this value from telegram.org
  • CHANNELS: Username or ID of channel or group. Separate multiple IDs by space
  • ADMINS: Username or ID of Admin. Separate multiple Admins by space
  • DATABASE_URI: mongoDB URI. Get this value from mongoDB. For more help watch this video
  • DATABASE_NAME: Name of the database in mongoDB. For more help watch this video

Optional Variables

  • COLLECTION_NAME: Name of the collections. Defaults to Telegram_files. If you going to use same database, then use different collection name for each bot
  • CACHE_TIME: The maximum amount of time in seconds that the result of the inline query may be cached on the server
  • USE_CAPTION_FILTER: Whether bot should use captions to improve search results. (True/False)
  • 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

channel - Get basic infomation about channels
total - Show total of saved files
delete - Delete file from database
index - Index all files from channel or group
logger - Get log file

Tips

  • Use index command or run 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

Support

Update Channel and Support Group

License

Code released under The GNU General Public License.

media-search-bot's People

Contributors

jonatan1609 avatar mahesh0253 avatar spechide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

media-search-bot's Issues

Unable to deploy the app through heroku.

Hi I am trying to create an inline search bot and filled all the required Fields with appropriate informations.
But when I clicked on "Deploy App" at the end of everything, the following following lines popups:-

"Item could not be created:
We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."

Please guide me, what to do next?

koyeb

can you please add koyeb support

Indexing Error

image

/index -46464634186

Error Msg

Error: unpack requires a buffer of 263 bytes

How to remove buttons from inline Search bot.

Screenshot_20220129_211308

Is there any process to remove the buttons from the inline shared files , shared through inline bot(In screenshot ), (2 buttons available below the files).
The buttons are as follows:-
1)search again &
2) Share bot.

As this bot is for private use so these buttons are pretty non-functional for me...

So, what should I do to remove those buttons.??
Any suggestions?

not working

this repo is not working it only shows messgae in bot but not files

RPC ERROR - BOT CRASHING IMMEDIATELY AFTER DEPLOYMENT

AFTER THE WORKER IS STARTED ;
THIS HAPPENS.

PLEASE LET ME KNOW HOW TO FIX IT

Pyrogram v1.0.7, Copyright (C) 2017-2020 Dan https://github.com/delivrance
2021-04-24T23:02:57.889465+00:00 app[worker.1]: Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
2021-04-24T23:02:57.889466+00:00 app[worker.1]:
2021-04-24T23:02:58.468430+00:00 app[worker.1]: Traceback (most recent call last):
2021-04-24T23:02:58.468440+00:00 app[worker.1]: File "bot.py", line 40, in
2021-04-24T23:02:58.468640+00:00 app[worker.1]: app.run()
2021-04-24T23:02:58.468647+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/methods/utilities/run.py", line 57, in run
2021-04-24T23:02:58.468800+00:00 app[worker.1]: run(self.start())
2021-04-24T23:02:58.468804+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
2021-04-24T23:02:58.469181+00:00 app[worker.1]: return future.result()
2021-04-24T23:02:58.469186+00:00 app[worker.1]: File "bot.py", line 28, in start
2021-04-24T23:02:58.469311+00:00 app[worker.1]: await super().start()
2021-04-24T23:02:58.469336+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/methods/utilities/start.py", line 57, in start
2021-04-24T23:02:58.469486+00:00 app[worker.1]: await self.authorize()
2021-04-24T23:02:58.469489+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/client.py", line 280, in authorize
2021-04-24T23:02:58.469706+00:00 app[worker.1]: return await self.sign_in_bot(self.bot_token)
2021-04-24T23:02:58.469726+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/methods/auth/sign_in_bot.py", line 46, in sign_in_bot
2021-04-24T23:02:58.469856+00:00 app[worker.1]: r = await self.send(
2021-04-24T23:02:58.469876+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/methods/advanced/send.py", line 77, in send
2021-04-24T23:02:58.470018+00:00 app[worker.1]: r = await self.session.send(
2021-04-24T23:02:58.470063+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/session/session.py", line 441, in send
2021-04-24T23:02:58.470358+00:00 app[worker.1]: return await self._send(data, timeout=timeout)
2021-04-24T23:02:58.470405+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/session/session.py", line 411, in _send
2021-04-24T23:02:58.470614+00:00 app[worker.1]: RPCError.raise_it(result, type(data))
2021-04-24T23:02:58.470617+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/errors/rpc_error.py", line 78, in raise_it
2021-04-24T23:02:58.470826+00:00 app[worker.1]: raise getattr(
2021-04-24T23:02:58.470883+00:00 app[worker.1]: pyrogram.errors.exceptions.bad_request_400.ApiIdInvalid: [400 API_ID_INVALID]: The api_id/api_hash combination is invalid (caused by "auth.ImportBotAuthorization")
2021-04-24T23:02:58.735664+00:00 heroku[worker.1]: Process exited with status 1
2021-04-24T23:02:58.921775+00:00 heroku[worker.1]: State changed from up to crashed

Deployment Error

raceback (most recent call last):
File "D:\school doc\Filter_bot\bot.py", line 10, in
from utils import Media
File "D:\school doc\Filter_bot\utils_init_.py", line 2, in
from .database import Media, save_file, get_search_results
File "D:\school doc\Filter_bot\utils\database.py", line 9, in
from info import DATABASE_URI, DATABASE_NAME, COLLECTION_NAME, USE_CAPTION_FILTER
File "D:\school doc\Filter_bot\info.py", line 9, in
API_ID = int(environ['5424560'])
File "D:\python\lib\os.py", line 679, in getitem
raise KeyError(key) from None

search chat

Sorry to hijack your project. But do you know a project to search public groups? (Something like searchPublicChats Class, without the need to code something)

Because the search on user application return incomplete results

function

Put a function so that it reads the old posts from my channel and index

RAILWAY

BRO CAN YOU PLS ADD RAILWAY SUPPORT

Search again button

Bro search again button is not working properly. When we click on that button that will showing my telegram user name or 'null' massage

INDEX COMMAND ERROR

when i run /index command I'M GETTING THIS Error: unpack requires a buffer of 263 bytes
here are the heroku logs

2021-07-01T08:11:31.272699+00:00 app[worker.1]: Qtagbot with for Pyrogram v1.2.9 (Layer 128) started on qtagbot.
2021-07-01T08:14:02.330614+00:00 app[worker.1]: 08:14:02 AM - 61 - plugins.userbot - userbot - ERROR - unpack requires a buffer of 263 bytes
2021-07-01T08:14:02.330623+00:00 app[worker.1]: Traceback (most recent call last):
2021-07-01T08:14:02.330625+00:00 app[worker.1]: File "/app/plugins/userbot.py", line 32, in index_files
2021-07-01T08:14:02.330626+00:00 app[worker.1]: async with user_bot:
2021-07-01T08:14:02.330627+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/client.py", line 258, in aenter
2021-07-01T08:14:02.330627+00:00 app[worker.1]: return await self.start()
2021-07-01T08:14:02.330628+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/methods/utilities/start.py", line 53, in start
2021-07-01T08:14:02.330628+00:00 app[worker.1]: is_authorized = await self.connect()
2021-07-01T08:14:02.330628+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/methods/auth/connect.py", line 39, in connect
2021-07-01T08:14:02.330629+00:00 app[worker.1]: await self.load_session()
2021-07-01T08:14:02.330629+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/client.py", line 672, in load_session
2021-07-01T08:14:02.330630+00:00 app[worker.1]: await self.storage.open()
2021-07-01T08:14:02.330630+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.8/site-packages/pyrogram/storage/memory_storage.py", line 38, in open
2021-07-01T08:14:02.330631+00:00 app[worker.1]: dc_id, test_mode, auth_key, user_id, is_bot = struct.unpack(
2021-07-01T08:14:02.330631+00:00 app[worker.1]: struct.error: unpack requires a buffer of 263 bytes

Getting Some Kind of Error

Please Help to solve this error:

2021-02-05T08:12:23.841256+00:00 app[worker.1]: Traceback (most recent call last):
2021-02-05T08:12:23.841280+00:00 app[worker.1]:   File "bot.py", line 12, in <module>
2021-02-05T08:12:23.841355+00:00 app[worker.1]:     from utils import Media
2021-02-05T08:12:23.841371+00:00 app[worker.1]:   File "/app/utils.py", line 13, in <module>
2021-02-05T08:12:23.841462+00:00 app[worker.1]:     instance = Instance(db)
2021-02-05T08:12:23.841483+00:00 app[worker.1]: TypeError: Can't instantiate abstract class Instance with abstract methods is_compatible_with

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.