[
  {
    "path": ".gitignore",
    "content": "# Personal files\r\n*.session\r\n*.session-journal\r\n.vscode\r\n*test*.py\r\nsetup.cfg\r\n\r\n# Byte-compiled / optimized / DLL files\r\n__pycache__/\r\n*.py[cod]\r\n*$py.class\r\n\r\n# C extensions\r\n*.so\r\n\r\n# Distribution / packaging\r\n.Python\r\nbuild/\r\ndevelop-eggs/\r\ndist/\r\ndownloads/\r\neggs/\r\n.eggs/\r\nlib/\r\nlib64/\r\nparts/\r\nsdist/\r\nvar/\r\nwheels/\r\nshare/python-wheels/\r\n*.egg-info/\r\n.installed.cfg\r\n*.egg\r\nMANIFEST\r\n\r\n# PyInstaller\r\n#  Usually these files are written by a python script from a template\r\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\r\n*.manifest\r\n*.spec\r\n\r\n# Installer logs\r\npip-log.txt\r\npip-delete-this-directory.txt\r\n\r\n# Unit test / coverage reports\r\nhtmlcov/\r\n.tox/\r\n.nox/\r\n.coverage\r\n.coverage.*\r\n.cache\r\nnosetests.xml\r\ncoverage.xml\r\n*.cover\r\n*.py,cover\r\n.hypothesis/\r\n.pytest_cache/\r\ncover/\r\n\r\n# Translations\r\n*.mo\r\n*.pot\r\n\r\n# Django stuff:\r\n*.log\r\nlocal_settings.py\r\ndb.sqlite3\r\ndb.sqlite3-journal\r\n\r\n# Flask stuff:\r\ninstance/\r\n.webassets-cache\r\n\r\n# Scrapy stuff:\r\n.scrapy\r\n\r\n# Sphinx documentation\r\ndocs/_build/\r\n\r\n# PyBuilder\r\n.pybuilder/\r\ntarget/\r\n\r\n# Jupyter Notebook\r\n.ipynb_checkpoints\r\n\r\n# IPython\r\nprofile_default/\r\nipython_config.py\r\n\r\n# pyenv\r\n#   For a library or package, you might want to ignore these files since the code is\r\n#   intended to run in multiple environments; otherwise, check them in:\r\n# .python-version\r\n\r\n# pipenv\r\n#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.\r\n#   However, in case of collaboration, if having platform-specific dependencies or dependencies\r\n#   having no cross-platform support, pipenv may install dependencies that don't work, or not\r\n#   install all needed dependencies.\r\n#Pipfile.lock\r\n\r\n# PEP 582; used by e.g. github.com/David-OConnor/pyflow\r\n__pypackages__/\r\n\r\n# Celery stuff\r\ncelerybeat-schedule\r\ncelerybeat.pid\r\n\r\n# SageMath parsed files\r\n*.sage.py\r\n\r\n# Environments\r\n.env\r\n.venv\r\nenv/\r\nvenv/\r\nENV/\r\nenv.bak/\r\nvenv.bak/\r\n\r\n# Spyder project settings\r\n.spyderproject\r\n.spyproject\r\n\r\n# Rope project settings\r\n.ropeproject\r\n\r\n# mkdocs documentation\r\n/site\r\n\r\n# mypy\r\n.mypy_cache/\r\n.dmypy.json\r\ndmypy.json\r\n\r\n# Pyre type checker\r\n.pyre/\r\n\r\n# pytype static type analyzer\r\n.pytype/\r\n\r\n# Cython debug symbols\r\ncython_debug/\r\nconfig.py\r\n.goutputstream-VAFWB1\r\nresult.json\r\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM python:3.8-slim-buster\n\nRUN apt update && apt upgrade -y\nRUN apt install git -y\nCOPY requirements.txt /requirements.txt\n\nRUN cd /\nRUN pip3 install -U pip && pip3 install -U -r requirements.txt\nWORKDIR /PiroAutoFilterBot\n\nCOPY . .\n\nCMD [\"python3\", \"bot.py\"]"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License along\n    with this program; if not, write to the Free Software Foundation, Inc.,\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.\n"
  },
  {
    "path": "Procfile",
    "content": "web: python3 bot.py\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n  <img src=\"assets/logo.jpg\">\n</p>\n<h1 align=\"center\">\n  <b>PiroAutoFilterBot</b>\n</h1>\n\n![Typing SVG](https://readme-typing-svg.herokuapp.com/?lines=PIRO+MOVIE+SEARCH+BOT+!;CREATED+BY+PIRO!;A+ADVANCE+BOT+WITH+COOL+FEATURES!)</p>\n<a href=\"https://github.com/ritheshrkrm/PiroAutoFilterBot/stargazers\"><img src=\"https://img.shields.io/github/stars/ritheshrkrm/PiroAutoFilterBot?color=black&logo=github&logoColor=black&style=for-the-badge\" alt=\"Stars\" /></a>\n<a href=\"https://github.com/ritheshrkrm/PiroAutoFilterBot/network/members\"> <img src=\"https://img.shields.io/github/forks/ritheshrkrm/PiroAutoFilterBot?color=black&logo=github&logoColor=black&style=for-the-badge\" /></a>\n<a href=\"https://github.com/ritheshrkrm/PiroAutoFilterBot/blob/master/LICENSE\"> <img src=\"https://img.shields.io/badge/License- GPL 2.0 license -blueviolet?style=for-the-badge\" alt=\"License\" /> </a>\n<a href=\"https://www.python.org/\"> <img src=\"https://img.shields.io/badge/Written%20in-Python-skyblue?style=for-the-badge&logo=python\" alt=\"Python\" /> </a>\n<a href=\"https://pypi.org/project/Pyrogram/\"> <img src=\"https://img.shields.io/pypi/v/pyrogram?color=white&label=pyrogram&logo=python&logoColor=blue&style=for-the-badge\" /></a>\n<a href=\"https://github.com/ritheshrkrm/PiroAutoFilterBot\"> <img src=\"https://img.shields.io/github/repo-size/ritheshrkrm/PiroAutoFilterBot?color=skyblue&logo=github&logoColor=blue&style=for-the-badge\" /></a>\n<a href=\"https://github.com/ritheshrkrm/PiroAutoFilterBot/commits/kdbotz\"> <img src=\"https://img.shields.io/github/last-commit/ritheshrkrm/PiroAutoFilterBot?color=black&logo=github&logoColor=black&style=for-the-badge\" /></a>\n\n### Features\n\n- [x] Indexes Files above 2GB\n- [x] Force Subscription\n- [x] Automatic File Filtering\n- [x] Double Filter Button\n- [x] Single Filter Button\n- [x] Forward Restriction\n- [x] File Protect\n- [x] Manual File Filtering\n- [x] Global File Filtering\n- [x] IMDB\n- [x] Admin Commands\n- [x] User Broadcast\n- [x] Group Broadcast\n- [x] Index\n- [x] IMDB search\n- [x] Inline Search\n- [x] Random pics\n- [x] ids and User info \n- [x] Stats\n- [x] Users\n- [x] Chats\n- [x] User Ban\n- [x] User Unban\n- [x] Chat Leave\n- [x] Chat Disable\n- [x] Channel\n- [x] Spelling Check Feature\n- [x] File Store\n- [x] Auto Delete\n- [x] And More....\n\n\n### Required Variables\n* `BOT_TOKEN`: Create a bot using [@BotFather](https://telegram.dog/BotFather), and get the Telegram API token.\n* `API_ID`: Get this value from [telegram.org](https://my.telegram.org/apps)\n* `API_HASH`: Get this value from [telegram.org](https://my.telegram.org/apps)\n* `CHANNELS`: Username or ID of channel or group. Separate multiple IDs by space\n* `ADMINS`: Username or ID of Admin. Separate multiple Admins by space\n* `DATABASE_URI`: [mongoDB](https://www.mongodb.com) URI. Get this value from [mongoDB](https://www.mongodb.com). For more help watch this [video](https://youtu.be/1G1XwEOnxxo)\n* `DATABASE_NAME`: Name of the database in [mongoDB](https://www.mongodb.com). For more help watch this [video](https://youtu.be/1G1XwEOnxxo)\n* `LOG_CHANNEL` : A channel to log the activities of bot. Make sure bot is an admin in the channel.\n### Optional Variables\n* `PICS`: Telegraph links of images to show in start message.( Multiple images can be used separated by space )\n* `FILE_STORE_CHANNEL`: Channel from were file store links of posts should be made.Separate multiple IDs by space\n* Check [info.py](https://github.com/ritheshrkrm/PiroAutoFilterBot/blob/master/info.py) for more\n\n### Deployment Methods\n<details><summary>Deploy To Heroku</summary>\n<p>\n<br>\n<a href=\"https://heroku.com/deploy?template=https://github.com/ritheshrkrm/PiroAutoFilterBot\">\n  <img src=\"https://www.herokucdn.com/deploy/button.svg\" alt=\"Deploy To Heroku\">\n</a>\n</p>\n</details>\n\n<details><summary>Deploy To Koyeb</summary>\n<b>The fastest way to deploy the application is to click the Deploy to Koyeb button below.</b>\n\n[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?type=git&repository=https://github.com/ritheshrkrm/PiroAutoFilterBot&branch=main&name=pirobot)\n</details>\n\n<details><summary>Deploy on Railway</summary>\n<a href=\"https://railway.app/new/template/y0ryFO\">\n<img src=\"https://railway.app/button.svg\" alt=\"Deploy on Railway\">\n</a>\n</details>\n\n<details><summary>Deploy To Render</summary>\n<br>\n<a href=\"https://render.com/deploy?repo=https://github/ritheshrkrm/PiroAutoFilterBot/tree/master\">\n<img src=\"https://render.com/images/deploy-to-render-button.svg\" alt=\"Deploy to Render\">\n</a>\n</details>\n\n<details><summary>Deploy To VPS</summary>\n<p>\n<pre>\nUse VPS Branch\ngit clone https://github.com/ritheshrkrm/PiroAutoFilterBot\n# Install Packages\npip3 install -U -r requirements.txt\nEdit info.py with variables as given below then run bot\npython3 bot.py\n</pre>\n</p>\n</details>\n\n\n### Commands\n```\nalive - check bot alive  \nping - pong  \ngfilter - to add a global filter \ndelg - to delete a global filter \nbroadcast - to broadcast a message to all users \ngroup_broadcast - to broadcast a message to all groups \nsettings - get settings   \nlogs - to get the rescent errors  \nstats - to get status of files in db \nfilter - add manual filters \nfilters - view filters  \nconnect - connect to PM \ndisconnect - disconnect from PM  \ndel - delete a filter  \ndelall - delete all filters    \nid - get tg ids \nimdb - fetch info from imdb  \nusers - to get list of my users and ids \nchats - to get list of the my chats and ids   \nleave  - to leave from a chat \ndisable  -  do disable a chat \nenable - re-enable chat \nban  - to ban a user  \nunban  - to unban a use\n```\n\n\n\n### Thanks to \n - Thanks To EvaMaria Devs For Their AutoFIlterBot\n - Thanks To Me For Wasting Time On This Repo Instead Of Studying :)\n\n ### Note 🏷️\n - <b>Importing this repo instead of forking is strictly prohibited 🚫 Kindly fork and edit as your wish (Must Give Credits for devs) 🙃</b>\n - <b>If you find any bugs or errors, report it to the developer.</b>\n* [![Contact Developer](https://img.shields.io/static/v1?label=Contact+Developer&message=On+Telegram&color=critical)](https://telegram.me/raixchat)\n\n### TELAGRAM SUPPORT \n\n* [![PIRO BOTZ](https://img.shields.io/static/v1?label=PIRO&message=BOTZ&color=critical)](https://telegram.me/piroxbots)\n\n\n\n### Disclaimer\n[![GNU Affero General Public License 2.0](https://www.gnu.org/graphics/agplv3-155x51.png)](https://www.gnu.org/licenses/agpl-3.0.en.html#header)    \nLicensed under [GNU AGPL 2.0.](https://github.com/ritheshrkrm/PiroAutoFilterBot/blob/master/LICENSE)\nSelling The Codes To Other People For Money Is *Strictly Prohibited*.\n"
  },
  {
    "path": "Script.py",
    "content": "class script(object):\n    START_TXT = \"\"\"𝖸𝗈...𝖸𝗈... {} 💖\n\n<b><u>𝖨'𝗆 𝖯𝗈𝗐𝖾𝗋𝖿𝗎𝗅 𝖠𝗎𝗍𝗈-𝖥𝗂𝗅𝗍𝖾𝗋 𝖡𝗈𝗍 𝖸𝗈𝗎 𝖢𝖺𝗇 𝖴𝗌𝖾 𝖬𝖾 𝖠𝗌 𝖠 𝖠𝗎𝗍𝗈-𝖿𝗂𝗅𝗍𝖾𝗋 𝗂𝗇 𝖸𝗈𝗎𝗋 𝖦𝗋𝗈𝗎𝗉</u></b>\n\n<i>𝖨𝗍𝗌 𝖤𝖺𝗌𝗒 𝖳𝗈 𝖴𝗌𝖾 𝖬𝖾; 𝖩𝗎𝗌𝗍 𝖠𝖽𝖽 𝖬𝖾 𝖳𝗈 𝖸𝗈𝗎𝗋 𝖦𝗋𝗈𝗎𝗉 𝖠𝗌 𝖠𝖽𝗆𝗂𝗇, \n𝖳𝗁𝖺𝗍𝗌 𝖠𝗅𝗅, 𝗂 𝗐𝗂𝗅𝗅 𝖯𝗋𝗈𝗏𝗂𝖽𝖾 𝖬𝗈𝗏𝗂𝖾𝗌 𝖳𝗁𝖾𝗋𝖾...🤓🤪</i>\n\n⚠️ 𝖬𝗈𝗋𝖾 𝖧𝖾𝗅𝗉 𝖧𝗂𝗍 /help\n\n🙋🏻‍♂️ 𝖳𝗎𝗍𝗈𝗋𝗂𝖺𝗅 𝖦𝗎𝗂𝖽𝖾 @piro_tuts\n\n<b>😎 𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖻𝗒 @piroxbots</b>\"\"\"\n\n    HELP_TXT = \"\"\"🙋🏻‍♂️   𝖧𝖾𝗅𝗅𝗈𝗈𝗈  {} 🤓\n\n○  𝗂𝗍'𝗌 𝖭𝗈𝗍𝖾 𝖢𝗈𝗆𝗉𝗅𝗂𝖼𝖺𝗍𝖾𝖽...🤓\n\n○  𝖲𝖾𝖺𝗋𝖼𝗁 𝗎𝗌𝗂𝗇𝗀 𝗂𝗇𝗅𝗂𝗇𝖾 𝗆𝗈𝖽𝖾\n𝖳𝗁𝗂𝗌 𝗆𝖾𝗍𝗁𝗈𝖽 𝗐𝗈𝗋𝗄𝗌 𝗈𝗇 𝖺𝗇𝗒 𝖼𝗁𝖺𝗍, 𝖩𝗎𝗌𝗍 𝗍𝗒𝗉𝖾 <b>Bot Username</b> 𝖺𝗇𝖽 𝗍𝗁𝖾𝗇 𝗅𝖾𝖺𝗏𝖾 𝖺 𝗌𝗉𝖺𝖼𝖾 𝖺𝗇𝖽 𝗌𝖾𝖺𝗋𝖼𝗁 𝖺𝗇𝗒 𝗆𝗈𝗏𝗂𝖾 𝗒𝗈𝗎 𝗐𝖺𝗇𝗍...\n\n🙋🏻‍♂️ 𝖳𝗎𝗍𝗈𝗋𝗂𝖺𝗅 𝖦𝗎𝗂𝖽𝖾 @piro_tuts\n\n○ 𝖠𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 𝖢𝗈𝗆𝗆𝖺𝗇𝖽𝗌\n     \n /alive - Check I'm Alive..\n /info - User info\n /ping - To get your ping\n /id - User id\n /stats - Db status  \n /broadcast - Broadcast (𝖮𝗐𝗇𝖾𝗋 𝖮𝗇𝗅𝗒)\n\n○ <u>𝖭𝗈𝗍𝗂𝖼𝖾</u> 📙:-\n\n𝖣𝗈𝗇𝗍 𝖲𝗉𝖺𝗆 𝖬𝖾...🤒\n\n😎 𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖻𝗒 @piroxbots\"\"\"\n\n    ABOUT_TXT = \"\"\"<b>○ 𝖬𝗒 𝖭𝖺𝗆𝖾: {}\n○ 𝖢𝗋𝖾𝖺𝗍𝗈𝗋 : <a href='https://t.me/piroxbots'>𝖳𝗁𝗂𝗌 𝖯𝖾𝗋𝗌𝗈𝗇</a>\n○ 𝖫𝖺𝗇𝗀𝗎𝖺𝗀𝖾 : 𝖯𝗒𝗍𝗁𝗈𝗇 𝟥 \n○ 𝖫𝗂𝖻𝗋𝖺𝗋𝗒 : 𝖯𝗒𝗋𝗈𝗀𝗋𝖺𝗆 𝖺𝗌𝗒𝗇𝖼𝗂𝗈 𝟢.𝟣𝟩.𝟣 \n○ 𝖲𝖾𝗋𝗏𝖾𝗋 : Contabo\n○ 𝖣𝖺𝗍𝖺𝖻𝖺𝗌𝖾 : <a href='https://www.mongodb.com'>𝖬𝗈𝗇𝗀𝗈𝖣𝖡 𝖥𝗋𝖾𝖾 𝖳𝗂𝖾𝗋</a>\n○ 𝖡𝗎𝗂𝗅𝖽 𝖲𝗍𝖺𝗍𝗎𝗌 : v1.0.1 [BeTa]\n○ 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉 : <a href='https://t.me/raixchat'>𝖳𝖺𝗉 𝖧𝖾𝗋𝖾</a>\"\"\"\n\n    SOURCE_TXT = \"\"\"<b>NOTE:</b>\nSpecial Thanks to EvaMaria Devs & Cloners for the codes \n<b>DEV:</b>\n\n- <a href=https://t.me/piroxbots>[𝖯𝖨𝖱𝖮]</a>\n\n- Source - https://github.com/ritheshrkrm/PiroAutoFilterBot\"\"\" #please don't change repo link give credit :)\n\n    MANUELFILTER_TXT = \"\"\"ʜᴇʟᴘ: <b>ꜰɪʟᴛᴇʀꜱ</b>\n- ꜰɪʟᴛᴇʀ ɪꜱ ᴀ ꜰᴇᴀᴛᴜʀᴇ ᴡᴇʀᴇ ᴜꜱᴇʀꜱ ᴄᴀɴ ꜱᴇᴛ ᴀᴜᴛᴏᴍᴀᴛᴇᴅ ʀᴇᴘʟɪᴇꜱ ꜰᴏʀ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ᴋᴇʏᴡᴏʀᴅ ᴀɴᴅ ɪ ᴡɪʟʟ ʀᴇꜱᴘᴏɴᴅ ᴡʜᴇɴᴇᴠᴇʀ ᴀ ᴋᴇʏᴡᴏʀᴅ ɪꜱ ꜰᴏᴜɴᴅ ɪɴ ᴛʜᴇ ᴍᴇꜱꜱᴀɢᴇ\n<b>ɴᴏᴛᴇ:</b>\n1. ᴛʜɪꜱ ʙᴏᴛ ꜱʜᴏᴜʟᴅ ʜᴀᴠᴇ ᴀᴅᴍɪɴ ᴘʀɪᴠɪʟᴇɢᴇ.\n2. ᴏɴʟʏ ᴀᴅᴍɪɴꜱ ᴄᴀɴ ᴀᴅᴅ ꜰɪʟᴛᴇʀꜱ ɪɴ ᴀ ᴄʜᴀᴛ.\n3. ᴀʟᴇʀᴛ ʙᴜᴛᴛᴏɴꜱ ʜᴀᴠᴇ ᴀ ʟɪᴍɪᴛ ᴏꜰ 64 ᴄʜᴀʀᴀᴄᴛᴇʀꜱ.\n\nCᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:\n\n• /filter - <code>ᴀᴅᴅ ᴀ ꜰɪʟᴛᴇʀ ɪɴ ᴀ ᴄʜᴀᴛ</code>\n• /filters - <code>ʟɪꜱᴛ ᴀʟʟ ᴛʜᴇ ꜰɪʟᴛᴇʀꜱ ᴏꜰ ᴀ ᴄʜᴀᴛ</code>\n• /del - <code>ᴅᴇʟᴇᴛᴇ ᴀ ꜱᴘᴇᴄɪꜰɪᴄ ꜰɪʟᴛᴇʀ ɪɴ ᴀ ᴄʜᴀᴛ</code>\n• /delall - <code>ᴅᴇʟᴇᴛᴇ ᴛʜᴇ ᴡʜᴏʟᴇ ꜰɪʟᴛᴇʀꜱ ɪɴ ᴀ ᴄʜᴀᴛ (ᴄʜᴀᴛ ᴏᴡɴᴇʀ ᴏɴʟʏ)</code>\"\"\"\n\n    BUTTON_TXT = \"\"\"ʜᴇʟᴘ: <b>ʙᴜᴛᴛᴏɴꜱ</b>\n- ᴛʜɪꜱ ʙᴏᴛ ꜱᴜᴘᴘᴏʀᴛꜱ ʙᴏᴛʜ ᴜʀʟ ᴀɴᴅ ᴀʟᴇʀᴛ ɪɴʟɪɴᴇ ʙᴜᴛᴛᴏɴꜱ.\n<b>ɴᴏᴛᴇ:</b>\n1. ᴛᴇʟᴇɢʀᴀᴍ ᴡɪʟʟ ɴᴏᴛ ᴀʟʟᴏᴡꜱ ʏᴏᴜ ᴛᴏ ꜱᴇɴᴅ ʙᴜᴛᴛᴏɴꜱ ᴡɪᴛʜᴏᴜᴛ ᴀɴʏ ᴄᴏɴᴛᴇɴᴛ, ꜱᴏ ᴄᴏɴᴛᴇɴᴛ ɪꜱ ᴍᴀɴᴅᴀᴛᴏʀʏ.\n2. ᴛʜɪꜱ ʙᴏᴛ ꜱᴜᴘᴘᴏʀᴛꜱ ʙᴜᴛᴛᴏɴꜱ ᴡɪᴛʜ ᴀɴʏ ᴛᴇʟᴇɢʀᴀᴍ ᴍᴇᴅɪᴀ ᴛʏᴘᴇ.\n3. ʙᴜᴛᴛᴏɴꜱ ꜱʜᴏᴜʟᴅ ʙᴇ ᴘʀᴏᴘᴇʀʟʏ ᴘᴀʀꜱᴇᴅ ᴀꜱ ᴍᴀʀᴋᴅᴏᴡɴ ꜰᴏʀᴍᴀᴛ\n<b>ᴜʀʟ ʙᴜᴛᴛᴏɴꜱ:</b>\n<code>[Button Text](buttonurl:https://t.me/piroxbots)</code>\n<b>ᴀʟᴇʀᴛ ʙᴜᴛᴛᴏɴꜱ:</b>\n<code>[Button Text](buttonalert:ᴛʜɪꜱ ɪꜱ ᴀɴ ᴀʟᴇʀᴛ ᴍᴇꜱꜱᴀɢᴇ)</code>\"\"\"\n\n    AUTOFILTER_TXT = \"\"\"ʜᴇʟᴘ: <b>ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ</b>\n<b>ɴᴏᴛᴇ: Fɪʟᴇ Iɴᴅᴇx</b>\n1. ᴍᴀᴋᴇ ᴍᴇ ᴛʜᴇ ᴀᴅᴍɪɴ ᴏꜰ ʏᴏᴜʀ ᴄʜᴀɴɴᴇʟ ɪꜰ ɪᴛ'ꜱ ᴘʀɪᴠᴀᴛᴇ.\n2. ᴍᴀᴋᴇ ꜱᴜʀᴇ ᴛʜᴀᴛ ʏᴏᴜʀ ᴄʜᴀɴɴᴇʟ ᴅᴏᴇꜱ ɴᴏᴛ ᴄᴏɴᴛᴀɪɴꜱ ᴄᴀᴍʀɪᴘꜱ, ᴘᴏʀɴ ᴀɴᴅ ꜰᴀᴋᴇ ꜰɪʟᴇꜱ.\n3. ꜰᴏʀᴡᴀʀᴅ ᴛʜᴇ ʟᴀꜱᴛ ᴍᴇꜱꜱᴀɢᴇ ᴛᴏ ᴍᴇ ᴡɪᴛʜ Qᴜᴏᴛᴇꜱ. ɪ'ʟʟ ᴀᴅᴅ ᴀʟʟ ᴛʜᴇ ꜰɪʟᴇꜱ ɪɴ ᴛʜᴀᴛ ᴄʜᴀɴɴᴇʟ ᴛᴏ ᴍʏ ᴅʙ.\n\n<b>Nᴏᴛᴇ: AᴜᴛᴏFɪʟᴛᴇʀ</b>\n1. Aᴅᴅ ᴛʜᴇ ʙᴏᴛ ᴀs ᴀᴅᴍɪɴ ᴏɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ.\n2. Usᴇ /connect ᴀɴᴅ ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ɢʀᴏᴜᴘ ᴛᴏ ᴛʜᴇ ʙᴏᴛ.\n3. Usᴇ /settings ᴏɴ ʙᴏᴛ's PM ᴀɴᴅ ᴛᴜʀɴ ᴏɴ AᴜᴛᴏFɪʟᴛᴇʀ ᴏɴ ᴛʜᴇ sᴇᴛᴛɪɴɢs ᴍᴇɴᴜ.\"\"\"\n\n    CONNECTION_TXT = \"\"\"ʜᴇʟᴘ: <b>ᴄᴏɴɴᴇᴄᴛɪᴏɴꜱ</b>\n- ᴜꜱᴇᴅ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʙᴏᴛ ᴛᴏ ᴘᴍ ꜰᴏʀ ᴍᴀɴᴀɢɪɴɢ ꜰɪʟᴛᴇʀꜱ \n- ɪᴛ ʜᴇʟᴘꜱ ᴛᴏ ᴀᴠᴏɪᴅ ꜱᴘᴀᴍᴍɪɴɢ ɪɴ ɢʀᴏᴜᴘꜱ.\n<b>ɴᴏᴛᴇ:</b>\n1. ᴏɴʟʏ ᴀᴅᴍɪɴꜱ ᴄᴀɴ ᴀᴅᴅ ᴀ ᴄᴏɴɴᴇᴄᴛɪᴏɴ.\n2. ꜱᴇɴᴅ <code>/ᴄᴏɴɴᴇᴄᴛ</code> ꜰᴏʀ ᴄᴏɴɴᴇᴄᴛɪɴɢ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ᴘᴍ\nCᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:\n• /connect  - <code>ᴄᴏɴɴᴇᴄᴛ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ᴄʜᴀᴛ ᴛᴏ ʏᴏᴜʀ ᴘᴍ</code>\n• /disconnect  - <code>ᴅɪꜱᴄᴏɴɴᴇᴄᴛ ꜰʀᴏᴍ ᴀ ᴄʜᴀᴛ</code>\n• /connections - <code>ʟɪꜱᴛ ᴀʟʟ ʏᴏᴜʀ ᴄᴏɴɴᴇᴄᴛɪᴏɴꜱ</code>\"\"\"\n\n    EXTRAMOD_TXT = \"\"\"ʜᴇʟᴘ: Exᴛʀᴀ Mᴏᴅᴜʟᴇs\n<b>ɴᴏᴛᴇ:</b>\nᴛʜᴇꜱᴇ ᴀʀᴇ ᴛʜᴇ ᴇxᴛʀᴀ ꜰᴇᴀᴛᴜʀᴇꜱ ᴏꜰ ᴛʜɪꜱ ʙᴏᴛ\nCᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:\n• /id - <code>ɢᴇᴛ ɪᴅ ᴏꜰ ᴀ ꜱᴘᴇᴄɪꜰɪᴇᴅ ᴜꜱᴇʀ.</code>\n• /info  - <code>ɢᴇᴛ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ᴀʙᴏᴜᴛ ᴀ ᴜꜱᴇʀ.</code>\n• /imdb  - <code>ɢᴇᴛ ᴛʜᴇ ꜰɪʟᴍ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ꜰʀᴏᴍ ɪᴍᴅʙ ꜱᴏᴜʀᴄᴇ.</code>\n• /search  - <code>ɢᴇᴛ ᴛʜᴇ ꜰɪʟᴍ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ꜰʀᴏᴍ ᴠᴀʀɪᴏᴜꜱ ꜱᴏᴜʀᴄᴇꜱ.</code>\"\"\"\n\n    ADMIN_TXT = \"\"\"ʜᴇʟᴘ: Aᴅᴍɪɴ Mᴏᴅs\n<b>ɴᴏᴛᴇ:</b>\nTʜɪs Mᴏᴅᴜʟᴇ Oɴʟʏ Wᴏʀᴋs Fᴏʀ Mʏ Aᴅᴍɪɴs\nCᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:\n• /logs - <code>ᴛᴏ ɢᴇᴛ ᴛʜᴇ ʀᴇᴄᴇɴᴛ ᴇʀʀᴏʀꜱ</code>\n• /stats - <code>ᴛᴏ ɢᴇᴛ ꜱᴛᴀᴛᴜꜱ ᴏꜰ ꜰɪʟᴇꜱ ɪɴ ᴅʙ. [Tʜɪs Cᴏᴍᴍᴀɴᴅ Cᴀɴ Bᴇ Usᴇᴅ Bʏ Aɴʏᴏɴᴇ]</code>\n• /delete - <code>ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀ ꜱᴘᴇᴄɪꜰɪᴄ ꜰɪʟᴇ ꜰʀᴏᴍ ᴅʙ.</code>\n• /users - <code>ᴛᴏ ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴍʏ ᴜꜱᴇʀꜱ ᴀɴᴅ ɪᴅꜱ.</code>\n• /chats - <code>ᴛᴏ ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴍʏ ᴄʜᴀᴛꜱ ᴀɴᴅ ɪᴅꜱ</code>\n• /leave  - <code>ᴛᴏ ʟᴇᴀᴠᴇ ꜰʀᴏᴍ ᴀ ᴄʜᴀᴛ.</code>\n• /disable  -  <code>ᴛᴏ ᴅɪꜱᴀʙʟᴇ ᴀ ᴄʜᴀᴛ.</code>\n• /ban  - <code>ᴛᴏ ʙᴀɴ ᴀ ᴜꜱᴇʀ.</code>\n• /unban  - <code>ᴛᴏ ᴜɴʙᴀɴ ᴀ ᴜꜱᴇʀ.</code>\n• /channel - <code>ᴛᴏ ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴛᴏᴛᴀʟ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴄʜᴀɴɴᴇʟꜱ</code>\n• /broadcast - <code>ᴛᴏ ʙʀᴏᴀᴅᴄᴀꜱᴛ ᴀ ᴍᴇꜱꜱᴀɢᴇ ᴛᴏ ᴀʟʟ ᴜꜱᴇʀꜱ</code>\n• /group_broadcast - <code>Tᴏ ʙʀᴏᴀᴅᴄᴀsᴛ ᴀ ᴍᴇssᴀɢᴇ ᴛᴏ ᴀʟʟ ᴄᴏɴɴᴇᴄᴛᴇᴅ ɢʀᴏᴜᴘs.</code>\n• /gfilter - <code>ᴛᴏ ᴀᴅᴅ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs</code>\n• /gfilters - <code>ᴛᴏ ᴠɪᴇᴡ ʟɪsᴛ ᴏғ ᴀʟʟ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs</code>\n• /delg - <code>ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀ sᴘᴇᴄɪғɪᴄ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ</code>\n• /request - <code>Tᴏ sᴇɴᴅ ᴀ Mᴏᴠɪᴇ/Sᴇʀɪᴇs ʀᴇᴏ̨ᴜᴇsᴛ ᴛᴏ ʙᴏᴛ ᴀᴅᴍɪɴs. Oɴʟʏ ᴡᴏʀᴋs ᴏɴ sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ. [Tʜɪs Cᴏᴍᴍᴀɴᴅ Cᴀɴ Bᴇ Usᴇᴅ Bʏ Aɴʏᴏɴᴇ]</code>\n• /delallg - <code>Tᴏ ᴅᴇʟᴇᴛᴇ ᴀʟʟ Gғɪʟᴛᴇʀs ғʀᴏᴍ ᴛʜᴇ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ.</code>\n• /deletefiles - <code>Tᴏ ᴅᴇʟᴇᴛᴇ CᴀᴍRɪᴘ ᴀɴᴅ PʀᴇDVD Fɪʟᴇs ғʀᴏᴍ ᴛʜᴇ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ.</code>\"\"\"\n\n    STATUS_TXT = \"\"\"𝖳𝗈𝗍𝖺𝗅 𝖥𝗂𝗅𝖾𝗌: <code>{}</code>\n𝖳𝗈𝗍𝖺𝗅 𝖬𝖾𝗆𝖻𝖾𝗋𝗌: <code>{}</code>\n𝖳𝗈𝗍𝖺𝗅 𝖢𝗁𝖺𝗍𝗌: <code>{}</code>\n𝖴𝗌𝖾𝖽 𝖲𝗍𝗈𝗋𝖺𝗀𝖾: <code>{}</code>\n\n<b>😎 𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖻𝗒 @piroxbots</b>\"\"\"\n\n    LOG_TEXT_G = \"\"\"#NewGroup\n𝖦𝗋𝗈𝗎𝗉 = {}(<code>{}</code>)\n𝖳𝗈𝗍𝖺𝗅 𝖬𝖾𝗆𝖻𝖾𝗋𝗌 = <code>{}</code>\n𝖠𝖽𝖽𝖾𝖽 𝖡𝗒 - {}\"\"\"\n\n    LOG_TEXT_P = \"\"\"#NewUser\n𝖨𝖽 - <code>{}</code>\n𝖭𝖺𝗆𝖾 - {}\"\"\"\n\n    REQ_TXT = \"\"\"𝖧𝖾𝗅𝗅𝗈 {}\n    𝖸𝗈𝗎𝗋 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 𝖧𝖺𝗌 𝖡𝖾𝖾𝗇 𝖠𝗉𝗉𝗋𝗈𝗏𝖾𝖽...!!!\"\"\"\n\n    ALRT_TXT = \"\"\"Hello {},\nThis is Not your Request\nRequest Yourself...!!\"\"\"\n\n    OLD_ALRT_TXT = \"\"\"Hey {},\nYou are using one of old message,\nRequest Again\"\"\"\n\n    CUDNT_FND = \"\"\"<b><i>\n𝖨 𝖼𝗈𝗎𝗅𝖽𝗇'𝗍 𝖿𝗂𝗇𝖽 𝖺𝗇𝗒𝗍𝗁𝗂𝗇𝗀 𝗋𝖾𝗅𝖺𝗍𝖾𝖽 𝗍𝗈 𝗍𝗁𝖺𝗍\n𝖣𝗂𝖽 𝗒𝗈𝗎 𝗆𝖾𝖺𝗇 𝖺𝗇𝗒 𝗈𝗇𝖾 𝗈𝖿 𝗍𝗁𝖾𝗌𝖾?</i></b>\"\"\"\n\n    I_CUDNT = \"\"\"❌ <b>𝖨 𝖼𝗈𝗎𝗅𝖽𝗇'𝗍 𝖿𝗂𝗇𝖽 𝖺𝗇𝗒𝗍𝗁𝗂𝗇𝗀 𝗋𝖾𝗅𝖺𝗍𝖾𝖽 𝗍𝗈 𝗍𝗁𝖺𝗍</b>\\n\\n‼ <b><i>𝖱𝖾𝗉𝗈𝗋𝗍 𝗍𝗈 𝖺𝖽𝗆𝗂𝗇 ▶ @raixchat</i></b>\"\"\"\n\n    I_CUD_NT = \"\"\"❌ <b>𝖨 𝖼𝗈𝗎𝗅𝖽𝗇'𝗍 𝖿𝗂𝗇𝖽 𝖺𝗇𝗒𝗍𝗁𝗂𝗇𝗀 𝗋𝖾𝗅𝖺𝗍𝖾𝖽 𝗍𝗈 𝗍𝗁𝖺𝗍</b>\\n\\n‼ <b><i>𝖱𝖾𝗉𝗈𝗋𝗍 𝗍𝗈 𝖺𝖽𝗆𝗂𝗇 ▶ @raixchat</i></b>\"\"\"\n\n    MVE_NT_FND = \"\"\"❌ <b>𝖨 𝖼𝗈𝗎𝗅𝖽𝗇'𝗍 𝖿𝗂𝗇𝖽 𝖺𝗇𝗒𝗍𝗁𝗂𝗇𝗀 𝗋𝖾𝗅𝖺𝗍𝖾𝖽 𝗍𝗈 𝗍𝗁𝖺𝗍</b>\\n\\n‼ <b><i>𝖱𝖾𝗉𝗈𝗋𝗍 𝗍𝗈 𝖺𝖽𝗆𝗂𝗇 ▶ @raixchat</i></b>\"\"\"\n\n    TOP_ALRT_MSG = \"\"\"𝖢𝗁𝖾𝖼𝗄𝗂𝗇𝗀 𝖿𝗈𝗋 𝗊𝗎𝖾𝗋𝗒 𝗂𝗇 𝖣𝖺𝗍𝖺𝖻𝖺𝗌𝖾...\"\"\"\n\n    MELCOW_ENG = \"\"\"<b>Hey {}, Welcome to {}</b> \n\n• 𝖭𝗈 𝖯𝗋𝗈𝗆𝗈, 𝖭𝗈 𝖯𝗈𝗋𝗇, 𝖭𝗈 𝖮𝗍𝗁𝖾𝗋 𝖠𝖻𝗎𝗌𝖾𝗌\n• 𝖠𝗌𝗄 𝖸𝗈𝗎𝗋 𝖬𝗈𝗏𝗂𝖾𝗌 𝖶𝗂𝗍𝗁 𝖢𝗈𝗋𝗋𝖾𝖼𝗍 𝖲𝗉𝖾𝗅𝗅𝗂𝗇𝗀\n• 𝖲𝗉𝖺𝗆𝗆𝖾𝗋𝗌 𝖲𝗍𝖺𝗒 𝖠𝗐𝖺𝗒\n• 𝖥𝖾𝖾𝗅 𝖥𝗋𝖾𝖾 𝖳𝗈 𝖱𝖾𝗉𝗈𝗋𝗍 𝖠𝗇𝗒 𝖤𝗋𝗋𝗈𝗋𝗌 𝖳𝗈 𝖠𝖽𝗆𝗂𝗇𝗌 𝗎𝗌𝗂𝗇𝗀 @admin\n\n<u>𝗥𝗲𝗾𝘂𝗲𝘀𝘁𝘀 𝗙𝗼𝗿𝗺𝗮𝘁𝘀</u>\n\n• 𝖲𝗈𝗅𝗈 2017\n• 𝖣𝗁𝗈𝗈𝗆 3 𝖧𝗂𝗇𝖽𝗂\n• 𝖪𝗎𝗋𝗎𝗉 𝖪𝖺𝗇\n• 𝖣𝖺𝗋𝗄 𝗌01\n• 𝖲𝗁𝖾 𝖧𝗎𝗅𝗄 720𝗉\n• 𝖥𝗋𝗂𝖾𝗇𝖽𝗌 𝗌03 1080𝗉\n• 𝖬𝗎𝗌𝗍 𝗋𝖾𝖺𝖽 𝗍𝗁𝗂𝗌 https://te.legra.ph/𝖯𝗈𝗐𝖾𝗋𝖾𝖽-𝖡𝗒-𝖯𝖨𝖱𝖮-12-11-2\n\n‼️𝗗𝗼𝗻𝘁 𝗮𝗱𝗱 𝘄𝗼𝗿𝗱𝘀 & 𝘀𝘆𝗺𝗯𝗼𝗹𝘀 𝗹𝗶𝗸𝗲 , . -  send link movie series 𝗲𝘁𝗰‼️\"\"\"\n\n    OWNER_INFO = \"\"\"\n○ 𝖢𝗋𝖾𝖺𝗍𝗈𝗋 : <a href='https://t.me/piroxbots'>𝖳𝗁𝗂𝗌 𝖯𝖾𝗋𝗌𝗈𝗇</a>\n\n○ 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉 : <a href='https://t.me/raixchat'>𝖳𝖺𝗉 𝖧𝖾𝗋𝖾</a>\n\"\"\"\n\n    NORSLTS = \"\"\"\n#NoResults \n\nID <b>: {}</b>\n\nName <b>: {}</b>\n\nMessage <b>: {}</b>\"\"\"\n\n    CAPTION = \"\"\"\n📂 <b>File Name</b>: <code>{file_name}</code> \n\n❤️‍🔥 </b>Join</b> [𝗕𝗟𝗔𝗦𝗧𝗘𝗥 𝗟𝗜𝗡𝗞𝗭](https://t.me/blaster_linkz)  \n\"\"\"\n\n    IMDB_TEMPLATE_TXT = \"\"\"\n🏷 𝖳𝗂𝗍𝗅𝖾: <a href={url}>{title}</a> \n🔮 𝖸𝖾𝖺𝗋: {year} \\n⭐️ 𝖱𝖺𝗍𝗂𝗇𝗀𝗌: {rating}/ 10  \n🎭 𝖦𝖾𝗇𝖾𝗋𝗌: {genres} \n\n🎊 𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖡𝗒 [[𝖯𝖨𝖱𝖮]](t.me/piroxbots)\"\"\"\n    \n    ALL_FILTERS = \"\"\"\n<b>Hᴇʏ {}, Tʜᴇsᴇ ᴀʀᴇ ᴍʏ ᴛʜʀᴇᴇ ᴛʏᴘᴇs ᴏғ ғɪʟᴛᴇʀs.</b>\"\"\"\n    \n    GFILTER_TXT = \"\"\"\n<b>Wᴇʟᴄᴏᴍᴇ ᴛᴏ Gʟᴏʙᴀʟ Fɪʟᴛᴇʀs. Gʟᴏʙᴀʟ Fɪʟᴛᴇʀs ᴀʀᴇ ᴛʜᴇ ғɪʟᴛᴇʀs sᴇᴛ ʙʏ ʙᴏᴛ ᴀᴅᴍɪɴs ᴡʜɪᴄʜ ᴡɪʟʟ ᴡᴏʀᴋ ᴏɴ ᴀʟʟ ɢʀᴏᴜᴘs.</b>\n    \nAᴠᴀɪʟᴀʙʟᴇ ᴄᴏᴍᴍᴀɴᴅs:\n• /gfilter - <code>Tᴏ ᴄʀᴇᴀᴛᴇ ᴀ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ.</code>\n• /gfilters - <code>Tᴏ ᴠɪᴇᴡ ᴀʟʟ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs.</code>\n• /delg - <code>Tᴏ ᴅᴇʟᴇᴛᴇ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ.</code>\n• /delallg - <code>ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀʟʟ ɢʟᴏʙᴀʟ ꜰɪʟᴛᴇʀꜱ.</code>\"\"\"\n    \n    FILE_STORE_TXT = \"\"\"\n<b>Fɪʟᴇ sᴛᴏʀᴇ ɪs ᴛʜᴇ ғᴇᴀᴛᴜʀᴇ ᴡʜɪᴄʜ ᴡɪʟʟ ᴄʀᴇᴀᴛᴇ ᴀ sʜᴀʀᴇᴀʙʟᴇ ʟɪɴᴋ ᴏғ ᴀ sɪɴɢʟᴇ ᴏʀ ᴍᴜʟᴛɪᴘʟᴇ ғɪʟᴇs.</b>\n\nAᴠᴀɪʟᴀʙʟᴇ ᴄᴏᴍᴍᴀɴᴅs:\n• /batch - <code>Tᴏ ᴄʀᴇᴀᴛᴇ ᴀ ʙᴀᴛᴄʜ ʟɪɴᴋ ᴏғ ᴍᴜʟᴛɪᴘʟᴇ ғɪʟᴇs.</code>\n• /link - <code>Tᴏ ᴄʀᴇᴀᴛᴇ ᴀ sɪɴɢʟᴇ ғɪʟᴇ sᴛᴏʀᴇ ʟɪɴᴋ.</code>\n• /pbatch - <code>Jᴜsᴛ ʟɪᴋᴇ /batch, ʙᴜᴛ ᴛʜᴇ ғɪʟᴇs ᴡɪʟʟ ʙᴇ sᴇɴᴅ ᴡɪᴛʜ ғᴏʀᴡᴀʀᴅ ʀᴇsᴛʀɪᴄᴛɪᴏɴs.</code>\n• /plink - <code>Jᴜsᴛ ʟɪᴋᴇ /link, ʙᴜᴛ ᴛʜᴇ ғɪʟᴇ ᴡɪʟʟ ʙᴇ sᴇɴᴅ ᴡɪᴛʜ ғᴏʀᴡᴀʀᴅ ʀᴇsᴛʀɪᴄᴛɪᴏɴ.</code>\"\"\"\n\n    RESTART_TXT = \"\"\"\n<b>𝖡𝗈𝗍 𝖱𝖾𝗌𝗍𝖺𝗋𝗍𝖾𝖽 !</b>\n\n📅 𝖣𝖺𝗍𝖾 : <code>{}</code>\n⏰ 𝖳𝗂𝗆𝖾 : <code>{}</code>\n🌐 𝖳𝗂𝗆𝖾𝗓𝗈𝗇𝖾 : <code>Asia/Kolkata</code>\n🛠️ 𝖡𝗎𝗂𝗅𝖽 𝖲𝗍𝖺𝗍𝗎𝗌 : <code>𝗏2.7.3 [ 𝖲𝗍𝖺𝖻𝗅𝖾 ]</code></b>\"\"\"\n\n    RESTART_GC_TXT = \"\"\"\n<b><u>𝖡𝗈𝗍 𝖱𝖾𝗌𝗍𝖺𝗋𝗍𝖾𝖽 ✅</u></b>\"\"\"\n\n    LOGO = \"\"\"\nPIRO BOTS\"\"\"\n"
  },
  {
    "path": "app.json",
    "content": "{\n    \"name\": \"PiroAutoFilterBot\",\n    \"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\",\n    \"stack\": \"container\",\n    \"keywords\": [\n      \"telegram\",\n      \"auto-filter\",\n      \"filter\",\n      \"best\",\n      \"indian\",\n      \"pyrogram\",\n      \"media\",\n      \"search\",\n      \"channel\",\n      \"index\",\n      \"inline\"\n    ],\n    \"website\": \"https://github.com/ritheshrkrm/PiroAutoFilterBot\",\n    \"repository\": \"https://github.com/ritheshrkrm/PiroAutoFilterBot\",\n    \"env\": {\n        \"BOT_TOKEN\": {\n            \"description\": \"Your bot token.\",\n            \"required\": true\n        },\n        \"API_ID\": {\n            \"description\": \"Get this value from https://my.telegram.org\",\n            \"required\": true\n        },\n        \"API_HASH\": {\n            \"description\": \"Get this value from https://my.telegram.org\",\n            \"required\": true\n        },\n        \"CHANNELS\": {\n            \"description\": \"Username or ID of channel or group. Separate multiple IDs by space.\",\n            \"required\": false\n        },\n        \"ADMINS\": {\n            \"description\": \"Username or ID of Admin. Separate multiple Admins by space.\",\n            \"required\": true\n        },\n        \"PICS\": {\n            \"description\": \"Add some telegraph link of pictures .\",\n            \"required\": false\n        },\n        \"LOG_CHANNEL\": {\n            \"description\": \"Bot Logs,Give a channel id with -100xxxxxxx\",\n            \"required\": true\n        },\n        \"AUTH_USERS\": {\n            \"description\": \"Username or ID of users to give access of inline search. Separate multiple users by space.\\nLeave it empty if you don't want to restrict bot usage.\",\n            \"required\": false\n        },\n        \"AUTH_CHANNEL\": {\n            \"description\": \"ID of channel.Make sure bot is admin in this channel. Without subscribing this channel users cannot use bot.\",\n            \"required\": false\n        },\n        \"DATABASE_URI\": {\n            \"description\": \"mongoDB URI. Get this value from https://www.mongodb.com. For more help watch this video - https://youtu.be/dsuTn4qV2GA\",\n            \"required\": true\n        },\n        \"DATABASE_NAME\": {\n            \"description\": \"Name of the database in mongoDB. For more help watch this video - https://youtu.be/dsuTn4qV2GA\",\n            \"required\": false\n        },\n        \"COLLECTION_NAME\": {\n            \"description\": \"Name of the collections. Defaults to Telegram_files. If you are using the same database, then use different collection name for each bot\",\n            \"value\": \"Telegram_files\",\n            \"required\": false\n        }\n    },\n    \"addons\": [],\n    \"buildpacks\": [{\n        \"url\": \"heroku/python\"\n    }],\n    \"formation\": {\n        \"worker\": {\n            \"quantity\": 1,\n            \"size\": \"free\"\n        }\n    }\n}\n"
  },
  {
    "path": "bot.py",
    "content": "import logging\nimport logging.config\n\n# Get logging configurations\nlogging.config.fileConfig('logging.conf')\nlogging.getLogger().setLevel(logging.INFO)\nlogging.getLogger(\"pyrogram\").setLevel(logging.ERROR)\nlogging.getLogger(\"imdbpy\").setLevel(logging.ERROR)\n\nfrom pyrogram import Client, __version__\nfrom pyrogram.raw.all import layer\nfrom database.ia_filterdb import Media\nfrom database.users_chats_db import db\nfrom info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_STR, LOG_CHANNEL, PORT ,SUPPORT_CHAT_ID\nfrom utils import temp\nfrom typing import Union, Optional, AsyncGenerator\nfrom pyrogram import types\nfrom Script import script \nfrom datetime import date, datetime \nimport pytz\nfrom aiohttp import web\nfrom plugins import web_server\n\nclass Bot(Client):\n\n    def __init__(self):\n        super().__init__(\n            name=SESSION,\n            api_id=API_ID,\n            api_hash=API_HASH,\n            bot_token=BOT_TOKEN,\n            workers=50,\n            plugins={\"root\": \"plugins\"},\n            sleep_threshold=5,\n        )\n\n    async def start(self):\n        b_users, b_chats = await db.get_banned()\n        temp.BANNED_USERS = b_users\n        temp.BANNED_CHATS = b_chats\n        await super().start()\n        await Media.ensure_indexes()\n        me = await self.get_me()\n        temp.ME = me.id\n        temp.U_NAME = me.username\n        temp.B_NAME = me.first_name\n        self.username = '@' + me.username\n        logging.info(f\"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.\")\n        logging.info(LOG_STR)\n        logging.info(script.LOGO)\n        tz = pytz.timezone('Asia/Kolkata')\n        today = date.today()\n        now = datetime.now(tz)\n        time = now.strftime(\"%H:%M:%S %p\")\n        await self.send_message(chat_id=LOG_CHANNEL, text=script.RESTART_TXT.format(today, time))\n        await self.send_message(chat_id=SUPPORT_CHAT_ID, text=script.RESTART_GC_TXT.format(today, time))\n        app = web.AppRunner(await web_server())\n        await app.setup()\n        bind_address = \"0.0.0.0\"\n        await web.TCPSite(app, bind_address, PORT).start()\n\n    async def stop(self, *args):\n        await super().stop()\n        logging.info(\"Bot stopped. Bye.\")\n\n    async def iter_messages(\n        self,\n        chat_id: Union[int, str],\n        limit: int,\n        offset: int = 0,\n    ) -> Optional[AsyncGenerator[\"types.Message\", None]]:\n        \"\"\"Iterate through a chat sequentially.\n        This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving\n        you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a\n        single call.\n        Parameters:\n            chat_id (``int`` | ``str``):\n                Unique identifier (int) or username (str) of the target chat.\n                For your personal cloud (Saved Messages) you can simply use \"me\" or \"self\".\n                For a contact that exists in your Telegram address book you can use his phone number (str).\n                \n            limit (``int``):\n                Identifier of the last message to be returned.\n                \n            offset (``int``, *optional*):\n                Identifier of the first message to be returned.\n                Defaults to 0.\n        Returns:\n            ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.\n        Example:\n            .. code-block:: python\n                for message in app.iter_messages(\"pyrogram\", 1, 15000):\n                    print(message.text)\n        \"\"\"\n        current = offset\n        while True:\n            new_diff = min(200, limit - current)\n            if new_diff <= 0:\n                return\n            messages = await self.get_messages(chat_id, list(range(current, current+new_diff+1)))\n            for message in messages:\n                yield message\n                current += 1\n\n\napp = Bot()\napp.run()\n"
  },
  {
    "path": "database/connections_mdb.py",
    "content": "import pymongo\n\nfrom info import DATABASE_URI, DATABASE_NAME\n\nimport logging\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.ERROR)\n\nmyclient = pymongo.MongoClient(DATABASE_URI)\nmydb = myclient[DATABASE_NAME]\nmycol = mydb['CONNECTION']   \n\n\nasync def add_connection(group_id, user_id):\n    query = mycol.find_one(\n        { \"_id\": user_id },\n        { \"_id\": 0, \"active_group\": 0 }\n    )\n    if query is not None:\n        group_ids = [x[\"group_id\"] for x in query[\"group_details\"]]\n        if group_id in group_ids:\n            return False\n\n    group_details = {\n        \"group_id\" : group_id\n    }\n\n    data = {\n        '_id': user_id,\n        'group_details' : [group_details],\n        'active_group' : group_id,\n    }\n\n    if mycol.count_documents( {\"_id\": user_id} ) == 0:\n        try:\n            mycol.insert_one(data)\n            return True\n        except:\n            logger.exception('Some error occurred!', exc_info=True)\n\n    else:\n        try:\n            mycol.update_one(\n                {'_id': user_id},\n                {\n                    \"$push\": {\"group_details\": group_details},\n                    \"$set\": {\"active_group\" : group_id}\n                }\n            )\n            return True\n        except:\n            logger.exception('Some error occurred!', exc_info=True)\n\n        \nasync def active_connection(user_id):\n\n    query = mycol.find_one(\n        { \"_id\": user_id },\n        { \"_id\": 0, \"group_details\": 0 }\n    )\n    if not query:\n        return None\n\n    group_id = query['active_group']\n    return int(group_id) if group_id != None else None\n\n\nasync def all_connections(user_id):\n    query = mycol.find_one(\n        { \"_id\": user_id },\n        { \"_id\": 0, \"active_group\": 0 }\n    )\n    if query is not None:\n        return [x[\"group_id\"] for x in query[\"group_details\"]]\n    else:\n        return None\n\n\nasync def if_active(user_id, group_id):\n    query = mycol.find_one(\n        { \"_id\": user_id },\n        { \"_id\": 0, \"group_details\": 0 }\n    )\n    return query is not None and query['active_group'] == group_id\n\n\nasync def make_active(user_id, group_id):\n    update = mycol.update_one(\n        {'_id': user_id},\n        {\"$set\": {\"active_group\" : group_id}}\n    )\n    return update.modified_count != 0\n\n\nasync def make_inactive(user_id):\n    update = mycol.update_one(\n        {'_id': user_id},\n        {\"$set\": {\"active_group\" : None}}\n    )\n    return update.modified_count != 0\n\n\nasync def delete_connection(user_id, group_id):\n\n    try:\n        update = mycol.update_one(\n            {\"_id\": user_id},\n            {\"$pull\" : { \"group_details\" : {\"group_id\":group_id} } }\n        )\n        if update.modified_count == 0:\n            return False\n        query = mycol.find_one(\n            { \"_id\": user_id },\n            { \"_id\": 0 }\n        )\n        if len(query[\"group_details\"]) >= 1:\n            if query['active_group'] == group_id:\n                prvs_group_id = query[\"group_details\"][len(query[\"group_details\"]) - 1][\"group_id\"]\n\n                mycol.update_one(\n                    {'_id': user_id},\n                    {\"$set\": {\"active_group\" : prvs_group_id}}\n                )\n        else:\n            mycol.update_one(\n                {'_id': user_id},\n                {\"$set\": {\"active_group\" : None}}\n            )\n        return True\n    except Exception as e:\n        logger.exception(f'Some error occurred! {e}', exc_info=True)\n        return False\n\n"
  },
  {
    "path": "database/filters_mdb.py",
    "content": "import pymongo\nfrom info import DATABASE_URI, DATABASE_NAME\nfrom pyrogram import enums\nimport logging\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.ERROR)\n\nmyclient = pymongo.MongoClient(DATABASE_URI)\nmydb = myclient[DATABASE_NAME]\n\n\n\nasync def add_filter(grp_id, text, reply_text, btn, file, alert):\n    mycol = mydb[str(grp_id)]\n    # mycol.create_index([('text', 'text')])\n\n    data = {\n        'text':str(text),\n        'reply':str(reply_text),\n        'btn':str(btn),\n        'file':str(file),\n        'alert':str(alert)\n    }\n\n    try:\n        mycol.update_one({'text': str(text)},  {\"$set\": data}, upsert=True)\n    except:\n        logger.exception('Some error occured!', exc_info=True)\n             \n     \nasync def find_filter(group_id, name):\n    mycol = mydb[str(group_id)]\n    \n    query = mycol.find( {\"text\":name})\n    # query = mycol.find( { \"$text\": {\"$search\": name}})\n    try:\n        for file in query:\n            reply_text = file['reply']\n            btn = file['btn']\n            fileid = file['file']\n            try:\n                alert = file['alert']\n            except:\n                alert = None\n        return reply_text, btn, alert, fileid\n    except:\n        return None, None, None, None\n\n\nasync def get_filters(group_id):\n    mycol = mydb[str(group_id)]\n\n    texts = []\n    query = mycol.find()\n    try:\n        for file in query:\n            text = file['text']\n            texts.append(text)\n    except:\n        pass\n    return texts\n\n\nasync def delete_filter(message, text, group_id):\n    mycol = mydb[str(group_id)]\n    \n    myquery = {'text':text }\n    query = mycol.count_documents(myquery)\n    if query == 1:\n        mycol.delete_one(myquery)\n        await message.reply_text(\n            f\"'`{text}`'  deleted. I'll not respond to that filter anymore.\",\n            quote=True,\n            parse_mode=enums.ParseMode.MARKDOWN\n        )\n    else:\n        await message.reply_text(\"Couldn't find that filter!\", quote=True)\n\n\nasync def del_all(message, group_id, title):\n    if str(group_id) not in mydb.list_collection_names():\n        await message.edit_text(f\"Nothing to remove in {title}!\")\n        return\n\n    mycol = mydb[str(group_id)]\n    try:\n        mycol.drop()\n        await message.edit_text(f\"All filters from {title} has been removed\")\n    except:\n        await message.edit_text(\"Couldn't remove all filters from group!\")\n        return\n\n\nasync def count_filters(group_id):\n    mycol = mydb[str(group_id)]\n\n    count = mycol.count()\n    return False if count == 0 else count\n\n\nasync def filter_stats():\n    collections = mydb.list_collection_names()\n\n    if \"CONNECTION\" in collections:\n        collections.remove(\"CONNECTION\")\n\n    totalcount = 0\n    for collection in collections:\n        mycol = mydb[collection]\n        count = mycol.count()\n        totalcount += count\n\n    totalcollections = len(collections)\n\n    return totalcollections, totalcount\n"
  },
  {
    "path": "database/gfilters_mdb.py",
    "content": "import pymongo\r\nfrom info import DATABASE_URI, DATABASE_NAME\r\nfrom pyrogram import enums\r\nimport logging\r\nlogger = logging.getLogger(__name__)\r\nlogger.setLevel(logging.ERROR)\r\n\r\nmyclient = pymongo.MongoClient(DATABASE_URI)\r\nmydb = myclient[DATABASE_NAME]\r\n\r\n\r\n\r\nasync def add_gfilter(gfilters, text, reply_text, btn, file, alert):\r\n    mycol = mydb[str(gfilters)]\r\n\r\n    data = {\r\n        'text':str(text),\r\n        'reply':str(reply_text),\r\n        'btn':str(btn),\r\n        'file':str(file),\r\n        'alert':str(alert)\r\n    }\r\n\r\n    try:\r\n        mycol.update_one({'text': str(text)},  {\"$set\": data}, upsert=True)\r\n    except:\r\n        logger.exception('Some error occured!', exc_info=True)\r\n             \r\n     \r\nasync def find_gfilter(gfilters, name):\r\n    mycol = mydb[str(gfilters)]\r\n    \r\n    query = mycol.find( {\"text\":name})\r\n    # query = mycol.find( { \"$text\": {\"$search\": name}})\r\n    try:\r\n        for file in query:\r\n            reply_text = file['reply']\r\n            btn = file['btn']\r\n            fileid = file['file']\r\n            try:\r\n                alert = file['alert']\r\n            except:\r\n                alert = None\r\n        return reply_text, btn, alert, fileid\r\n    except:\r\n        return None, None, None, None\r\n\r\n\r\nasync def get_gfilters(gfilters):\r\n    mycol = mydb[str(gfilters)]\r\n\r\n    texts = []\r\n    query = mycol.find()\r\n    try:\r\n        for file in query:\r\n            text = file['text']\r\n            texts.append(text)\r\n    except:\r\n        pass\r\n    return texts\r\n\r\n\r\nasync def delete_gfilter(message, text, gfilters):\r\n    mycol = mydb[str(gfilters)]\r\n    \r\n    myquery = {'text':text }\r\n    query = mycol.count_documents(myquery)\r\n    if query == 1:\r\n        mycol.delete_one(myquery)\r\n        await message.reply_text(\r\n            f\"'`{text}`'  deleted. I'll not respond to that gfilter anymore.\",\r\n            quote=True,\r\n            parse_mode=enums.ParseMode.MARKDOWN\r\n        )\r\n    else:\r\n        await message.reply_text(\"Couldn't find that gfilter!\", quote=True)\r\n\r\nasync def del_allg(message, gfilters):\r\n    if str(gfilters) not in mydb.list_collection_names():\r\n        await message.edit_text(\"Nothing to Remove !\")\r\n        return\r\n\r\n    mycol = mydb[str(gfilters)]\r\n    try:\r\n        mycol.drop()\r\n        await message.edit_text(f\"All gfilters has been removed !\")\r\n    except:\r\n        await message.edit_text(\"Couldn't remove all gfilters !\")\r\n        return\r\n\r\nasync def count_gfilters(gfilters):\r\n    mycol = mydb[str(gfilters)]\r\n\r\n    count = mycol.count()\r\n    return False if count == 0 else count\r\n\r\n\r\nasync def gfilter_stats():\r\n    collections = mydb.list_collection_names()\r\n\r\n    if \"CONNECTION\" in collections:\r\n        collections.remove(\"CONNECTION\")\r\n\r\n    totalcount = 0\r\n    for collection in collections:\r\n        mycol = mydb[collection]\r\n        count = mycol.count()\r\n        totalcount += count\r\n\r\n    totalcollections = len(collections)\r\n\r\n    return totalcollections, totalcount\r\n"
  },
  {
    "path": "database/ia_filterdb.py",
    "content": "import logging\nfrom struct import pack\nimport re\nimport base64\nfrom pyrogram.file_id import FileId\nfrom pymongo.errors import DuplicateKeyError\nfrom umongo import Instance, Document, fields\nfrom motor.motor_asyncio import AsyncIOMotorClient\nfrom marshmallow.exceptions import ValidationError\nfrom info import DATABASE_URI, DATABASE_NAME, COLLECTION_NAME, USE_CAPTION_FILTER, MAX_B_TN\nfrom utils import get_settings, save_group_settings\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.INFO)\n\n\nclient = AsyncIOMotorClient(DATABASE_URI)\ndb = client[DATABASE_NAME]\ninstance = Instance.from_db(db)\n\n@instance.register\nclass Media(Document):\n    file_id = fields.StrField(attribute='_id')\n    file_ref = fields.StrField(allow_none=True)\n    file_name = fields.StrField(required=True)\n    file_size = fields.IntField(required=True)\n    file_type = fields.StrField(allow_none=True)\n    mime_type = fields.StrField(allow_none=True)\n    caption = fields.StrField(allow_none=True)\n\n    class Meta:\n        indexes = ('$file_name', )\n        collection_name = COLLECTION_NAME\n\n\nasync def save_file(media):\n    \"\"\"Save file in database\"\"\"\n\n    # TODO: Find better way to get same file_id for same media to avoid duplicates\n    file_id, file_ref = unpack_new_file_id(media.file_id)\n    file_name = re.sub(r\"(_|\\-|\\.|\\+)\", \" \", str(media.file_name))\n    try:\n        file = Media(\n            file_id=file_id,\n            file_ref=file_ref,\n            file_name=file_name,\n            file_size=media.file_size,\n            file_type=media.file_type,\n            mime_type=media.mime_type,\n            caption=media.caption.html if media.caption else None,\n        )\n    except ValidationError:\n        logger.exception('Error occurred while saving file in database')\n        return False, 2\n    else:\n        try:\n            await file.commit()\n        except DuplicateKeyError:      \n            logger.warning(\n                f'{getattr(media, \"file_size\", \"NO_FILE\")} is already saved in database'\n            )\n\n            return False, 0\n        else:\n            logger.info(f'{getattr(media, \"file_size\", \"NO_FILE\")} is saved to database')\n            return True, 1\n\n\n\nasync def get_search_results(chat_id, query, file_type=None, max_results=10, offset=0, filter=False):\n    \"\"\"For given query return (results, next_offset)\"\"\"\n    if chat_id is not None:\n        settings = await get_settings(int(chat_id))\n        try:\n            if settings['max_btn']:\n                max_results = 10\n            else:\n                max_results = int(MAX_B_TN)\n        except KeyError:\n            await save_group_settings(int(chat_id), 'max_btn', False)\n            settings = await get_settings(int(chat_id))\n            if settings['max_btn']:\n                max_results = 10\n            else:\n                max_results = int(MAX_B_TN)\n    query = query.strip()\n    #if filter:\n        #better ?\n        #query = query.replace(' ', r'(\\s|\\.|\\+|\\-|_)')\n        #raw_pattern = r'(\\s|_|\\-|\\.|\\+)' + query + r'(\\s|_|\\-|\\.|\\+)'\n    if not query:\n        raw_pattern = '.'\n    elif ' ' not in query:\n        raw_pattern = r'(\\b|[\\.\\+\\-_])' + query + r'(\\b|[\\.\\+\\-_])'\n    else:\n        raw_pattern = query.replace(' ', r'.*[\\s\\.\\+\\-_]')\n    \n    try:\n        regex = re.compile(raw_pattern, flags=re.IGNORECASE)\n    except:\n        return []\n\n    if USE_CAPTION_FILTER:\n        filter = {'$or': [{'file_name': regex}, {'caption': regex}]}\n    else:\n        filter = {'file_name': regex}\n\n    if file_type:\n        filter['file_type'] = file_type\n\n    total_results = await Media.count_documents(filter)\n    next_offset = offset + max_results\n\n    if next_offset > total_results:\n        next_offset = ''\n\n    cursor = Media.find(filter)\n    # Sort by recent\n    cursor.sort('$natural', -1)\n    # Slice files according to offset and max results\n    cursor.skip(offset).limit(max_results)\n    # Get list of files\n    files = await cursor.to_list(length=max_results)\n\n    return files, next_offset, total_results\n\nasync def get_bad_files(query, file_type=None, filter=False):\n    \"\"\"For given query return (results, next_offset)\"\"\"\n    query = query.strip()\n    #if filter:\n        #better ?\n        #query = query.replace(' ', r'(\\s|\\.|\\+|\\-|_)')\n        #raw_pattern = r'(\\s|_|\\-|\\.|\\+)' + query + r'(\\s|_|\\-|\\.|\\+)'\n    if not query:\n        raw_pattern = '.'\n    elif ' ' not in query:\n        raw_pattern = r'(\\b|[\\.\\+\\-_])' + query + r'(\\b|[\\.\\+\\-_])'\n    else:\n        raw_pattern = query.replace(' ', r'.*[\\s\\.\\+\\-_]')\n    \n    try:\n        regex = re.compile(raw_pattern, flags=re.IGNORECASE)\n    except:\n        return []\n\n    if USE_CAPTION_FILTER:\n        filter = {'$or': [{'file_name': regex}, {'caption': regex}]}\n    else:\n        filter = {'file_name': regex}\n\n    if file_type:\n        filter['file_type'] = file_type\n\n    total_results = await Media.count_documents(filter)\n\n    cursor = Media.find(filter)\n    # Sort by recent\n    cursor.sort('$natural', -1)\n    # Get list of files\n    files = await cursor.to_list(length=total_results)\n\n    return files, total_results\n\nasync def get_file_details(query):\n    filter = {'file_id': query}\n    cursor = Media.find(filter)\n    filedetails = await cursor.to_list(length=1)\n    return filedetails\n\n\ndef encode_file_id(s: bytes) -> str:\n    r = b\"\"\n    n = 0\n\n    for i in s + bytes([22]) + bytes([4]):\n        if i == 0:\n            n += 1\n        else:\n            if n:\n                r += b\"\\x00\" + bytes([n])\n                n = 0\n\n            r += bytes([i])\n\n    return base64.urlsafe_b64encode(r).decode().rstrip(\"=\")\n\n\ndef encode_file_ref(file_ref: bytes) -> str:\n    return base64.urlsafe_b64encode(file_ref).decode().rstrip(\"=\")\n\n\ndef unpack_new_file_id(new_file_id):\n    \"\"\"Return file_id, file_ref\"\"\"\n    decoded = FileId.decode(new_file_id)\n    file_id = encode_file_id(\n        pack(\n            \"<iiqq\",\n            int(decoded.file_type),\n            decoded.dc_id,\n            decoded.media_id,\n            decoded.access_hash\n        )\n    )\n    file_ref = encode_file_ref(decoded.file_reference)\n    return file_id, file_ref"
  },
  {
    "path": "database/users_chats_db.py",
    "content": "import motor.motor_asyncio\nfrom info import DATABASE_NAME, DATABASE_URI, IMDB, IMDB_TEMPLATE, MELCOW_NEW_USERS, P_TTI_SHOW_OFF, SINGLE_BUTTON, SPELL_CHECK_REPLY, PROTECT_CONTENT, AUTO_DELETE, AUTO_FFILTER, MAX_BTN\n\nclass Database:\n    \n    def __init__(self, uri, database_name):\n        self._client = motor.motor_asyncio.AsyncIOMotorClient(uri)\n        self.db = self._client[database_name]\n        self.col = self.db.users\n        self.grp = self.db.groups\n\n\n    def new_user(self, id, name):\n        return dict(\n            id = id,\n            name = name,\n            ban_status=dict(\n                is_banned=False,\n                ban_reason=\"\",\n            ),\n        )\n\n\n    def new_group(self, id, title):\n        return dict(\n            id = id,\n            title = title,\n            chat_status=dict(\n                is_disabled=False,\n                reason=\"\",\n            ),\n        )\n    \n    async def add_user(self, id, name):\n        user = self.new_user(id, name)\n        await self.col.insert_one(user)\n    \n    async def is_user_exist(self, id):\n        user = await self.col.find_one({'id':int(id)})\n        return bool(user)\n    \n    async def total_users_count(self):\n        count = await self.col.count_documents({})\n        return count\n    \n    async def remove_ban(self, id):\n        ban_status = dict(\n            is_banned=False,\n            ban_reason=''\n        )\n        await self.col.update_one({'id': id}, {'$set': {'ban_status': ban_status}})\n    \n    async def ban_user(self, user_id, ban_reason=\"No Reason\"):\n        ban_status = dict(\n            is_banned=True,\n            ban_reason=ban_reason\n        )\n        await self.col.update_one({'id': user_id}, {'$set': {'ban_status': ban_status}})\n\n    async def get_ban_status(self, id):\n        default = dict(\n            is_banned=False,\n            ban_reason=''\n        )\n        user = await self.col.find_one({'id':int(id)})\n        if not user:\n            return default\n        return user.get('ban_status', default)\n\n    async def get_all_users(self):\n        return self.col.find({})\n    \n\n    async def delete_user(self, user_id):\n        await self.col.delete_many({'id': int(user_id)})\n\n\n    async def get_banned(self):\n        users = self.col.find({'ban_status.is_banned': True})\n        chats = self.grp.find({'chat_status.is_disabled': True})\n        b_chats = [chat['id'] async for chat in chats]\n        b_users = [user['id'] async for user in users]\n        return b_users, b_chats\n    \n\n\n    async def add_chat(self, chat, title):\n        chat = self.new_group(chat, title)\n        await self.grp.insert_one(chat)\n    \n\n    async def get_chat(self, chat):\n        chat = await self.grp.find_one({'id':int(chat)})\n        return False if not chat else chat.get('chat_status')\n    \n\n    async def re_enable_chat(self, id):\n        chat_status=dict(\n            is_disabled=False,\n            reason=\"\",\n            )\n        await self.grp.update_one({'id': int(id)}, {'$set': {'chat_status': chat_status}})\n        \n    async def update_settings(self, id, settings):\n        await self.grp.update_one({'id': int(id)}, {'$set': {'settings': settings}})\n        \n    \n    async def get_settings(self, id):\n        default = {\n            'button': SINGLE_BUTTON,\n            'botpm': P_TTI_SHOW_OFF,\n            'file_secure': PROTECT_CONTENT,\n            'imdb': IMDB,\n            'spell_check': SPELL_CHECK_REPLY,\n            'welcome': MELCOW_NEW_USERS,\n            'auto_delete': AUTO_DELETE,\n            'auto_ffilter': AUTO_FFILTER,\n            'max_btn': MAX_BTN,\n            'template': IMDB_TEMPLATE\n        }\n        chat = await self.grp.find_one({'id':int(id)})\n        if chat:\n            return chat.get('settings', default)\n        return default\n    \n\n    async def disable_chat(self, chat, reason=\"No Reason\"):\n        chat_status=dict(\n            is_disabled=True,\n            reason=reason,\n            )\n        await self.grp.update_one({'id': int(chat)}, {'$set': {'chat_status': chat_status}})\n    \n\n    async def total_chat_count(self):\n        count = await self.grp.count_documents({})\n        return count\n    \n\n    async def get_all_chats(self):\n        return self.grp.find({})\n\n\n    async def get_db_size(self):\n        return (await self.db.command(\"dbstats\"))['dataSize']\n\n\ndb = Database(DATABASE_URI, DATABASE_NAME)\n"
  },
  {
    "path": "docker-compose.yml",
    "content": "version: \"3.10\"\r\nservices:\r\n   worker:\r\n    build: .\r\n    environment:\r\n      BOT_TOKEN: $BOT_TOKEN\r\n      API_ID: $API_ID\r\n      API_HASH: $API_HASH\r\n      CHANNELS: $CHANNELS\r\n      ADMINS: $ADMINS\r\n      LOG_CHANNEL: $LOG_CHANNEL\r\n      DATABASE_NAME: $DATABASE_NAME\r\n      DATABASE_URI: $DATABASE_URI\r\n      HEROKU_API_KEY: $HEROKU_API_KEY\r\n"
  },
  {
    "path": "heroku.yml",
    "content": "build:\n  docker:\n      worker: Dockerfile"
  },
  {
    "path": "info.py",
    "content": "import re\nfrom os import environ\nimport asyncio\nimport json\nfrom collections import defaultdict\nfrom typing import Dict, List, Union\nfrom pyrogram import Client\nfrom time import time\n\nid_pattern = re.compile(r'^.\\d+$')\ndef is_enabled(value, default):\n    if value.strip().lower() in [\"on\", \"true\", \"yes\", \"1\", \"enable\", \"y\"]:\n        return True\n    elif value.strip().lower() in [\"off\", \"false\", \"no\", \"0\", \"disable\", \"n\"]:\n        return False\n    else:\n        return default\n\n# Bot information\nSESSION = environ.get('SESSION', 'Media_search')\nAPI_ID = int(environ.get('API_ID', ''))\nAPI_HASH = environ.get('API_HASH', '')\nBOT_TOKEN = environ.get('BOT_TOKEN', '')\nPORT = environ.get(\"PORT\", \"8080\")\n\n# Bot settings\nCACHE_TIME = int(environ.get('CACHE_TIME', 300))\nUSE_CAPTION_FILTER = bool(environ.get('USE_CAPTION_FILTER', True))\nBOT_START_TIME = time()\n\n# Bot images & videos\nPICS = (environ.get('PICS', 'https://telegra.ph/file/5553dc39f968b364d4856.jpg')).split()\nREQ_PICS = (environ.get('REQ_PICS', 'https://graph.org/file/5cb80fa6096997b7226b3.jpg')).split()\nNOR_IMG = environ.get(\"NOR_IMG\", \"https://telegra.ph/file/0593a3103ba1b9a5855bf.jpg\")\nMELCOW_VID = environ.get(\"MELCOW_VID\", \"https://graph.org/file/72dff2b65352ba85d0a34.mp4\")\nSPELL_IMG = environ.get(\"SPELL_IMG\", \"https://telegra.ph/file/2a888a370f479f4338f7c.jpg\")\n\n# Admins, Channels & Users\nADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()]\nCHANNELS = [int(ch) if id_pattern.search(ch) else ch for ch in environ.get('CHANNELS', '0').split()]\nauth_users = [int(user) if id_pattern.search(user) else user for user in environ.get('AUTH_USERS', '').split()]\nAUTH_USERS = (auth_users + ADMINS) if auth_users else []\nauth_channel = environ.get('AUTH_CHANNEL')\nauth_grp = environ.get('AUTH_GROUP')\nAUTH_CHANNEL = int(auth_channel) if auth_channel and id_pattern.search(auth_channel) else None\nAUTH_GROUPS = [int(ch) for ch in auth_grp.split()] if auth_grp else None\nsupport_chat_id = environ.get('SUPPORT_CHAT_ID')\nreqst_channel = environ.get('REQST_CHANNEL_ID')\nREQST_CHANNEL = int(reqst_channel) if reqst_channel and id_pattern.search(reqst_channel) else None\nSUPPORT_CHAT_ID = -1001792675255\nNO_RESULTS_MSG = bool(environ.get(\"NO_RESULTS_MSG\", False))\n\n# MongoDB information\nDATABASE_URI = environ.get('DATABASE_URI', \"\")\nDATABASE_NAME = environ.get('DATABASE_NAME', \"PIRO\")\nCOLLECTION_NAME = environ.get('COLLECTION_NAME', 'FILES')\n\n# Others\nDELETE_CHANNELS = [int(dch) if id_pattern.search(dch) else dch for dch in environ.get('DELETE_CHANNELS', '0').split()]\nMAX_B_TN = environ.get(\"MAX_B_TN\", \"10\")\nMAX_BTN = is_enabled((environ.get('MAX_BTN', \"True\")), True)\nLOG_CHANNEL = int(environ.get('LOG_CHANNEL', 0))\nSUPPORT_CHAT = environ.get('SUPPORT_CHAT', 'raixchat')\nP_TTI_SHOW_OFF = is_enabled((environ.get('P_TTI_SHOW_OFF', \"True\")), False)\nIMDB = is_enabled((environ.get('IMDB', \"False\")), True)\nAUTO_FFILTER = is_enabled((environ.get('AUTO_FFILTER', \"True\")), True)\nAUTO_DELETE = is_enabled((environ.get('AUTO_DELETE', \"True\")), True)\nSINGLE_BUTTON = is_enabled((environ.get('SINGLE_BUTTON', \"True\")), True)\nCUSTOM_FILE_CAPTION = environ.get(\"CUSTOM_FILE_CAPTION\", '📂 <b>File Name</b>: <code>{file_name}</code> \\n\\n❤️‍🔥 <b>Join</b> [𝗕𝗟𝗔𝗦𝗧𝗘𝗥 𝗟𝗜𝗡𝗞𝗭](https://t.me/blaster_linkz)')\nBATCH_FILE_CAPTION = environ.get(\"BATCH_FILE_CAPTION\", '')\nIMDB_TEMPLATE = environ.get(\"IMDB_TEMPLATE\", '🏷 𝖳𝗂𝗍𝗅𝖾: <a href={url}>{title}</a> \\n🔮 𝖸𝖾𝖺𝗋: {year} \\n⭐️ 𝖱𝖺𝗍𝗂𝗇𝗀𝗌: {rating}/ 10  \\n🎭 𝖦𝖾𝗇𝖾𝗋𝗌: {genres} \\n\\n🎊 𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖡𝗒 [[𝖯𝖨𝖱𝖮]](t.me/piroxbots)')\nLONG_IMDB_DESCRIPTION = is_enabled(environ.get(\"LONG_IMDB_DESCRIPTION\", \"False\"), False)\nSPELL_CHECK_REPLY = is_enabled(environ.get(\"SPELL_CHECK_REPLY\", \"True\"), True)\nMAX_LIST_ELM = environ.get(\"MAX_LIST_ELM\", None)\nINDEX_REQ_CHANNEL = int(environ.get('INDEX_REQ_CHANNEL', LOG_CHANNEL))\nFILE_STORE_CHANNEL = [int(ch) for ch in (environ.get('FILE_STORE_CHANNEL', '')).split()]\nMELCOW_NEW_USERS = is_enabled((environ.get('MELCOW_NEW_USERS', \"True\")), True)\nPROTECT_CONTENT = is_enabled((environ.get('PROTECT_CONTENT', \"False\")), False)\nPUBLIC_FILE_STORE = is_enabled((environ.get('PUBLIC_FILE_STORE', \"False\")), True)\n\nLOG_STR = \"Current Cusomized Configurations are:-\\n\"\nLOG_STR += (\"IMDB Results are enabled, Bot will be showing imdb details for you queries.\\n\" if IMDB else \"IMBD Results are disabled.\\n\")\nLOG_STR += (\"P_TTI_SHOW_OFF found , Users will be redirected to send /start to Bot PM instead of sending file file directly\\n\" if P_TTI_SHOW_OFF else \"P_TTI_SHOW_OFF is disabled files will be send in PM, instead of sending start.\\n\")\nLOG_STR += (\"SINGLE_BUTTON is Found, filename and files size will be shown in a single button instead of two separate buttons\\n\" if SINGLE_BUTTON else \"SINGLE_BUTTON is disabled , filename and file_sixe will be shown as different buttons\\n\")\nLOG_STR += (f\"CUSTOM_FILE_CAPTION enabled with value {CUSTOM_FILE_CAPTION}, your files will be send along with this customized caption.\\n\" if CUSTOM_FILE_CAPTION else \"No CUSTOM_FILE_CAPTION Found, Default captions of file will be used.\\n\")\nLOG_STR += (\"Long IMDB storyline enabled.\" if LONG_IMDB_DESCRIPTION else \"LONG_IMDB_DESCRIPTION is disabled , Plot will be shorter.\\n\")\nLOG_STR += (\"Spell Check Mode Is Enabled, bot will be suggesting related movies if movie not found\\n\" if SPELL_CHECK_REPLY else \"SPELL_CHECK_REPLY Mode disabled\\n\")\nLOG_STR += (f\"MAX_LIST_ELM Found, long list will be shortened to first {MAX_LIST_ELM} elements\\n\" if MAX_LIST_ELM else \"Full List of casts and crew will be shown in imdb template, restrict them by adding a value to MAX_LIST_ELM\\n\")\nLOG_STR += f\"Your current IMDB template is {IMDB_TEMPLATE}\"\n"
  },
  {
    "path": "logging.conf",
    "content": "[loggers]\nkeys=root\n\n[handlers]\nkeys=consoleHandler,fileHandler\n\n[formatters]\nkeys=consoleFormatter,fileFormatter\n\n[logger_root]\nlevel=DEBUG\nhandlers=consoleHandler,fileHandler\n\n[handler_consoleHandler]\nclass=StreamHandler\nlevel=INFO\nformatter=consoleFormatter\nargs=(sys.stdout,)\n\n[handler_fileHandler]\nclass=FileHandler\nlevel=ERROR\nformatter=fileFormatter\nargs=('Logs.txt','w',)\n\n[formatter_consoleFormatter]\nformat=%(asctime)s - %(lineno)d - %(name)s - %(module)s - %(levelname)s - %(message)s\ndatefmt=%I:%M:%S %p\n\n[formatter_fileFormatter]\nformat=[%(asctime)s:%(name)s:%(lineno)d:%(levelname)s] %(message)s\ndatefmt=%m/%d/%Y %I:%M:%S %p"
  },
  {
    "path": "plugins/__init__.py",
    "content": "from aiohttp import web\r\nfrom .route import routes\r\n\r\n\r\nasync def web_server():\r\n    web_app = web.Application(client_max_size=30000000)\r\n    web_app.add_routes(routes)\r\n    return web_app"
  },
  {
    "path": "plugins/approve.py",
    "content": "from pyrogram import Client\r\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup\r\nfrom pyrogram.errors import UserIsBlocked, PeerIdInvalid\r\n\r\n\r\n@Client.on_chat_join_request()\r\nasync def accept_request(client, r):\r\n\r\n    rm = InlineKeyboardMarkup([[\r\n        InlineKeyboardButton(\"❤️‍🔥 𝖡𝖫𝖠𝖲𝖳𝖤𝖱 𝖧𝖴𝖡 ❤️‍🔥\", url=f\"https://t.me/blaster_hub\"),\r\n        InlineKeyboardButton(\"⚡𝖴𝗉𝖽𝖺𝗍𝖾𝗌 ⚡\", url=f\"https://t.me/piroxbots\")\r\n    ]])\r\n    \r\n    try:\r\n        await client.send_photo(\r\n            r.from_user.id,\r\n            'https://graph.org/file/5cb80fa6096997b7226b3.jpg',\r\n            f\"**𝖧𝖾𝗅𝗅𝗈 {r.from_user.mention} 👻, 𝖶𝖾𝗅𝖼𝗈𝗆𝖾 𝖳𝗈 {r.chat.title}\\n𝖸𝗈𝗎𝗋 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 𝖧𝖺𝗌 𝖡𝖾𝖾𝗇 𝖠𝗉𝗉𝗋𝗈𝗏𝖾𝖽...!!!**\",\r\n            reply_markup=rm)\r\n\r\n    except UserIsBlocked:\r\n        print(\"User blocked the bot\")\r\n    except PeerIdInvalid:\r\n        print(\"Err\")\r\n    except Exception as e:\r\n        print(f\"#Error\\n{str(e)}\")\r\n\r\n    await r.approve()\r\n"
  },
  {
    "path": "plugins/banned.py",
    "content": "from pyrogram import Client, filters\r\nfrom utils import temp\r\nfrom pyrogram.types import Message\r\nfrom database.users_chats_db import db\r\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup\r\nfrom info import SUPPORT_CHAT\r\n\r\nasync def banned_users(_, client, message: Message):\r\n    return (\r\n        message.from_user is not None or not message.sender_chat\r\n    ) and message.from_user.id in temp.BANNED_USERS\r\n\r\nbanned_user = filters.create(banned_users)\r\n\r\nasync def disabled_chat(_, client, message: Message):\r\n    return message.chat.id in temp.BANNED_CHATS\r\n\r\ndisabled_group=filters.create(disabled_chat)\r\n\r\n\r\n@Client.on_message(filters.private & banned_user & filters.incoming)\r\nasync def ban_reply(bot, message):\r\n    ban = await db.get_ban_status(message.from_user.id)\r\n    await message.reply(f'<b>‼️Sorry Dude, You are Banned to use Me.‼️</b> \\n\\nBan Reason: {ban[\"ban_reason\"]}')\r\n\r\n@Client.on_message(filters.group & disabled_group & filters.incoming)\r\nasync def grp_bd(bot, message):\r\n    buttons = [[\r\n        InlineKeyboardButton('🧩 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 🧩', url=f\"https://t.me/{SUPPORT_CHAT}\")\r\n    ]]\r\n    reply_markup=InlineKeyboardMarkup(buttons)\r\n    vazha = await db.get_chat(message.chat.id)\r\n    k = await message.reply(\r\n        text=f\"<b>CHAT NOT ALLOWED 🐞</b>\\n\\nMy admins has restricted me from working here ! If you want to know more about it contact 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 GROUP..\\nReason : <code>{vazha['reason']}</code>.\",\r\n        reply_markup=reply_markup)\r\n    try:\r\n        await k.pin()\r\n    except:\r\n        pass\r\n    await bot.leave_chat(message.chat.id)\r\n"
  },
  {
    "path": "plugins/broadcast.py",
    "content": "from pyrogram import Client, filters\nimport datetime\nimport time\nfrom database.users_chats_db import db\nfrom info import ADMINS\nfrom utils import broadcast_messages, broadcast_messages_group\nimport asyncio\n        \n@Client.on_message(filters.command(\"broadcast\") & filters.user(ADMINS) & filters.reply)\nasync def verupikkals(bot, message):\n    users = await db.get_all_users()\n    b_msg = message.reply_to_message\n    sts = await message.reply_text(\n        text='🔊 Broadcasting your messages...'\n    )\n    start_time = time.time()\n    total_users = await db.total_users_count()\n    done = 0\n    blocked = 0\n    deleted = 0\n    failed =0\n\n    success = 0\n    async for user in users:\n        pti, sh = await broadcast_messages(int(user['id']), b_msg)\n        if pti:\n            success += 1\n        elif pti == False:\n            if sh == \"Blocked\":\n                blocked+=1\n            elif sh == \"Deleted\":\n                deleted += 1\n            elif sh == \"Error\":\n                failed += 1\n        done += 1\n        await asyncio.sleep(2)\n        if not done % 20:\n            await sts.edit(f\"Broadcast in progress:\\n\\nTotal Users {total_users}\\nCompleted: {done} / {total_users}\\nSuccess: {success}\\nBlocked: {blocked}\\nDeleted: {deleted}\")    \n    time_taken = datetime.timedelta(seconds=int(time.time()-start_time))\n    await sts.edit(f\"Broadcast Completed:\\nCompleted in {time_taken} seconds.\\n\\nTotal Users {total_users}\\nCompleted: {done} / {total_users}\\nSuccess: {success}\\nBlocked: {blocked}\\nDeleted: {deleted}\")\n\n@Client.on_message(filters.command(\"group_broadcast\") & filters.user(ADMINS) & filters.reply)\nasync def broadcast_group(bot, message):\n    groups = await db.get_all_chats()\n    b_msg = message.reply_to_message\n    sts = await message.reply_text(\n        text='🔊 Broadcasting your messages To Groups...'\n    )\n    start_time = time.time()\n    total_groups = await db.total_chat_count()\n    done = 0\n    failed =0\n\n    success = 0\n    async for group in groups:\n        pti, sh = await broadcast_messages_group(int(group['id']), b_msg)\n        if pti:\n            success += 1\n        elif sh == \"Error\":\n                failed += 1\n        done += 1\n        if not done % 20:\n            await sts.edit(f\"Broadcast in progress:\\n\\nTotal Groups {total_groups}\\nCompleted: {done} / {total_groups}\\nSuccess: {success}\")    \n    time_taken = datetime.timedelta(seconds=int(time.time()-start_time))\n    await sts.edit(f\"Broadcast Completed:\\nCompleted in {time_taken} seconds.\\n\\nTotal Groups {total_groups}\\nCompleted: {done} / {total_groups}\\nSuccess: {success}\")\n"
  },
  {
    "path": "plugins/channel.py",
    "content": "from pyrogram import Client, filters\nfrom info import CHANNELS\nfrom database.ia_filterdb import save_file\n\nmedia_filter = filters.document | filters.video\n\n\n@Client.on_message(filters.chat(CHANNELS) & media_filter)\nasync def media(bot, message):\n    \"\"\"Media Handler\"\"\"\n    for file_type in (\"document\", \"video\"):\n        media = getattr(message, file_type, None)\n        if media is not None:\n            break\n    else:\n        return\n\n    media.file_type = file_type\n    media.caption = message.caption\n    await save_file(media)"
  },
  {
    "path": "plugins/check_alive.py",
    "content": "import random\r\nimport re, asyncio, time, shutil, psutil, os, sys\r\nfrom pyrogram import Client, filters, enums\r\nfrom pyrogram.types import *\r\nfrom info import BOT_START_TIME, ADMINS\r\nfrom utils import humanbytes  \r\n\r\nCMD = [\"/\", \".\"]\r\n\r\n@Client.on_message(filters.command(\"alive\", CMD))\r\nasync def check_alive(_, message):\r\n    await message.reply_text(\"𝖡𝗎𝖽𝖽𝗒 𝖨𝖺𝗆 𝖠𝗅𝗂𝗏𝖾 :) 𝖧𝗂𝗍 /start \\n\\n𝖧𝗂𝗍 /help 𝖥𝗈𝗋 𝖧𝖾𝗅𝗉 ;)\\n\\n\\n𝖧𝗂𝗍 /ping 𝖳𝗈 𝖢𝗁𝖾𝖼𝗄 𝖡𝗈𝗍 𝖯𝗂𝗇𝗀 😁\")\r\n\r\n@Client.on_message(filters.command(\"help\", CMD))\r\nasync def help(_, message):\r\n    await message.reply_text(\"𝖧𝗂𝗍 /movie 𝖥𝗈𝗋 𝖬𝗈𝗏𝗂𝖾 𝖲𝖾𝖺𝗋𝖼𝗁 𝖱𝗎𝗅𝖾𝗌 📃\\n\\n𝖧𝗂𝗍 /series 𝖥𝗈𝗋 𝖲𝖾𝗋𝗂𝖾𝗌 𝖲𝖾𝖺𝗋𝖼𝗁 𝖱𝗎𝗅𝖾𝗌 📃\\n\\n\\n𝖧𝗂𝗍 /tutorial 𝖥𝗈𝗋 𝖯𝗋𝗈𝗉𝖾𝗋 𝖳𝗎𝗍𝗈𝗋𝗂𝖺𝗅 𝖵𝗂𝖽𝖾𝗈𝗌 🤗\")\r\n\r\n\r\n@Client.on_message(filters.command(\"movie\", CMD))\r\nasync def movie(_, message):\r\n    await message.reply_text(\"⚠️❗️ 𝗠𝗼𝘃𝗶𝗲 𝗥𝗲𝗾𝘂𝗲𝘀𝘁 𝗙𝗼𝗿𝗺𝗮𝘁 ❗️⚠️\\n\\n📝 𝖬𝗈𝗏𝗂𝖾 𝖭𝖺𝗆𝖾, 𝖸𝖾𝖺𝗋,(𝖨𝖿 𝗒𝗈𝗎 𝖪𝗇𝗈𝗐) 𝖶𝗂𝗍𝗁 𝖢𝗈𝗋𝗋𝖾𝖼𝗍 𝖲𝗉𝖾𝗅𝗅𝗂𝗇𝗀 📚\\n\\n🗣 𝖨𝖿 𝖨𝗍 𝗂𝗌 𝖺 𝖥𝗂𝗅𝗆 𝖲𝖾𝗋𝗂𝖾𝗌. 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 𝖮𝗇𝖾 𝖡𝗒 𝖮𝗇𝖾 𝖶𝗂𝗍𝗁 𝖯𝗋𝗈𝗉𝖾𝗋 𝖭𝖺𝗆𝖾 🧠\\n\\n🖇𝐄𝐱𝐚𝐦𝐩𝐥𝐞:\\n\\n• Robin Hood ✅\\n• Robin Hood 2010✅\\n• Kurup 2021 Kan✅ \\n• Harry Potter and the Philosophers Stone✅\\n• Harry Potter and the Prisoner of Azkaban✅\\n\\n🥱 𝖥𝗈𝗋 𝖫𝖺𝗇𝗀𝗎𝖺𝗀𝖾 𝖠𝗎𝖽𝗂𝗈𝗌 - 𝖪𝖺𝗇 𝖿𝗈𝗋 𝖪𝖺𝗇𝗇𝖺𝖽𝖺, 𝖬𝖺𝗅 - 𝖬𝖺𝗅𝖺𝗒𝖺𝗅𝖺𝗆, 𝖳𝖺𝗆 - 𝖳𝖺𝗆𝗂𝗅\\n\\n🔎 𝖴𝗌𝖾 𝖥𝗂𝗋𝗌𝗍 3 𝖫𝖾𝗍𝗍𝖾𝗋𝗌 𝖮𝖿 𝖫𝖺𝗇𝗀𝗎𝖺𝗀𝖾 𝖥𝗈𝗋 𝖠𝗎𝖽𝗂𝗈𝗌 [𝖪𝖺𝗇 𝖳𝖺𝗆 𝖳𝖾𝗅 𝖬𝖺𝗅 𝖧𝗂𝗇 𝖲𝗉𝖺 𝖤𝗇𝗀 𝖪𝗈𝗋 𝖾𝗍𝖼...]\\n\\n❌ [𝗗𝗼𝗻𝘁 𝗨𝘀𝗲 𝘄𝗼𝗿𝗱𝘀 𝗟𝗶𝗸𝗲 𝗗𝘂𝗯𝗯𝗲𝗱/𝗠𝗼𝘃𝗶𝗲𝘀/𝗦𝗲𝗻𝗱/𝗛𝗗 , . : - 𝗲𝘁𝗰] ❌\")\r\n\r\n@Client.on_message(filters.command(\"series\", CMD))\r\nasync def series(_, message):\r\n    await message.reply_text(\"⚠️❗️ 𝗦𝗲𝗿𝗶𝗲𝘀 𝗥𝗲𝗾𝘂𝗲𝘀𝘁 𝗙𝗼𝗿𝗺𝗮𝘁 ❗️⚠️\\n\\n🗣 𝖲𝖾𝗋𝗂𝖾𝗌 𝖭𝖺𝗆𝖾,𝖲𝖾𝖺𝗌𝗈𝗇 (𝖶𝗁𝗂𝖼𝗁 𝖲𝖾𝖺𝗌𝗈𝗇 𝗒𝗈𝗎 𝗐𝖺𝗇𝗍) 🧠\\n\\n🖇𝐄𝐱𝐚𝐦𝐩𝐥𝐞: \\n\\n• Game Of Thrones S03𝖤02 720𝗉✅\\n• Sex Education S02 720p✅ \\n• Breaking Bad S01E05✅ \\n• Prison Break 1080p✅ \\n• Witcher S02✅\\n\\n🥱 𝖥𝗈𝗋 𝖲𝖾𝖺𝗌𝗈𝗇 𝖬𝖾𝗇𝗍𝗂𝗈𝗇 𝖠𝗌 𝖲01 𝖥𝗈𝗋 𝖲𝖾𝖺𝗌𝗈𝗇 1, 𝖲02 𝖥𝗈𝗋 𝖲𝖾𝖺𝗌𝗈𝗇 2 𝖾𝗍𝖼 [𝖲03,𝖲04 ,𝖲06,𝖲10,𝖲17] 𝖦𝗈𝖾𝗌 𝖫𝗂𝗄𝖾 𝖳𝗁𝖺𝗍\\n\\n🔎 𝖥𝗈𝗋 𝖤𝗉𝗂𝗌𝗈𝖽𝖾 𝖬𝖾𝗇𝗍𝗂𝗈𝗇 𝖠𝗌 𝖤𝗉01 𝖥𝗈𝗋 𝖤𝗉𝗂𝗌𝗈𝖽𝖾 1, 𝖤𝗉02 𝖥𝗈𝗋 𝖤𝗉𝗂𝗌𝗈𝖽𝖾 2 𝖾𝗍𝖼 [𝖤𝗉03,𝖤𝗉07,𝖤𝗉17,𝖤𝗉21] 𝖦𝗈'𝗌 𝖫𝗂𝗄𝖾 𝖳𝗁𝖺𝗍 \\n\\n❌ [𝗗𝗼𝗻𝘁 𝗨𝘀𝗲 𝘄𝗼𝗿𝗱𝘀 𝗟𝗶𝗸𝗲 𝗦𝗲𝗮𝘀𝗼𝗻/𝗘𝗽𝗶𝘀𝗼𝗱𝗲/𝗦𝗲𝗿𝗶𝗲𝘀 , . : - 𝗲𝘁𝗰] ❌\")\r\n\r\n@Client.on_message(filters.command(\"tutorial\", CMD))\r\nasync def tutorial(_, message):\r\n    await message.reply_text(\"𝖢𝗁𝖾𝖼𝗄𝗈𝗎𝗍 @piro_tuts 𝖥𝗈𝗋 𝖳𝗎𝗍𝗈𝗋𝗂𝖺𝗅𝗌 😎\")\r\n\r\n@Client.on_message(filters.command(\"ping\", CMD))\r\nasync def ping(_, message):\r\n    start_t = time.time()\r\n    rm = await message.reply_text(\"...........\")\r\n    end_t = time.time()\r\n    time_taken_s = (end_t - start_t) * 1000\r\n    await rm.edit(f\"𝖯𝗂𝗇𝗀!\\n{time_taken_s:.3f} ms\")\r\n\r\n@Client.on_message(filters.command(\"status\"))          \r\nasync def stats(bot, update):\r\n    currentTime = time.strftime(\"%Hh%Mm%Ss\", time.gmtime(time.time() - BOT_START_TIME))\r\n    total, used, free = shutil.disk_usage(\".\")\r\n    total = humanbytes(total)\r\n    used = humanbytes(used)\r\n    free = humanbytes(free)\r\n    cpu_usage = psutil.cpu_percent()\r\n    ram_usage = psutil.virtual_memory().percent\r\n    disk_usage = psutil.disk_usage('/').percent\r\n\r\n    ms_g = f\"\"\"<b>⚙️ 𝖡𝗈𝗍 𝖲𝗍𝖺𝗍𝗎𝗌</b>\r\n\r\n🕔 𝖴𝗉𝗍𝗂𝗆𝖾: <code>{currentTime}</code>\r\n🛠 𝖢𝖯𝖴 𝖴𝗌𝖺𝗀𝖾: <code>{cpu_usage}%</code>\r\n🗜 𝖱𝖠𝖬 𝖴𝗌𝖺𝗀𝖾: <code>{ram_usage}%</code>\r\n🗂 𝖳𝗈𝗍𝖺𝗅 𝖣𝗂𝗌𝗄 𝖲𝗉𝖺𝖼𝖾: <code>{total}</code>\r\n🗳 𝖴𝗌𝖾𝖽 𝖲𝗉𝖺𝖼𝖾: <code>{used} ({disk_usage}%)</code>\r\n📝 𝖥𝗋𝖾𝖾 𝖲𝗉𝖺𝖼𝖾: <code>{free}</code> \"\"\"\r\n\r\n    msg = await bot.send_message(chat_id=update.chat.id, text=\"__𝖯𝗋𝗈𝖼𝖾𝗌𝗌𝗂𝗇𝗀...__\", parse_mode=enums.ParseMode.MARKDOWN)         \r\n    await msg.edit_text(text=ms_g, parse_mode=enums.ParseMode.HTML)\r\n\r\n@Client.on_message(filters.command(\"restart\") & filters.user(ADMINS))\r\nasync def stop_button(bot, message):\r\n    msg = await bot.send_message(text=\"**𝖡𝗈𝗍 𝖨𝗌 𝖱𝖾𝗌𝗍𝖺𝗋𝗍𝗂𝗇𝗀...🪄**\", chat_id=message.chat.id)       \r\n    await asyncio.sleep(3)\r\n    await msg.edit(\"**𝖡𝗈𝗍 𝖱𝖾𝗌𝗍𝖺𝗋𝗍𝖾𝖽 𝖲𝗎𝖼𝖼𝖾𝗌𝗌𝖿𝗎𝗅𝗅𝗒 ! 𝖱𝖾𝖺𝖽𝗒 𝖳𝗈 𝖬𝗈𝗏𝖾 𝖮𝗇 💯**\")\r\n    os.execl(sys.executable, sys.executable, *sys.argv)"
  },
  {
    "path": "plugins/commands.py",
    "content": "import os\nimport logging\nimport random\nimport asyncio\nfrom Script import script\nfrom pyrogram import Client, filters, enums\nfrom pyrogram.errors import ChatAdminRequired, FloodWait\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup\nfrom database.ia_filterdb import Media, get_file_details, unpack_new_file_id, get_bad_files\nfrom database.users_chats_db import db\nfrom info import CHANNELS, ADMINS, AUTH_CHANNEL, LOG_CHANNEL, PICS, BATCH_FILE_CAPTION, CUSTOM_FILE_CAPTION, SUPPORT_CHAT, PROTECT_CONTENT, REQST_CHANNEL, SUPPORT_CHAT_ID, MAX_B_TN\nfrom utils import get_settings, get_size, is_subscribed, save_group_settings, temp\nfrom database.connections_mdb import active_connection\nimport re\nimport json\nimport base64\nlogger = logging.getLogger(__name__)\n\nBATCH_FILES = {}\n\n@Client.on_message(filters.command(\"start\") & filters.incoming)\nasync def start(client, message):\n    if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        buttons = [[\n                    InlineKeyboardButton('➕ 𝖠𝖽𝖽 𝖬𝖾 𝖳𝗈 𝖸𝗈𝗎𝗋 𝖦𝗋𝗈𝗎𝗉 ➕', url=f\"http://t.me/{temp.U_NAME}?startgroup=true\")\n                ],[\n                    InlineKeyboardButton('🛡 𝖮𝗐𝗇𝖾𝗋', callback_data=\"owner_info\"),\n                    InlineKeyboardButton('🧩 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉', url=f\"https://t.me/{SUPPORT_CHAT}\")\n                ],[\n                    InlineKeyboardButton('ℹ️ 𝖧𝖾𝗅𝗉', callback_data='help'),\n                    InlineKeyboardButton('😊 𝖠𝖻𝗈𝗎𝗍', callback_data='about')\n                ],[\n                    InlineKeyboardButton('🔎 𝖨𝗇𝗅𝗂𝗇𝖾 𝖲𝖾𝖺𝗋𝖼𝗁', switch_inline_query_current_chat='')\n                  ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await message.reply(script.START_TXT.format(message.from_user.mention if message.from_user else message.chat.title, temp.U_NAME, temp.B_NAME), reply_markup=reply_markup)\n        await asyncio.sleep(2)\n        if not await db.get_chat(message.chat.id):\n            total=await client.get_chat_members_count(message.chat.id)\n            await client.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, \"Unknown\"))       \n            await db.add_chat(message.chat.id, message.chat.title)\n        return \n    if not await db.is_user_exist(message.from_user.id):\n        await db.add_user(message.from_user.id, message.from_user.first_name)\n        await client.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(message.from_user.id, message.from_user.mention))\n    if len(message.command) != 2:\n        buttons = [[\n                    InlineKeyboardButton('➕ 𝖠𝖽𝖽 𝖬𝖾 𝖳𝗈 𝖸𝗈𝗎𝗋 𝖦𝗋𝗈𝗎𝗉 ➕', url=f\"http://t.me/{temp.U_NAME}?startgroup=true\")\n                ],[\n                    InlineKeyboardButton('🛡 𝖮𝗐𝗇𝖾𝗋', callback_data=\"owner_info\"),\n                    InlineKeyboardButton('🧩 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉', url=f\"https://t.me/{SUPPORT_CHAT}\")\n                ],[\n                    InlineKeyboardButton('ℹ️ 𝖧𝖾𝗅𝗉', callback_data='help'),\n                    InlineKeyboardButton('😊 𝖠𝖻𝗈𝗎𝗍', callback_data='about'),\n                ],[\n                    InlineKeyboardButton('🔎 𝖨𝗇𝗅𝗂𝗇𝖾 𝖲𝖾𝖺𝗋𝖼𝗁', switch_inline_query_current_chat='')\n                  ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await message.reply_photo(\n            photo=random.choice(PICS),\n            caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n        return\n    if AUTH_CHANNEL and not await is_subscribed(client, message):\n        try:\n            invite_link = await client.create_chat_invite_link(int(AUTH_CHANNEL))\n        except ChatAdminRequired:\n            logger.error(\"Make sure Bot is admin in Forcesub channel\")\n            return\n        btn = [\n            [\n                InlineKeyboardButton(\n                    \"🤖 𝖩𝗈𝗂𝗇 𝖴𝗉𝖽𝖺𝗍𝖾𝗌 𝖢𝗁𝖺𝗇𝗇𝖾𝗅 🤖\", url=invite_link.invite_link\n                )\n            ]\n        ]\n\n        if message.command[1] != \"subscribe\" or message.command[1] != \"send_all\":\n            try:\n                kk, file_id = message.command[1].split(\"_\", 1)\n                pre = 'checksubp' if kk == 'filep' else 'checksub' \n                btn.append([InlineKeyboardButton(\"🔄 𝖳𝗋𝗒 𝖠𝗀𝖺𝗂𝗇 🔄\", callback_data=f\"{pre}#{file_id}\")])\n            except (IndexError, ValueError):\n                btn.append([InlineKeyboardButton(\"🔄 𝖳𝗋𝗒 𝖠𝗀𝖺𝗂𝗇 🔄\", url=f\"https://t.me/{temp.U_NAME}?start={message.command[1]}\")])\n        await client.send_message(\n            chat_id=message.from_user.id,\n            text=\"**Please Join My Updates Channel to use this Bot!**\",\n            reply_markup=InlineKeyboardMarkup(btn),\n            parse_mode=enums.ParseMode.MARKDOWN\n            )\n        return\n    if len(message.command) == 2 and message.command[1] in [\"subscribe\", \"error\", \"okay\", \"help\"]:\n        buttons = [[\n                    InlineKeyboardButton('➕ 𝖠𝖽𝖽 𝖬𝖾 𝖳𝗈 𝖸𝗈𝗎𝗋 𝖦𝗋𝗈𝗎𝗉 ➕', url=f\"http://t.me/{temp.U_NAME}?startgroup=true\")\n                ],[\n                    InlineKeyboardButton('🛡 𝖮𝗐𝗇𝖾𝗋', callback_data=\"owner_info\"),\n                    InlineKeyboardButton('🧩 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉', url=f\"https://t.me/{SUPPORT_CHAT}\")\n                ],[\n                    InlineKeyboardButton('ℹ️ 𝖧𝖾𝗅𝗉', callback_data='help'),\n                    InlineKeyboardButton('😊 𝖠𝖻𝗈𝗎𝗍', callback_data='about')\n                ],[\n                    InlineKeyboardButton('🔎 𝖨𝗇𝗅𝗂𝗇𝖾 𝖲𝖾𝖺𝗋𝖼𝗁', switch_inline_query_current_chat='')\n                    \n                  ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await message.reply_photo(\n            photo=random.choice(PICS),\n            caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n        return\n    data = message.command[1]\n    try:\n        pre, file_id = data.split('_', 1)\n    except:\n        file_id = data\n        pre = \"\"\n        \n    if data.startswith(\"all\"):\n        _, key, pre = data.split(\"_\", 2)\n        files = temp.FILES_IDS.get(key)\n        if not files:\n            return await message.reply('<b><i>No such file exist.</b></i>')\n        \n        for file in files:\n            title = file.file_name\n            size=get_size(file.file_size)\n            f_caption=file.caption\n            if CUSTOM_FILE_CAPTION:\n                try:\n                    f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)\n                except:\n                    f_caption=f_caption\n            if f_caption is None:\n                f_caption = f\"{file.file_name}\"\n            await client.send_cached_media(\n                chat_id=message.from_user.id,\n                file_id=file.file_id,\n                caption=f_caption,\n                protect_content=True if pre == 'filep' else False,\n                reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=f\"https://t.me/piroxbots\") ] ] ),\n            )\n        return\n    \n    if data.split(\"-\", 1)[0] == \"BATCH\":\n        sts = await message.reply(\"<b>Please wait...</b>\")\n        file_id = data.split(\"-\", 1)[1]\n        msgs = BATCH_FILES.get(file_id)\n        if not msgs:\n            file = await client.download_media(file_id)\n            try: \n                with open(file) as file_data:\n                    msgs=json.loads(file_data.read())\n            except:\n                await sts.edit(\"FAILED\")\n                return await client.send_message(LOG_CHANNEL, \"UNABLE TO OPEN FILE.\")\n            os.remove(file)\n            BATCH_FILES[file_id] = msgs\n        for msg in msgs:\n            title = msg.get(\"title\")\n            size=get_size(int(msg.get(\"size\", 0)))\n            f_caption=msg.get(\"caption\", \"\")\n            if BATCH_FILE_CAPTION:\n                try:\n                    f_caption=BATCH_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)\n                except Exception as e:\n                    logger.exception(e)\n                    f_caption=f_caption\n            if f_caption is None:\n                f_caption = f\"{title}\"\n            try:\n                await client.send_cached_media(\n                    chat_id=message.from_user.id,\n                    file_id=msg.get(\"file_id\"),\n                    caption=f_caption,\n                    protect_content=msg.get('protect', False),\n                    reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=f\"https://t.me/piroxbots\") ] ] ),\n                    \n                )\n            except FloodWait as e:\n                await asyncio.sleep(e.x)\n                logger.warning(f\"Floodwait of {e.x} sec.\")\n                await client.send_cached_media(\n                    chat_id=message.from_user.id,\n                    file_id=msg.get(\"file_id\"),\n                    caption=f_caption,\n                    protect_content=msg.get('protect', False),\n                    reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=f\"https://t.me/piroxbots\") ] ] ),\n                )\n            except Exception as e:\n                logger.warning(e, exc_info=True)\n                continue\n            await asyncio.sleep(1) \n        await sts.delete()\n        return\n    elif data.split(\"-\", 1)[0] == \"DSTORE\":\n        sts = await message.reply(\"<b>Please wait...</b>\")\n        b_string = data.split(\"-\", 1)[1]\n        decoded = (base64.urlsafe_b64decode(b_string + \"=\" * (-len(b_string) % 4))).decode(\"ascii\")\n        try:\n            f_msg_id, l_msg_id, f_chat_id, protect = decoded.split(\"_\", 3)\n        except:\n            f_msg_id, l_msg_id, f_chat_id = decoded.split(\"_\", 2)\n            protect = \"/pbatch\" if PROTECT_CONTENT else \"batch\"\n        diff = int(l_msg_id) - int(f_msg_id)\n        async for msg in client.iter_messages(int(f_chat_id), int(l_msg_id), int(f_msg_id)):\n            if msg.media:\n                media = getattr(msg, msg.media.value)\n                if BATCH_FILE_CAPTION:\n                    try:\n                        f_caption=BATCH_FILE_CAPTION.format(file_name=getattr(media, 'file_name', ''), file_size=getattr(media, 'file_size', ''), file_caption=getattr(msg, 'caption', ''))\n                    except Exception as e:\n                        logger.exception(e)\n                        f_caption = getattr(msg, 'caption', '')\n                else:\n                    media = getattr(msg, msg.media.value)\n                    file_name = getattr(media, 'file_name', '')\n                    f_caption = getattr(msg, 'caption', file_name)\n                try:\n                    await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == \"/pbatch\" else False)\n                except FloodWait as e:\n                    await asyncio.sleep(e.x)\n                    await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == \"/pbatch\" else False)\n                except Exception as e:\n                    logger.exception(e)\n                    continue\n            elif msg.empty:\n                continue\n            else:\n                try:\n                    await msg.copy(message.chat.id, protect_content=True if protect == \"/pbatch\" else False)\n                except FloodWait as e:\n                    await asyncio.sleep(e.x)\n                    await msg.copy(message.chat.id, protect_content=True if protect == \"/pbatch\" else False)\n                except Exception as e:\n                    logger.exception(e)\n                    continue\n            await asyncio.sleep(1) \n        return await sts.delete()\n        \n\n    files_ = await get_file_details(file_id)           \n    if not files_:\n        pre, file_id = ((base64.urlsafe_b64decode(data + \"=\" * (-len(data) % 4))).decode(\"ascii\")).split(\"_\", 1)\n        try:\n            msg = await client.send_cached_media(\n                chat_id=message.from_user.id,\n                file_id=file_id,\n                protect_content=True if pre == 'filep' else False,\n                reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=\"https://t.me/piroxbots\") ] ] ),\n            )\n            filetype = msg.media\n            file = getattr(msg, filetype.value)\n            title = file.file_name\n            size=get_size(file.file_size)\n            f_caption = f\"<code>{title}</code>\"\n            if CUSTOM_FILE_CAPTION:\n                try:\n                    f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='')\n                except:\n                    return\n            await msg.edit_caption(f_caption)\n            return\n        except:\n            pass\n        return await message.reply('<b><i>No such file exist.</b></i>')\n    files = files_[0]\n    title = files.file_name\n    size=get_size(files.file_size)\n    f_caption=files.caption\n    if CUSTOM_FILE_CAPTION:\n        try:\n            f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)\n        except Exception as e:\n            logger.exception(e)\n            f_caption=f_caption\n    if f_caption is None:\n        f_caption = f\"{files.file_name}\"\n    await client.send_cached_media(\n        chat_id=message.from_user.id,\n        file_id=file_id,\n        caption=f_caption,\n        protect_content=True if pre == 'filep' else False,\n        reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=\"https://t.me/piroxbots\") ] ] ),\n    )\n                    \n\n@Client.on_message(filters.command('channel') & filters.user(ADMINS))\nasync def channel_info(bot, message):\n           \n    \"\"\"Send basic information of channel\"\"\"\n    if isinstance(CHANNELS, (int, str)):\n        channels = [CHANNELS]\n    elif isinstance(CHANNELS, list):\n        channels = CHANNELS\n    else:\n        raise ValueError(\"Unexpected type of CHANNELS\")\n\n    text = '📑 **Indexed channels/groups**\\n'\n    for channel in channels:\n        chat = await bot.get_chat(channel)\n        if chat.username:\n            text += '\\n@' + chat.username\n        else:\n            text += '\\n' + chat.title or chat.first_name\n\n    text += f'\\n\\n**Total:** {len(CHANNELS)}'\n\n    if len(text) < 4096:\n        await message.reply(text)\n    else:\n        file = 'Indexed channels.txt'\n        with open(file, 'w') as f:\n            f.write(text)\n        await message.reply_document(file)\n        os.remove(file)\n\n\n@Client.on_message(filters.command('logs') & filters.user(ADMINS))\nasync def log_file(bot, message):\n    \"\"\"Send log file\"\"\"\n    try:\n        await message.reply_document('Logs.txt')\n    except Exception as e:\n        await message.reply(str(e))\n\n@Client.on_message(filters.command('delete') & filters.user(ADMINS))\nasync def delete(bot, message):\n    \"\"\"Delete file from database\"\"\"\n    reply = message.reply_to_message\n    if reply and reply.media:\n        msg = await message.reply(\"Processing...⏳\", quote=True)\n    else:\n        await message.reply('Reply to file with /delete which you want to delete', quote=True)\n        return\n\n    for file_type in (\"document\", \"video\", \"audio\"):\n        media = getattr(reply, file_type, None)\n        if media is not None:\n            break\n    else:\n        await msg.edit('This is not supported file format')\n        return\n    \n    file_id, file_ref = unpack_new_file_id(media.file_id)\n\n    result = await Media.collection.delete_one({\n        '_id': file_id,\n    })\n    if result.deleted_count:\n        await msg.edit('File is successfully deleted from database')\n    else:\n        file_name = re.sub(r\"(_|\\-|\\.|\\+)\", \" \", str(media.file_name))\n        result = await Media.collection.delete_many({\n            'file_name': file_name,\n            'file_size': media.file_size,\n            'mime_type': media.mime_type\n            })\n        if result.deleted_count:\n            await msg.edit('File is successfully deleted from database')\n        else:\n            result = await Media.collection.delete_many({\n                'file_name': media.file_name,\n                'file_size': media.file_size,\n                'mime_type': media.mime_type\n            })\n            if result.deleted_count:\n                await msg.edit('File is successfully deleted from database')\n            else:\n                await msg.edit('File not found in database')\n\n\n@Client.on_message(filters.command('deleteall') & filters.user(ADMINS))\nasync def delete_all_index(bot, message):\n    await message.reply_text(\n        'This will delete all indexed files.\\nDo you want to continue??',\n        reply_markup=InlineKeyboardMarkup(\n            [\n                [\n                    InlineKeyboardButton(\n                        text=\"YES\", callback_data=\"autofilter_delete\"\n                    )\n                ],\n                [\n                    InlineKeyboardButton(\n                        text=\"CANCEL\", callback_data=\"close_data\"\n                    )\n                ],\n            ]\n        ),\n        quote=True,\n    )\n\n\n@Client.on_callback_query(filters.regex(r'^autofilter_delete'))\nasync def delete_all_index_confirm(bot, message):\n    await Media.collection.drop()\n    await message.answer('Piracy Is Crime')\n    await message.message.edit('Succesfully Deleted All The Indexed Files.')\n\n\n@Client.on_message(filters.command('settings'))\nasync def settings(client, message):\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n\n    if chat_type == enums.ChatType.PRIVATE:\n        grpid = await active_connection(str(userid))\n        if grpid is not None:\n            grp_id = grpid\n            try:\n                chat = await client.get_chat(grpid)\n                title = chat.title\n            except:\n                await message.reply_text(\"Make sure I'm present in your group!!\", quote=True)\n                return\n        else:\n            await message.reply_text(\"I'm not connected to any groups!\", quote=True)\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        grp_id = message.chat.id\n        title = message.chat.title\n\n    else:\n        return\n\n    st = await client.get_chat_member(grp_id, userid)\n    if (\n            st.status != enums.ChatMemberStatus.ADMINISTRATOR\n            and st.status != enums.ChatMemberStatus.OWNER\n            and str(userid) not in ADMINS\n    ):\n        return\n    \n    settings = await get_settings(grp_id)\n\n    try:\n        if settings['max_btn']:\n            settings = await get_settings(grp_id)\n    except KeyError:\n        await save_group_settings(grp_id, 'max_btn', False)\n        settings = await get_settings(grp_id)\n\n    if settings is not None:\n        buttons = [\n            [\n                InlineKeyboardButton(\n                    '𝖥𝗂𝗅𝗍𝖾𝗋 𝖡𝗎𝗍𝗍𝗈𝗇',\n                    callback_data=f'setgs#button#{settings[\"button\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '𝖲𝗂𝗇𝗀𝗅𝖾 𝖡𝗎𝗍𝗍𝗈𝗇' if settings[\"button\"] else '𝖣𝗈𝗎𝖻𝗅𝖾',\n                    callback_data=f'setgs#button#{settings[\"button\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖥𝗂𝗅𝖾 𝖲𝖾𝗇𝖽 𝖬𝗈𝖽𝖾',\n                    callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '𝖬𝖺𝗇𝗎𝖺𝗅 𝖲𝗍𝖺𝗋𝗍' if settings[\"botpm\"] else '𝖠𝗎𝗍𝗈 𝖲𝖾𝗇𝖽',\n                    callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖯𝗋𝗈𝗍𝖾𝖼𝗍 𝖢𝗈𝗇𝗍𝖾𝗇𝗍',\n                    callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '✅ 𝖮𝗇' if settings[\"file_secure\"] else '❌ 𝖮𝖿𝖿',\n                    callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖨𝖬𝖣𝖻',\n                    callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '✅ 𝖮𝗇' if settings[\"imdb\"] else '❌ 𝖮𝖿𝖿',\n                    callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖲𝗉𝖾𝗅𝗅 𝖢𝗁𝖾𝖼𝗄',\n                    callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '✅ 𝖮𝗇' if settings[\"spell_check\"] else '❌ 𝖮𝖿𝖿',\n                    callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖶𝖾𝗅𝖼𝗈𝗆𝖾 𝖬𝖾𝗌𝗌𝖺𝗀𝖾',\n                    callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '✅ 𝖮𝗇' if settings[\"welcome\"] else '❌ 𝖮𝖿𝖿',\n                    callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖠𝗎𝗍𝗈 𝖣𝖾𝗅𝖾𝗍𝖾',\n                    callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '5 𝖬𝗂𝗇' if settings[\"auto_delete\"] else '❌ 𝖮𝖿𝖿',\n                    callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖠𝗎𝗍𝗈-𝖥𝗂𝗅𝗍𝖾𝗋',\n                    callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '✅ 𝖮𝗇' if settings[\"auto_ffilter\"] else '❌ 𝖮𝖿𝖿',\n                    callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{grp_id}',\n                ),\n            ],\n            [\n                InlineKeyboardButton(\n                    '𝖬𝖺𝗑 𝖡𝗎𝗍𝗍𝗈𝗇𝗌',\n                    callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{grp_id}',\n                ),\n                InlineKeyboardButton(\n                    '10' if settings[\"max_btn\"] else f'{MAX_B_TN}',\n                    callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{grp_id}',\n                ),\n            ],\n        ]\n\n        btn = [[\n                InlineKeyboardButton(\"⬇ 𝖮𝗉𝖾𝗇 𝖧𝖾𝗋𝖾 ⬇\", callback_data=f\"opnsetgrp#{grp_id}\"),\n                InlineKeyboardButton(\"➡ 𝖮𝗉𝖾𝗇 𝗂𝗇 𝖯𝖬 ➡\", callback_data=f\"opnsetpm#{grp_id}\")\n              ]]\n\n        reply_markup = InlineKeyboardMarkup(buttons)\n        if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n            await message.reply_text(\n                text=\"<b>𝖣𝗈 𝖸𝗈𝗎 𝖶𝖺𝗇𝗍 𝖳𝗈 𝖮𝗉𝖾𝗇 𝖲𝖾𝗍𝗍𝗂𝗇𝗀𝗌 𝖧𝖾𝗋𝖾 ?</b>\",\n                reply_markup=InlineKeyboardMarkup(btn),\n                disable_web_page_preview=True,\n                parse_mode=enums.ParseMode.HTML,\n                reply_to_message_id=message.id\n            )\n        else:\n            await message.reply_text(\n                text=f\"<b>𝖢𝗁𝖺𝗇𝗀𝖾 𝖸𝗈𝗎𝗋 𝖲𝖾𝗍𝗍𝗂𝗇𝗀𝗌 𝖥𝗈𝗋 {title} 𝖠𝗌 𝖸𝗈𝗎𝗋 𝖶𝗂𝗌𝗁</b>\",\n                reply_markup=reply_markup,\n                disable_web_page_preview=True,\n                parse_mode=enums.ParseMode.HTML,\n                reply_to_message_id=message.id\n            )\n\n@Client.on_message(filters.command(\"send\") & filters.user(ADMINS))\nasync def send_msg(bot, message):\n    if message.reply_to_message:\n        target_id = message.text\n        command = [\"/send\"]\n        out = \"Users Saved In DB Are:\\n\\n\"\n        for cmd in command:\n            if cmd in target_id:\n                target_id = target_id.replace(cmd, \"\")\n        success = False\n        try:\n            user = await bot.get_users(target_id)\n            users = await db.get_all_users()\n            async for usr in users:\n                out += f\"{usr['id']}\"\n                out += '\\n'\n            if str(user.id) in str(out):\n                await message.reply_to_message.copy(int(user.id))\n                success = True\n            else:\n                success = False\n            if success:\n                await message.reply_text(f\"<b>Your message has been successfully send to {user.mention}.</b>\")\n            else:\n                await message.reply_text(\"<b>This user didn't started this bot yet !</b>\")\n        except Exception as e:\n            await message.reply_text(f\"<b>Error: {e}</b>\")\n    else:\n        await message.reply_text(\"<b>Use this command as a reply to any message using the target chat id. For eg: /send userid</b>\")\n\n@Client.on_message(filters.command('set_template'))\nasync def save_template(client, message):\n    sts = await message.reply(\"Checking template\")\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n\n    if chat_type == enums.ChatType.PRIVATE:\n        grpid = await active_connection(str(userid))\n        if grpid is not None:\n            grp_id = grpid\n            try:\n                chat = await client.get_chat(grpid)\n                title = chat.title\n            except:\n                await message.reply_text(\"Make sure I'm present in your group!!\", quote=True)\n                return\n        else:\n            await message.reply_text(\"I'm not connected to any groups!\", quote=True)\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        grp_id = message.chat.id\n        title = message.chat.title\n\n    else:\n        return\n\n    st = await client.get_chat_member(grp_id, userid)\n    if (\n            st.status != enums.ChatMemberStatus.ADMINISTRATOR\n            and st.status != enums.ChatMemberStatus.OWNER\n            and str(userid) not in ADMINS\n    ):\n        return\n\n    if len(message.command) < 2:\n        return await sts.edit(\"No Input!!\")\n    template = message.text.split(\" \", 1)[1]\n    await save_group_settings(grp_id, 'template', template)\n    await sts.edit(f\"Successfully changed template for {title} to\\n\\n{template}\")\n\n\n@Client.on_message((filters.command([\"request\", \"Request\"]) | filters.regex(\"#request\") | filters.regex(\"#Request\")) & filters.group)\nasync def requests(bot, message):\n    if REQST_CHANNEL is None or SUPPORT_CHAT_ID is None: return # Must add REQST_CHANNEL and SUPPORT_CHAT_ID to use this feature\n    if message.reply_to_message and SUPPORT_CHAT_ID == message.chat.id:\n        chat_id = message.chat.id\n        reporter = str(message.from_user.id)\n        mention = message.from_user.mention\n        success = True\n        content = message.reply_to_message.text\n        try:\n            if REQST_CHANNEL is not None:\n                btn = [[\n                        InlineKeyboardButton('📥 𝖵𝗂𝖾𝗐 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 📥', url=f\"{message.reply_to_message.link}\"),\n                        InlineKeyboardButton('📝 𝖲𝗁𝗈𝗐 𝖮𝗉𝗍𝗂𝗈𝗇𝗌 📝', callback_data=f'show_option#{reporter}')\n                      ]]\n                reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f\"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\\n\\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>\", reply_markup=InlineKeyboardMarkup(btn))\n                success = True\n            elif len(content) >= 3:\n                for admin in ADMINS:\n                    btn = [[\n                        InlineKeyboardButton('📥 𝖵𝗂𝖾𝗐 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 📥', url=f\"{message.reply_to_message.link}\"),\n                        InlineKeyboardButton('📝 𝖲𝗁𝗈𝗐 𝖮𝗉𝗍𝗂𝗈𝗇𝗌 📝', callback_data=f'show_option#{reporter}')\n                      ]]\n                    reported_post = await bot.send_message(chat_id=admin, text=f\"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\\n\\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>\", reply_markup=InlineKeyboardMarkup(btn))\n                    success = True\n            else:\n                if len(content) < 3:\n                    await message.reply_text(\"<b>You must type about your request [Minimum 3 Characters]. Requests can't be empty.</b>\")\n            if len(content) < 3:\n                success = False\n        except Exception as e:\n            await message.reply_text(f\"Error: {e}\")\n            pass\n        \n    elif SUPPORT_CHAT_ID == message.chat.id:\n        chat_id = message.chat.id\n        reporter = str(message.from_user.id)\n        mention = message.from_user.mention\n        success = True\n        content = message.text\n        keywords = [\"#request\", \"/request\", \"#Request\", \"/Request\"]\n        for keyword in keywords:\n            if keyword in content:\n                content = content.replace(keyword, \"\")\n        try:\n            if REQST_CHANNEL is not None and len(content) >= 3:\n                btn = [[\n                        InlineKeyboardButton('📥 𝖵𝗂𝖾𝗐 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 📥', url=f\"{message.link}\"),\n                        InlineKeyboardButton('📝 𝖲𝗁𝗈𝗐 𝖮𝗉𝗍𝗂𝗈𝗇𝗌 📝', callback_data=f'show_option#{reporter}')\n                      ]]\n                reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f\"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\\n\\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>\", reply_markup=InlineKeyboardMarkup(btn))\n                success = True\n            elif len(content) >= 3:\n                for admin in ADMINS:\n                    btn = [[\n                        InlineKeyboardButton('📥 𝖵𝗂𝖾𝗐 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 📥', url=f\"{message.link}\"),\n                        InlineKeyboardButton('📝 𝖲𝗁𝗈𝗐 𝖮𝗉𝗍𝗂𝗈𝗇𝗌 📝', callback_data=f'show_option#{reporter}')\n                      ]]\n                    reported_post = await bot.send_message(chat_id=admin, text=f\"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\\n\\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>\", reply_markup=InlineKeyboardMarkup(btn))\n                    success = True\n            else:\n                if len(content) < 3:\n                    await message.reply_text(\"<b>You must type about your request [Minimum 3 Characters]. Requests can't be empty.</b>\")\n            if len(content) < 3:\n                success = False\n        except Exception as e:\n            await message.reply_text(f\"Error: {e}\")\n            pass\n\n    else:\n        success = False\n    \n    if success:\n        btn = [[\n                InlineKeyboardButton('📥 𝖵𝗂𝖾𝗐 𝖱𝖾𝗊𝗎𝖾𝗌𝗍 📥', url=f\"{reported_post.link}\")\n              ]]\n        await message.reply_text(\"<b>Your request has been added! Please wait for some time.</b>\", reply_markup=InlineKeyboardMarkup(btn))\n\n@Client.on_message(filters.command(\"usend\") & filters.user(ADMINS))\nasync def send_msg(bot, message):\n    if message.reply_to_message:\n        target_id = message.text.split(\" \", 1)[1]\n        out = \"Users Saved In DB Are:\\n\\n\"\n        success = False\n        try:\n            user = await bot.get_users(target_id)\n            users = await db.get_all_users()\n            async for usr in users:\n                out += f\"{usr['id']}\"\n                out += '\\n'\n            if str(user.id) in str(out):\n                await message.reply_to_message.copy(int(user.id))\n                success = True\n            else:\n                success = False\n            if success:\n                await message.reply_text(f\"<b>𝖸𝗈𝗎𝗋 𝖬𝖾𝗌𝗌𝖺𝗀𝖾 𝖧𝖺𝗌 𝖲𝗎𝖼𝖼𝖾𝗌𝗌𝖿𝗎𝗅𝗅𝗒 𝖲𝖾𝗇𝗍 𝖳𝗈 {user.mention}.</b>\")\n            else:\n                await message.reply_text(\"<b>An Error Occured !</b>\")\n        except Exception as e:\n            await message.reply_text(f\"<b>Error :- <code>{e}</code></b>\")\n    else:\n        await message.reply_text(\"<b>Error𝖢𝗈𝗆𝗆𝖺𝗇𝖽 𝖨𝗇𝖼𝗈𝗆𝗉𝗅𝖾𝗍𝖾 !</b>\")\n        \n@Client.on_message(filters.command(\"send\") & filters.user(ADMINS))\nasync def send_msg(bot, message):\n    if message.reply_to_message:\n        target_id = message.text.split(\" \", 1)[1]\n        out = \"Users Saved In DB Are:\\n\\n\"\n        success = False\n        try:\n            user = await bot.get_users(target_id)\n            users = await db.get_all_users()\n            async for usr in users:\n                out += f\"{usr['id']}\"\n                out += '\\n'\n            if str(user.id) in str(out):\n                await message.reply_to_message.copy(int(user.id))\n                success = True\n            else:\n                success = False\n            if success:\n                await message.reply_text(f\"<b>Your message has been successfully send to {user.mention}.</b>\")\n            else:\n                await message.reply_text(\"<b>This user didn't started this bot yet !</b>\")\n        except Exception as e:\n            await message.reply_text(f\"<b>Error: {e}</b>\")\n    else:\n        await message.reply_text(\"<b>Use this command as a reply to any message using the target chat id. For eg: /send userid</b>\")\n\n@Client.on_message(filters.command(\"gsend\") & filters.user(ADMINS))\nasync def send_chatmsg(bot, message):\n    if message.reply_to_message:\n        target_id = message.text.split(\" \", 1)[1]\n        out = \"Chats Saved In DB Are:\\n\\n\"\n        success = False\n        try:\n            chat = await bot.get_chat(target_id)\n            chats = await db.get_all_chats()\n            async for cht in chats:\n                out += f\"{cht['id']}\"\n                out += '\\n'\n            if str(chat.id) in str(out):\n                await message.reply_to_message.copy(int(chat.id))\n                success = True\n            else:\n                success = False\n            if success:\n                await message.reply_text(f\"<b>Your message has been successfully send to <code>{chat.id}</code>.</b>\")\n            else:\n                await message.reply_text(\"<b>An Error Occured !</b>\")\n        except Exception as e:\n            await message.reply_text(f\"<b>Error :- <code>{e}</code></b>\")\n    else:\n        await message.reply_text(\"<b>Error𝖢𝗈𝗆𝗆𝖺𝗇𝖽 𝖨𝗇𝖼𝗈𝗆𝗉𝗅𝖾𝗍𝖾 !</b>\")\n\n@Client.on_message(filters.command(\"deletefiles\") & filters.user(ADMINS))\nasync def deletemultiplefiles(bot, message):\n    chat_type = message.chat.type\n    if chat_type != enums.ChatType.PRIVATE:\n        return await message.reply_text(f\"<b>Hey {message.from_user.mention}, This command won't work in groups. It only works on my PM !</b>\")\n    else:\n        pass\n    try:\n        keyword = message.text.split(\" \", 1)[1]\n    except:\n        return await message.reply_text(f\"<b>Hey {message.from_user.mention}, Give me a keyword along with the command to delete files.</b>\")\n    k = await bot.send_message(chat_id=message.chat.id, text=f\"<b>Fetching Files for your query {keyword} on DB... Please wait...</b>\")\n    files, total = await get_bad_files(keyword)\n    await k.edit_text(f\"<b>Found {total} files for your query {keyword} !\\n\\nFile deletion process will start in 5 seconds !</b>\")\n    await asyncio.sleep(5)\n    deleted = 0\n    for file in files:\n        await k.edit_text(f\"<b>Process started for deleting files from DB. Successfully deleted {str(deleted)} files from DB for your query {keyword} !\\n\\nPlease wait...</b>\")\n        file_ids = file.file_id\n        file_name = file.file_name\n        result = await Media.collection.delete_one({\n            '_id': file_ids,\n        })\n        if result.deleted_count:\n            logger.info(f'File Found for your query {keyword}! Successfully deleted {file_name} from database.')\n        deleted += 1\n    await k.edit_text(text=f\"<b>Process Completed for file deletion !\\n\\nSuccessfully deleted {str(deleted)} files from database for your query {keyword}.</b>\")\n"
  },
  {
    "path": "plugins/connection.py",
    "content": "from pyrogram import filters, Client, enums\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup\nfrom database.connections_mdb import add_connection, all_connections, if_active, delete_connection\nfrom info import ADMINS\nfrom utils import temp\nimport logging\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.ERROR)\n\n\n@Client.on_message((filters.private | filters.group) & filters.command('connect'))\nasync def addconnection(client, message):\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n\n    if chat_type == enums.ChatType.PRIVATE:\n        try:\n            cmd, group_id = message.text.split(\" \", 1)\n        except:\n            await message.reply_text(\n                \"<b>Enter in correct format!</b>\\n\\n\"\n                \"<code>/connect groupid</code>\\n\\n\"\n                \"<i>Get your Group id by adding this bot to your group and use  <code>/id</code></i>\",\n                quote=True\n            )\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        group_id = message.chat.id\n\n    try:\n        st = await client.get_chat_member(group_id, userid)\n        if (\n                st.status != enums.ChatMemberStatus.ADMINISTRATOR\n                and st.status != enums.ChatMemberStatus.OWNER\n                and userid not in ADMINS\n        ):\n            await message.reply_text(\"You should be an admin in Given group!\", quote=True)\n            return\n    except Exception as e:\n        logger.exception(e)\n        await message.reply_text(\n            \"Invalid Group ID!\\n\\nIf correct, Make sure I'm present in your group!!\",\n            quote=True,\n        )\n\n        return\n    try:\n        st = await client.get_chat_member(group_id, \"me\")\n        if st.status == enums.ChatMemberStatus.ADMINISTRATOR:\n            ttl = await client.get_chat(group_id)\n            title = ttl.title\n\n            addcon = await add_connection(str(group_id), str(userid))\n            if addcon:\n                await message.reply_text(\n                    f\"Successfully connected to **{title}**\\nNow manage your group from my pm !\",\n                    quote=True,\n                    parse_mode=enums.ParseMode.MARKDOWN\n                )\n                if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n                    await client.send_message(\n                        userid,\n                        f\"Connected to **{title}** !\",\n                        parse_mode=enums.ParseMode.MARKDOWN\n                    )\n            else:\n                await message.reply_text(\n                    \"You're already connected to this chat!\",\n                    quote=True\n                )\n        else:\n            await message.reply_text(\"Add me as an admin in group\", quote=True)\n    except Exception as e:\n        logger.exception(e)\n        await message.reply_text('Some error occurred! Try again later.', quote=True)\n        return\n\n\n@Client.on_message((filters.private | filters.group) & filters.command('disconnect'))\nasync def deleteconnection(client, message):\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n\n    if chat_type == enums.ChatType.PRIVATE:\n        await message.reply_text(\"Run /connections to view or disconnect from groups!\", quote=True)\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        group_id = message.chat.id\n\n        st = await client.get_chat_member(group_id, userid)\n        if (\n                st.status != enums.ChatMemberStatus.ADMINISTRATOR\n                and st.status != enums.ChatMemberStatus.OWNER\n                and str(userid) not in ADMINS\n        ):\n            return\n\n        delcon = await delete_connection(str(userid), str(group_id))\n        if delcon:\n            await message.reply_text(\"Successfully disconnected from this chat\", quote=True)\n        else:\n            await message.reply_text(\"This chat isn't connected to me!\\nDo /connect to connect.\", quote=True)\n\n\n@Client.on_message(filters.private & filters.command([\"connections\"]))\nasync def connections(client, message):\n    userid = message.from_user.id\n\n    groupids = await all_connections(str(userid))\n    if groupids is None:\n        await message.reply_text(\n            \"There are no active connections!! Connect to some groups first.\",\n            quote=True\n        )\n        return\n    buttons = []\n    for groupid in groupids:\n        try:\n            ttl = await client.get_chat(int(groupid))\n            title = ttl.title\n            active = await if_active(str(userid), str(groupid))\n            act = \" - ACTIVE\" if active else \"\"\n            buttons.append(\n                [\n                    InlineKeyboardButton(\n                        text=f\"{title}{act}\", callback_data=f\"groupcb:{groupid}:{act}\"\n                    )\n                ]\n            )\n        except:\n            pass\n    if buttons:\n        await message.reply_text(\n            \"Your connected group details ;\\n\\n\",\n            reply_markup=InlineKeyboardMarkup(buttons),\n            quote=True\n        )\n    else:\n        await message.reply_text(\n            \"There are no active connections!! Connect to some groups first.\",\n            quote=True\n        )\n"
  },
  {
    "path": "plugins/delete_files.py",
    "content": "import re\r\nimport logging\r\nfrom pyrogram import Client, filters\r\nfrom info import DELETE_CHANNELS\r\nfrom database.ia_filterdb import Media, unpack_new_file_id\r\n\r\nlogger = logging.getLogger(__name__)\r\n\r\nmedia_filter = filters.document | filters.video | filters.audio\r\n\r\n\r\n@Client.on_message(filters.chat(DELETE_CHANNELS) & media_filter)\r\nasync def deletemultiplemedia(bot, message):\r\n    \"\"\"Delete Multiple files from database\"\"\"\r\n\r\n    for file_type in (\"document\", \"video\", \"audio\"):\r\n        media = getattr(message, file_type, None)\r\n        if media is not None:\r\n            break\r\n    else:\r\n        return\r\n\r\n    file_id, file_ref = unpack_new_file_id(media.file_id)\r\n\r\n    result = await Media.collection.delete_one({\r\n        '_id': file_id,\r\n    })\r\n    if result.deleted_count:\r\n        logger.info('File is successfully deleted from database.')\r\n    else:\r\n        file_name = re.sub(r\"(_|\\-|\\.|\\+)\", \" \", str(media.file_name))\r\n        result = await Media.collection.delete_many({\r\n            'file_name': file_name,\r\n            'file_size': media.file_size,\r\n            'mime_type': media.mime_type\r\n            })\r\n        if result.deleted_count:\r\n            logger.info('File is successfully deleted from database.')\r\n        else:\r\n            result = await Media.collection.delete_many({\r\n                'file_name': media.file_name,\r\n                'file_size': media.file_size,\r\n                'mime_type': media.mime_type\r\n            })\r\n            if result.deleted_count:\r\n                logger.info('File is successfully deleted from database.')\r\n            else:\r\n                logger.info('File not found in database.')\r\n"
  },
  {
    "path": "plugins/filters.py",
    "content": "import io\nfrom pyrogram import filters, Client, enums\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup\nfrom database.filters_mdb import(\n   add_filter,\n   get_filters,\n   delete_filter,\n   count_filters\n)\n\nfrom database.connections_mdb import active_connection\nfrom utils import get_file_id, parser, split_quotes\nfrom info import ADMINS\n\n\n@Client.on_message(filters.command(['filter', 'addf']) & filters.incoming)\nasync def addfilter(client, message):\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n    args = message.text.html.split(None, 1)\n\n    if chat_type == enums.ChatType.PRIVATE:\n        grpid = await active_connection(str(userid))\n        if grpid is not None:\n            grp_id = grpid\n            try:\n                chat = await client.get_chat(grpid)\n                title = chat.title\n            except:\n                await message.reply_text(\"Make sure I'm present in your group!!\", quote=True)\n                return\n        else:\n            await message.reply_text(\"I'm not connected to any groups!\", quote=True)\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        grp_id = message.chat.id\n        title = message.chat.title\n\n    else:\n        return\n\n    st = await client.get_chat_member(grp_id, userid)\n    if (\n        st.status != enums.ChatMemberStatus.ADMINISTRATOR\n        and st.status != enums.ChatMemberStatus.OWNER\n        and str(userid) not in ADMINS\n    ):\n        return\n\n\n    if len(args) < 2:\n        await message.reply_text(\"Command Incomplete :(\", quote=True)\n        return\n\n    extracted = split_quotes(args[1])\n    text = extracted[0].lower()\n\n    if not message.reply_to_message and len(extracted) < 2:\n        await message.reply_text(\"Add some content to save your filter!\", quote=True)\n        return\n\n    if (len(extracted) >= 2) and not message.reply_to_message:\n        reply_text, btn, alert = parser(extracted[1], text)\n        fileid = None\n        if not reply_text:\n            await message.reply_text(\"You cannot have buttons alone, give some text to go with it!\", quote=True)\n            return\n\n    elif message.reply_to_message and message.reply_to_message.reply_markup:\n        try:\n            rm = message.reply_to_message.reply_markup\n            btn = rm.inline_keyboard\n            msg = get_file_id(message.reply_to_message)\n            if msg:\n                fileid = msg.file_id\n                reply_text = message.reply_to_message.caption.html\n            else:\n                reply_text = message.reply_to_message.text.html\n                fileid = None\n            alert = None\n        except:\n            reply_text = \"\"\n            btn = \"[]\" \n            fileid = None\n            alert = None\n\n    elif message.reply_to_message and message.reply_to_message.media:\n        try:\n            msg = get_file_id(message.reply_to_message)\n            fileid = msg.file_id if msg else None\n            reply_text, btn, alert = parser(extracted[1], text) if message.reply_to_message.sticker else parser(message.reply_to_message.caption.html, text)\n        except:\n            reply_text = \"\"\n            btn = \"[]\"\n            alert = None\n    elif message.reply_to_message and message.reply_to_message.text:\n        try:\n            fileid = None\n            reply_text, btn, alert = parser(message.reply_to_message.text.html, text)\n        except:\n            reply_text = \"\"\n            btn = \"[]\"\n            alert = None\n    else:\n        return\n\n    await add_filter(grp_id, text, reply_text, btn, fileid, alert)\n\n    await message.reply_text(\n        f\"Filter for  `{text}`  added in  **{title}**\",\n        quote=True,\n        parse_mode=enums.ParseMode.MARKDOWN\n    )\n\n\n@Client.on_message(filters.command(['viewfilters', 'filters']) & filters.incoming)\nasync def get_all(client, message):\n    \n    chat_type = message.chat.type\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    if chat_type == enums.ChatType.PRIVATE:\n        userid = message.from_user.id\n        grpid = await active_connection(str(userid))\n        if grpid is not None:\n            grp_id = grpid\n            try:\n                chat = await client.get_chat(grpid)\n                title = chat.title\n            except:\n                await message.reply_text(\"Make sure I'm present in your group!!\", quote=True)\n                return\n        else:\n            await message.reply_text(\"I'm not connected to any groups!\", quote=True)\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        grp_id = message.chat.id\n        title = message.chat.title\n\n    else:\n        return\n\n    st = await client.get_chat_member(grp_id, userid)\n    if (\n        st.status != enums.ChatMemberStatus.ADMINISTRATOR\n        and st.status != enums.ChatMemberStatus.OWNER\n        and str(userid) not in ADMINS\n    ):\n        return\n\n    texts = await get_filters(grp_id)\n    count = await count_filters(grp_id)\n    if count:\n        filterlist = f\"Total number of filters in **{title}** : {count}\\n\\n\"\n\n        for text in texts:\n            keywords = \" ×  `{}`\\n\".format(text)\n\n            filterlist += keywords\n\n        if len(filterlist) > 4096:\n            with io.BytesIO(str.encode(filterlist.replace(\"`\", \"\"))) as keyword_file:\n                keyword_file.name = \"keywords.txt\"\n                await message.reply_document(\n                    document=keyword_file,\n                    quote=True\n                )\n            return\n    else:\n        filterlist = f\"There are no active filters in **{title}**\"\n\n    await message.reply_text(\n        text=filterlist,\n        quote=True,\n        parse_mode=enums.ParseMode.MARKDOWN\n    )\n        \n@Client.on_message(filters.command('del') & filters.incoming)\nasync def deletefilter(client, message):\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n\n    if chat_type == enums.ChatType.PRIVATE:\n        grpid  = await active_connection(str(userid))\n        if grpid is not None:\n            grp_id = grpid\n            try:\n                chat = await client.get_chat(grpid)\n                title = chat.title\n            except:\n                await message.reply_text(\"Make sure I'm present in your group!!\", quote=True)\n                return\n        else:\n            await message.reply_text(\"I'm not connected to any groups!\", quote=True)\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        grp_id = message.chat.id\n        title = message.chat.title\n\n    else:\n        return\n\n    st = await client.get_chat_member(grp_id, userid)\n    if (\n        st.status != enums.ChatMemberStatus.ADMINISTRATOR\n        and st.status != enums.ChatMemberStatus.OWNER\n        and str(userid) not in ADMINS\n    ):\n        return\n\n    try:\n        cmd, text = message.text.split(\" \", 1)\n    except:\n        await message.reply_text(\n            \"<i>Mention the filtername which you wanna delete!</i>\\n\\n\"\n            \"<code>/del filtername</code>\\n\\n\"\n            \"Use /viewfilters to view all available filters\",\n            quote=True\n        )\n        return\n\n    query = text.lower()\n\n    await delete_filter(message, query, grp_id)\n        \n\n@Client.on_message(filters.command('delall') & filters.incoming)\nasync def delallconfirm(client, message):\n    userid = message.from_user.id if message.from_user else None\n    if not userid:\n        return await message.reply(f\"You are anonymous admin. Use /connect {message.chat.id} in PM\")\n    chat_type = message.chat.type\n\n    if chat_type == enums.ChatType.PRIVATE:\n        grpid  = await active_connection(str(userid))\n        if grpid is not None:\n            grp_id = grpid\n            try:\n                chat = await client.get_chat(grpid)\n                title = chat.title\n            except:\n                await message.reply_text(\"Make sure I'm present in your group!!\", quote=True)\n                return\n        else:\n            await message.reply_text(\"I'm not connected to any groups!\", quote=True)\n            return\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        grp_id = message.chat.id\n        title = message.chat.title\n\n    else:\n        return\n\n\n    st = await client.get_chat_member(grp_id, userid)\n    if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS):\n        await message.reply_text(\n            f\"This will delete all filters from '{title}'.\\nDo you want to continue??\",\n            reply_markup=InlineKeyboardMarkup([\n                [InlineKeyboardButton(text=\"YES\",callback_data=\"delallconfirm\")],\n                [InlineKeyboardButton(text=\"CANCEL\",callback_data=\"delallcancel\")]\n            ]),\n            quote=True\n        )\n\n"
  },
  {
    "path": "plugins/genlink.py",
    "content": "import re\nfrom pyrogram import filters, Client, enums\nfrom pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified\nfrom info import ADMINS, LOG_CHANNEL, FILE_STORE_CHANNEL, PUBLIC_FILE_STORE\nfrom database.ia_filterdb import unpack_new_file_id\nfrom utils import temp\nimport re\nimport os\nimport json\nimport base64\nimport logging\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.INFO)\n\nasync def allowed(_, __, message):\n    if PUBLIC_FILE_STORE:\n        return True\n    if message.from_user and message.from_user.id in ADMINS:\n        return True\n    return False\n\n@Client.on_message(filters.command(['link', 'plink']) & filters.create(allowed))\nasync def gen_link_s(bot, message):\n    replied = message.reply_to_message\n    if not replied:\n        return await message.reply('Reply to a message to get a shareable link.')\n    file_type = replied.media\n    if file_type not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]:\n        return await message.reply(\"Reply to a supported media\")\n    if message.has_protected_content and message.chat.id not in ADMINS:\n        return await message.reply(\"okDa\")\n    file_id, ref = unpack_new_file_id((getattr(replied, file_type.value)).file_id)\n    string = 'filep_' if message.text.lower().strip() == \"/plink\" else 'file_'\n    string += file_id\n    outstr = base64.urlsafe_b64encode(string.encode(\"ascii\")).decode().strip(\"=\")\n    await message.reply(f\"Here is your Link:\\nhttps://t.me/{temp.U_NAME}?start={outstr}\")\n    \n    \n@Client.on_message(filters.command(['batch', 'pbatch']) & filters.create(allowed))\nasync def gen_link_batch(bot, message):\n    if \" \" not in message.text:\n        return await message.reply(\"Use correct format.\\nExample <code>/batch https://t.me/piroxbots/10 https://t.me/piroxbots/20</code>.\")\n    links = message.text.strip().split(\" \")\n    if len(links) != 3:\n        return await message.reply(\"Use correct format.\\nExample <code>/batch https://t.me/piroxbots/10 https://t.me/piroxbots/20</code>.\")\n    cmd, first, last = links\n    regex = re.compile(\"(https://)?(t\\.me/|telegram\\.me/|telegram\\.dog/)(c/)?(\\d+|[a-zA-Z_0-9]+)/(\\d+)$\")\n    match = regex.match(first)\n    if not match:\n        return await message.reply('Invalid link')\n    f_chat_id = match.group(4)\n    f_msg_id = int(match.group(5))\n    if f_chat_id.isnumeric():\n        f_chat_id  = int((\"-100\" + f_chat_id))\n\n    match = regex.match(last)\n    if not match:\n        return await message.reply('Invalid link')\n    l_chat_id = match.group(4)\n    l_msg_id = int(match.group(5))\n    if l_chat_id.isnumeric():\n        l_chat_id  = int((\"-100\" + l_chat_id))\n\n    if f_chat_id != l_chat_id:\n        return await message.reply(\"Chat ids not matched.\")\n    try:\n        chat_id = (await bot.get_chat(f_chat_id)).id\n    except ChannelInvalid:\n        return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.')\n    except (UsernameInvalid, UsernameNotModified):\n        return await message.reply('Invalid Link specified.')\n    except Exception as e:\n        return await message.reply(f'Errors - {e}')\n\n    sts = await message.reply(\"Generating link for your message.\\nThis may take time depending upon number of messages\")\n    if chat_id in FILE_STORE_CHANNEL:\n        string = f\"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}\"\n        b_64 = base64.urlsafe_b64encode(string.encode(\"ascii\")).decode().strip(\"=\")\n        return await sts.edit(f\"Here is your link https://t.me/{temp.U_NAME}?start=DSTORE-{b_64}\")\n\n    FRMT = \"Generating Link...\\nTotal Messages: `{total}`\\nDone: `{current}`\\nRemaining: `{rem}`\\nStatus: `{sts}`\"\n\n    outlist = []\n\n    # file store without db channel\n    og_msg = 0\n    tot = 0\n    async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id):\n        tot += 1\n        if msg.empty or msg.service:\n            continue\n        if not msg.media:\n            # only media messages supported.\n            continue\n        try:\n            file_type = msg.media\n            file = getattr(msg, file_type.value)\n            caption = getattr(msg, 'caption', '')\n            if caption:\n                caption = caption.html\n            if file:\n                file = {\n                    \"file_id\": file.file_id,\n                    \"caption\": caption,\n                    \"title\": getattr(file, \"file_name\", \"\"),\n                    \"size\": file.file_size,\n                    \"protect\": cmd.lower().strip() == \"/pbatch\",\n                }\n\n                og_msg +=1\n                outlist.append(file)\n        except:\n            pass\n        if not og_msg % 20:\n            try:\n                await sts.edit(FRMT.format(total=l_msg_id-f_msg_id, current=tot, rem=((l_msg_id-f_msg_id) - tot), sts=\"Saving Messages\"))\n            except:\n                pass\n    with open(f\"batchmode_{message.from_user.id}.json\", \"w+\") as out:\n        json.dump(outlist, out)\n    post = await bot.send_document(LOG_CHANNEL, f\"batchmode_{message.from_user.id}.json\", file_name=\"Batch.json\", caption=\"⚠️Generated for filestore.\")\n    os.remove(f\"batchmode_{message.from_user.id}.json\")\n    file_id, ref = unpack_new_file_id(post.document.file_id)\n    await sts.edit(f\"Here is your link\\nContains `{og_msg}` files.\\n https://t.me/{temp.U_NAME}?start=BATCH-{file_id}\")\n"
  },
  {
    "path": "plugins/gfilters.py",
    "content": "import io\r\nfrom pyrogram import filters, Client, enums\r\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup\r\nfrom database.gfilters_mdb import(\r\n   add_gfilter,\r\n   get_gfilters,\r\n   delete_gfilter,\r\n   count_gfilters\r\n)\r\n\r\nfrom database.connections_mdb import active_connection\r\nfrom utils import get_file_id, gfilterparser, split_quotes\r\nfrom info import ADMINS\r\n\r\n\r\n@Client.on_message(filters.command(['gfilter', 'addg']) & filters.incoming & filters.user(ADMINS))\r\nasync def addgfilter(client, message):\r\n    args = message.text.html.split(None, 1)\r\n\r\n    if len(args) < 2:\r\n        await message.reply_text(\"Command Incomplete :(\", quote=True)\r\n        return\r\n\r\n    extracted = split_quotes(args[1])\r\n    text = extracted[0].lower()\r\n\r\n    if not message.reply_to_message and len(extracted) < 2:\r\n        await message.reply_text(\"Add some content to save your filter!\", quote=True)\r\n        return\r\n\r\n    if (len(extracted) >= 2) and not message.reply_to_message:\r\n        reply_text, btn, alert = gfilterparser(extracted[1], text)\r\n        fileid = None\r\n        if not reply_text:\r\n            await message.reply_text(\"You cannot have buttons alone, give some text to go with it!\", quote=True)\r\n            return\r\n\r\n    elif message.reply_to_message and message.reply_to_message.reply_markup:\r\n        try:\r\n            rm = message.reply_to_message.reply_markup\r\n            btn = rm.inline_keyboard\r\n            msg = get_file_id(message.reply_to_message)\r\n            if msg:\r\n                fileid = msg.file_id\r\n                reply_text = message.reply_to_message.caption.html\r\n            else:\r\n                reply_text = message.reply_to_message.text.html\r\n                fileid = None\r\n            alert = None\r\n        except:\r\n            reply_text = \"\"\r\n            btn = \"[]\" \r\n            fileid = None\r\n            alert = None\r\n\r\n    elif message.reply_to_message and message.reply_to_message.media:\r\n        try:\r\n            msg = get_file_id(message.reply_to_message)\r\n            fileid = msg.file_id if msg else None\r\n            reply_text, btn, alert = gfilterparser(extracted[1], text) if message.reply_to_message.sticker else gfilterparser(message.reply_to_message.caption.html, text)\r\n        except:\r\n            reply_text = \"\"\r\n            btn = \"[]\"\r\n            alert = None\r\n    elif message.reply_to_message and message.reply_to_message.text:\r\n        try:\r\n            fileid = None\r\n            reply_text, btn, alert = gfilterparser(message.reply_to_message.text.html, text)\r\n        except:\r\n            reply_text = \"\"\r\n            btn = \"[]\"\r\n            alert = None\r\n    else:\r\n        return\r\n\r\n    await add_gfilter('gfilters', text, reply_text, btn, fileid, alert)\r\n\r\n    await message.reply_text(\r\n        f\"GFilter for  `{text}`  added\",\r\n        quote=True,\r\n        parse_mode=enums.ParseMode.MARKDOWN\r\n    )\r\n\r\n\r\n@Client.on_message(filters.command(['viewgfilters', 'gfilters']) & filters.incoming & filters.user(ADMINS))\r\nasync def get_all_gfilters(client, message):\r\n    texts = await get_gfilters('gfilters')\r\n    count = await count_gfilters('gfilters')\r\n    if count:\r\n        gfilterlist = f\"Total number of gfilters : {count}\\n\\n\"\r\n\r\n        for text in texts:\r\n            keywords = \" ×  `{}`\\n\".format(text)\r\n\r\n            gfilterlist += keywords\r\n\r\n        if len(gfilterlist) > 4096:\r\n            with io.BytesIO(str.encode(gfilterlist.replace(\"`\", \"\"))) as keyword_file:\r\n                keyword_file.name = \"keywords.txt\"\r\n                await message.reply_document(\r\n                    document=keyword_file,\r\n                    quote=True\r\n                )\r\n            return\r\n    else:\r\n        gfilterlist = f\"There are no active gfilters.\"\r\n\r\n    await message.reply_text(\r\n        text=gfilterlist,\r\n        quote=True,\r\n        parse_mode=enums.ParseMode.MARKDOWN\r\n    )\r\n        \r\n@Client.on_message(filters.command('delg') & filters.incoming & filters.user(ADMINS))\r\nasync def deletegfilter(client, message):\r\n    try:\r\n        cmd, text = message.text.split(\" \", 1)\r\n    except:\r\n        await message.reply_text(\r\n            \"<i>Mention the gfiltername which you wanna delete!</i>\\n\\n\"\r\n            \"<code>/delg gfiltername</code>\\n\\n\"\r\n            \"Use /viewgfilters to view all available gfilters\",\r\n            quote=True\r\n        )\r\n        return\r\n\r\n    query = text.lower()\r\n\r\n    await delete_gfilter(message, query, 'gfilters')\r\n\r\n@Client.on_message(filters.command('delallg') & filters.user(ADMINS))\r\nasync def delallgfilters(client, message):\r\n    await message.reply_text(\r\n            f\"Do you want to continue??\",\r\n            reply_markup=InlineKeyboardMarkup([\r\n                [InlineKeyboardButton(text=\"YES\",callback_data=\"gfiltersdeleteallconfirm\")],\r\n                [InlineKeyboardButton(text=\"CANCEL\",callback_data=\"gfiltersdeleteallcancel\")]\r\n            ]),\r\n            quote=True\r\n        )"
  },
  {
    "path": "plugins/index.py",
    "content": "import logging\nimport asyncio\nfrom pyrogram import Client, filters, enums\nfrom pyrogram.errors import FloodWait\nfrom pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, ChatAdminRequired, UsernameInvalid, UsernameNotModified\nfrom info import ADMINS\nfrom info import INDEX_REQ_CHANNEL as LOG_CHANNEL\nfrom database.ia_filterdb import save_file\nfrom pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton\nfrom utils import temp\nimport re\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.INFO)\nlock = asyncio.Lock()\n\n\n@Client.on_callback_query(filters.regex(r'^index'))\nasync def index_files(bot, query):\n    if query.data.startswith('index_cancel'):\n        temp.CANCEL = True\n        return await query.answer(\"Cancelling Indexing\")\n    _, raju, chat, lst_msg_id, from_user = query.data.split(\"#\")\n    if raju == 'reject':\n        await query.message.delete()\n        await bot.send_message(int(from_user),\n                               f'Your Submission for indexing {chat} has been decliened by our moderators.',\n                               reply_to_message_id=int(lst_msg_id))\n        return\n\n    if lock.locked():\n        return await query.answer('Wait until previous process complete.', show_alert=True)\n    msg = query.message\n\n    await query.answer('Processing...⏳', show_alert=True)\n    if int(from_user) not in ADMINS:\n        await bot.send_message(int(from_user),\n                               f'Your Submission for indexing {chat} has been accepted by our moderators and will be added soon.',\n                               reply_to_message_id=int(lst_msg_id))\n    await msg.edit(\n        \"Starting Indexing\",\n        reply_markup=InlineKeyboardMarkup(\n            [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]]\n        )\n    )\n    try:\n        chat = int(chat)\n    except:\n        chat = chat\n    await index_files_to_db(int(lst_msg_id), chat, msg, bot)\n\n\n@Client.on_message((filters.forwarded | (filters.regex(\"(https://)?(t\\.me/|telegram\\.me/|telegram\\.dog/)(c/)?(\\d+|[a-zA-Z_0-9]+)/(\\d+)$\")) & filters.text ) & filters.private & filters.incoming)\nasync def send_for_index(bot, message):\n    if message.text:\n        regex = re.compile(\"(https://)?(t\\.me/|telegram\\.me/|telegram\\.dog/)(c/)?(\\d+|[a-zA-Z_0-9]+)/(\\d+)$\")\n        match = regex.match(message.text)\n        if not match:\n            return await message.reply('Invalid link')\n        chat_id = match.group(4)\n        last_msg_id = int(match.group(5))\n        if chat_id.isnumeric():\n            chat_id  = int((\"-100\" + chat_id))\n    elif message.forward_from_chat.type == enums.ChatType.CHANNEL:\n        last_msg_id = message.forward_from_message_id\n        chat_id = message.forward_from_chat.username or message.forward_from_chat.id\n    else:\n        return\n    try:\n        await bot.get_chat(chat_id)\n    except ChannelInvalid:\n        return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.')\n    except (UsernameInvalid, UsernameNotModified):\n        return await message.reply('Invalid Link specified.')\n    except Exception as e:\n        logger.exception(e)\n        return await message.reply(f'Errors - {e}')\n    try:\n        k = await bot.get_messages(chat_id, last_msg_id)\n    except:\n        return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private')\n    if k.empty:\n        return await message.reply('This may be group and iam not a admin of the group.')\n\n    if message.from_user.id in ADMINS:\n        buttons = [\n            [\n                InlineKeyboardButton('Yes',\n                                     callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}')\n            ],\n            [\n                InlineKeyboardButton('close', callback_data='close_data'),\n            ]\n        ]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        return await message.reply(\n            f'Do you Want To Index This Channel/ Group ?\\n\\nChat ID/ Username: <code>{chat_id}</code>\\nLast Message ID: <code>{last_msg_id}</code>',\n            reply_markup=reply_markup)\n\n    if type(chat_id) is int:\n        try:\n            link = (await bot.create_chat_invite_link(chat_id)).invite_link\n        except ChatAdminRequired:\n            return await message.reply('Make sure iam an admin in the chat and have permission to invite users.')\n    else:\n        link = f\"@{message.forward_from_chat.username}\"\n    buttons = [\n        [\n            InlineKeyboardButton('Accept Index',\n                                 callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}')\n        ],\n        [\n            InlineKeyboardButton('Reject Index',\n                                 callback_data=f'index#reject#{chat_id}#{message.id}#{message.from_user.id}'),\n        ]\n    ]\n    reply_markup = InlineKeyboardMarkup(buttons)\n    await bot.send_message(LOG_CHANNEL,\n                           f'#IndexRequest\\n\\nBy : {message.from_user.mention} (<code>{message.from_user.id}</code>)\\nChat ID/ Username - <code> {chat_id}</code>\\nLast Message ID - <code>{last_msg_id}</code>\\nInviteLink - {link}',\n                           reply_markup=reply_markup)\n    await message.reply('ThankYou For the Contribution, Wait For My Moderators to verify the files.')\n\n\n@Client.on_message(filters.command('setskip') & filters.user(ADMINS))\nasync def set_skip_number(bot, message):\n    if ' ' in message.text:\n        _, skip = message.text.split(\" \")\n        try:\n            skip = int(skip)\n        except:\n            return await message.reply(\"Skip number should be an integer.\")\n        await message.reply(f\"Successfully set SKIP number as {skip}\")\n        temp.CURRENT = int(skip)\n    else:\n        await message.reply(\"Give me a skip number\")\n\n\nasync def index_files_to_db(lst_msg_id, chat, msg, bot):\n    total_files = 0\n    duplicate = 0\n    errors = 0\n    deleted = 0\n    no_media = 0\n    unsupported = 0\n    async with lock:\n        try:\n            current = temp.CURRENT\n            temp.CANCEL = False\n            async for message in bot.iter_messages(chat, lst_msg_id, temp.CURRENT):\n                if temp.CANCEL:\n                    await msg.edit(f\"Successfully Cancelled!!\\n\\nSaved <code>{total_files}</code> files to dataBase!\\nDuplicate Files Skipped: <code>{duplicate}</code>\\nDeleted Messages Skipped: <code>{deleted}</code>\\nNon-Media messages skipped: <code>{no_media + unsupported}</code>(Unsupported Media - `{unsupported}` )\\nErrors Occurred: <code>{errors}</code>\")\n                    break\n                current += 1\n                if current % 20 == 0:\n                    can = [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]]\n                    reply = InlineKeyboardMarkup(can)\n                    await asyncio.sleep(2)\n                    await msg.edit_text(\n                        text=f\"Total messages fetched: <code>{current}</code>\\nTotal messages saved: <code>{total_files}</code>\\nDuplicate Files Skipped: <code>{duplicate}</code>\\nDeleted Messages Skipped: <code>{deleted}</code>\\nNon-Media messages skipped: <code>{no_media + unsupported}</code>(Unsupported Media - `{unsupported}` )\\nErrors Occurred: <code>{errors}</code>\",\n                        reply_markup=reply)\n                if message.empty:\n                    deleted += 1\n                    continue\n                elif not message.media:\n                    no_media += 1\n                    continue\n                elif message.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]:\n                    unsupported += 1\n                    continue\n                media = getattr(message, message.media.value, None)\n                if not media:\n                    unsupported += 1\n                    continue\n                media.file_type = message.media.value\n                media.caption = message.caption\n                aynav, vnay = await save_file(media)\n                if aynav:\n                    total_files += 1\n                elif vnay == 0:\n                    duplicate += 1\n                elif vnay == 2:\n                    errors += 1\n        except Exception as e:\n            logger.exception(e)\n            await msg.edit(f'Error: {e}')\n        else:\n            await msg.edit(f'Succesfully saved <code>{total_files}</code> to dataBase!\\nDuplicate Files Skipped: <code>{duplicate}</code>\\nDeleted Messages Skipped: <code>{deleted}</code>\\nNon-Media messages skipped: <code>{no_media + unsupported}</code>(Unsupported Media - `{unsupported}` )\\nErrors Occurred: <code>{errors}</code>')\n"
  },
  {
    "path": "plugins/inline.py",
    "content": "import logging\nfrom pyrogram import Client, emoji, filters\nfrom pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultCachedDocument, InlineQuery\nfrom database.ia_filterdb import get_search_results\nfrom utils import is_subscribed, get_size, temp\nfrom info import CACHE_TIME, AUTH_USERS, AUTH_CHANNEL, CUSTOM_FILE_CAPTION\nfrom database.connections_mdb import active_connection\n\nlogger = logging.getLogger(__name__)\ncache_time = 0 if AUTH_USERS or AUTH_CHANNEL else CACHE_TIME\n\nasync def inline_users(query: InlineQuery):\n    if AUTH_USERS:\n        if query.from_user and query.from_user.id in AUTH_USERS:\n            return True\n        else:\n            return False\n    if query.from_user and query.from_user.id not in temp.BANNED_USERS:\n        return True\n    return False\n\n@Client.on_inline_query()\nasync def answer(bot, query):\n    \"\"\"𝖲𝗁𝗈𝗐 𝖲𝖾𝖺𝗋𝖼𝗁 𝖱𝖾𝗌𝗎𝗅𝗍𝗌 𝖥𝗈𝗋 𝖦𝗂𝗏𝖾𝗇 𝖨𝗇𝗅𝗂𝗇𝖾 𝖰𝗎𝖾𝗋𝗒\"\"\"\n    chat_id = await active_connection(str(query.from_user.id))\n    \n    if not await inline_users(query):\n        await query.answer(results=[],\n                           cache_time=0,\n                           switch_pm_text='okDa',\n                           switch_pm_parameter=\"hehe\")\n        return\n\n    if AUTH_CHANNEL and not await is_subscribed(bot, query):\n        await query.answer(results=[],\n                           cache_time=0,\n                           switch_pm_text='𝖸𝗈𝗎 𝖧𝖺𝗏𝖾 𝖳𝗈 𝖲𝗎𝖻𝗌𝖼𝗋𝗂𝖻𝖾 𝖬𝗒 𝖢𝗁𝖺𝗇𝗇𝖾𝗅 𝖳𝗈 𝖴𝗌𝖾 𝖬𝖾 :)',\n                           switch_pm_parameter=\"subscribe\")\n        return\n\n    results = []\n    if '|' in query.query:\n        string, file_type = query.query.split('|', maxsplit=1)\n        string = string.strip()\n        file_type = file_type.strip().lower()\n    else:\n        string = query.query.strip()\n        file_type = None\n\n    offset = int(query.offset or 0)\n    reply_markup = get_reply_markup(query=string)\n    files, next_offset, total = await get_search_results(\n                                                  chat_id,\n                                                  string,\n                                                  file_type=file_type,\n                                                  max_results=10,\n                                                  offset=offset)\n\n    for file in files:\n        title=file.file_name\n        size=get_size(file.file_size)\n        f_caption=file.caption\n        if CUSTOM_FILE_CAPTION:\n            try:\n                f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)\n            except Exception as e:\n                logger.exception(e)\n                f_caption=f_caption\n        if f_caption is None:\n            f_caption = f\"{file.file_name}\"\n        results.append(\n            InlineQueryResultCachedDocument(\n                title=file.file_name,\n                document_file_id=file.file_id,\n                caption=f_caption,\n                description=f'Size: {get_size(file.file_size)}\\nType: {file.file_type}',\n                reply_markup=reply_markup))\n\n    if results:\n        switch_pm_text = f\"{emoji.FILE_FOLDER} 𝖧𝖾𝗋𝖾 𝖨𝗌 𝖳𝗁𝖾 𝖱𝖾𝗌𝗎𝗅𝗍𝗌 \"\n        if string:\n            switch_pm_text += f\" for {string}\"\n        try:\n            await query.answer(results=results,\n                           is_personal = True,\n                           cache_time=cache_time,\n                           switch_pm_text=switch_pm_text,\n                           switch_pm_parameter=\"start\",\n                           next_offset=str(next_offset))\n        except QueryIdInvalid:\n            pass\n        except Exception as e:\n            logging.exception(str(e))\n    else:\n        switch_pm_text = f'{emoji.CROSS_MARK} 𝖭𝗈 𝖱𝖾𝗌𝗎𝗅𝗍𝗌 𝖥𝗈𝗎𝗇𝖽'\n        if string:\n            switch_pm_text += f' for \"{string}\"'\n\n        await query.answer(results=[],\n                           is_personal = True,\n                           cache_time=cache_time,\n                           switch_pm_text=switch_pm_text,\n                           switch_pm_parameter=\"okay\")\n\n\ndef get_reply_markup(query):\n    buttons = [\n        [\n            InlineKeyboardButton('🔎 𝖲𝖾𝖺𝗋𝖼𝗁 𝖠𝗀𝖺𝗂𝗇', switch_inline_query_current_chat=query),\n            InlineKeyboardButton('⚡𝖴𝗉𝖽𝖺𝗍𝖾𝗌 ⚡', url=\"https://t.me/piroxbots\")\n        ]\n        ]\n    return InlineKeyboardMarkup(buttons)\n\n\n\n"
  },
  {
    "path": "plugins/json.py",
    "content": "import os\r\nfrom pyrogram import Client, filters\r\nfrom pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message, CallbackQuery\r\n\r\n@Client.on_message(filters.command([\"json\", 'js', 'showjson']))\r\nasync def jsonify(_, message):\r\n    the_real_message = None\r\n    reply_to_id = None\r\n\r\n    if message.reply_to_message:\r\n        the_real_message = message.reply_to_message\r\n    else:\r\n        the_real_message = message\r\n    try:\r\n        pk = InlineKeyboardMarkup(\r\n            [\r\n                [\r\n                    InlineKeyboardButton(\r\n                        text=\"🔐 𝖢𝗅𝗈𝗌𝖾\",\r\n                        callback_data=\"close_data\"\r\n                    )\r\n                ]\r\n            ]\r\n        )\r\n        await message.reply_text(f\"<code>{the_real_message}</code>\", reply_markup=pk, quote=True)\r\n    except Exception as e:\r\n        with open(\"json.text\", \"w+\", encoding=\"utf8\") as out_file:\r\n            out_file.write(str(the_real_message))\r\n        reply_markup = InlineKeyboardMarkup(\r\n            [\r\n                [\r\n                    InlineKeyboardButton(\r\n                        text=\"🔐 𝖢𝗅𝗈𝗌𝖾\",\r\n                        callback_data=\"close_data\"\r\n                    )\r\n                ]\r\n            ]\r\n        )\r\n        await message.reply_document(\r\n            document=\"json.text\",\r\n            caption=str(e),\r\n            disable_notification=True,\r\n            quote=True,\r\n            reply_markup=reply_markup\r\n        )            \r\n        os.remove(\"json.text\")\r\n\r\n"
  },
  {
    "path": "plugins/misc.py",
    "content": "import os\nfrom pyrogram import Client, filters, enums\nfrom pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty\nfrom info import IMDB_TEMPLATE\nfrom utils import extract_user, get_file_id, get_poster, last_online\nimport time\nfrom datetime import datetime\nfrom pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery\nimport logging\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.ERROR)\n\n@Client.on_message(filters.command('id'))\nasync def showid(client, message):\n    chat_type = message.chat.type\n    if chat_type == enums.ChatType.PRIVATE:\n        user_id = message.chat.id\n        first = message.from_user.first_name\n        last = message.from_user.last_name or \"\"\n        username = message.from_user.username\n        dc_id = message.from_user.dc_id or \"\"\n        await message.reply_text(\n            f\"<b>➲ First Name:</b> {first}\\n<b>➲ Last Name:</b> {last}\\n<b>➲ Username:</b> {username}\\n<b>➲ Telegram ID:</b> <code>{user_id}</code>\\n<b>➲ Data Centre:</b> <code>{dc_id}</code>\",\n            quote=True\n        )\n\n    elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n        _id = \"\"\n        _id += (\n            \"<b>➲ Chat ID</b>: \"\n            f\"<code>{message.chat.id}</code>\\n\"\n        )\n        if message.reply_to_message:\n            _id += (\n                \"<b>➲ User ID</b>: \"\n                f\"<code>{message.from_user.id if message.from_user else 'Anonymous'}</code>\\n\"\n                \"<b>➲ Replied User ID</b>: \"\n                f\"<code>{message.reply_to_message.from_user.id if message.reply_to_message.from_user else 'Anonymous'}</code>\\n\"\n            )\n            file_info = get_file_id(message.reply_to_message)\n        else:\n            _id += (\n                \"<b>➲ User ID</b>: \"\n                f\"<code>{message.from_user.id if message.from_user else 'Anonymous'}</code>\\n\"\n            )\n            file_info = get_file_id(message)\n        if file_info:\n            _id += (\n                f\"<b>{file_info.message_type}</b>: \"\n                f\"<code>{file_info.file_id}</code>\\n\"\n            )\n        await message.reply_text(\n            _id,\n            quote=True\n        )\n\n@Client.on_message(filters.command([\"info\"]))\nasync def who_is(client, message):\n    status_message = await message.reply_text(\n        \"`Fetching user info...`\"\n    )\n    await status_message.edit(\n        \"`Processing user info...`\"\n    )\n    from_user = None\n    from_user_id, _ = extract_user(message)\n    try:\n        from_user = await client.get_users(from_user_id)\n    except Exception as error:\n        await status_message.edit(str(error))\n        return\n    if from_user is None:\n        return await status_message.edit(\"no valid user_id / message specified\")\n    message_out_str = \"\"\n    message_out_str += f\"<b>➲First Name:</b> {from_user.first_name}\\n\"\n    last_name = from_user.last_name or \"<b>None</b>\"\n    message_out_str += f\"<b>➲Last Name:</b> {last_name}\\n\"\n    message_out_str += f\"<b>➲Telegram ID:</b> <code>{from_user.id}</code>\\n\"\n    username = from_user.username or \"<b>None</b>\"\n    dc_id = from_user.dc_id or \"[User Doesn't Have A Valid DP]\"\n    message_out_str += f\"<b>➲Data Centre:</b> <code>{dc_id}</code>\\n\"\n    message_out_str += f\"<b>➲User Name:</b> @{username}\\n\"\n    message_out_str += f\"<b>➲User 𝖫𝗂𝗇𝗄:</b> <a href='tg://user?id={from_user.id}'><b>Click Here</b></a>\\n\"\n    if message.chat.type in ((enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)):\n        try:\n            chat_member_p = await message.chat.get_member(from_user.id)\n            joined_date = (\n                chat_member_p.joined_date or datetime.now()\n            ).strftime(\"%Y.%m.%d %H:%M:%S\")\n            message_out_str += (\n                \"<b>➲Joined this Chat on:</b> <code>\"\n                f\"{joined_date}\"\n                \"</code>\\n\"\n            )\n        except UserNotParticipant:\n            pass\n    chat_photo = from_user.photo\n    if chat_photo:\n        local_user_photo = await client.download_media(\n            message=chat_photo.big_file_id\n        )\n        buttons = [[\n            InlineKeyboardButton('🔐 𝖢𝗅𝗈𝗌𝖾', callback_data='close_data')\n        ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await message.reply_photo(\n            photo=local_user_photo,\n            quote=True,\n            reply_markup=reply_markup,\n            caption=message_out_str,\n            parse_mode=enums.ParseMode.HTML,\n            disable_notification=True\n        )\n        os.remove(local_user_photo)\n    else:\n        buttons = [[\n            InlineKeyboardButton('🔐 𝖢𝗅𝗈𝗌𝖾', callback_data='close_data')\n        ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await message.reply_text(\n            text=message_out_str,\n            reply_markup=reply_markup,\n            quote=True,\n            parse_mode=enums.ParseMode.HTML,\n            disable_notification=True\n        )\n    await status_message.delete()\n\n@Client.on_message(filters.command([\"imdb\", 'search']))\nasync def imdb_search(client, message):\n    if ' ' in message.text:\n        k = await message.reply('<b>Searching IMDb....</b>')\n        r, title = message.text.split(None, 1)\n        movies = await get_poster(title, bulk=True)\n        if not movies:\n            return await message.reply(\"<i><b>No results Found</b></i>\")\n        btn = [\n            [\n                InlineKeyboardButton(\n                    text=f\"{movie.get('title')} - {movie.get('year')}\",\n                    callback_data=f\"imdb#{movie.movieID}\",\n                )\n            ]\n            for movie in movies\n        ]\n        await k.edit('<b>𝖧𝖾𝗋𝖾 𝗂𝗌 𝗐𝗁𝖺𝗍 𝗂 𝖿𝗈𝗎𝗇𝖽 𝗈𝗇 𝖨𝖬𝖣𝖻</b>', reply_markup=InlineKeyboardMarkup(btn))\n    else:\n        await message.reply('Give me a movie / series Name')\n\n@Client.on_callback_query(filters.regex('^imdb'))\nasync def imdb_callback(bot: Client, quer_y: CallbackQuery):\n    i, movie = quer_y.data.split('#')\n    imdb = await get_poster(query=movie, id=True)\n    btn = [\n            [\n                InlineKeyboardButton(\n                    text=f\"{imdb.get('title')}\",\n                    url=imdb['url'],\n                )\n            ]\n        ]\n    message = quer_y.message.reply_to_message or quer_y.message\n    if imdb:\n        caption = IMDB_TEMPLATE.format(\n            query = imdb['title'],\n            title = imdb['title'],\n            votes = imdb['votes'],\n            aka = imdb[\"aka\"],\n            seasons = imdb[\"seasons\"],\n            box_office = imdb['box_office'],\n            localized_title = imdb['localized_title'],\n            kind = imdb['kind'],\n            imdb_id = imdb[\"imdb_id\"],\n            cast = imdb[\"cast\"],\n            runtime = imdb[\"runtime\"],\n            countries = imdb[\"countries\"],\n            certificates = imdb[\"certificates\"],\n            languages = imdb[\"languages\"],\n            director = imdb[\"director\"],\n            writer = imdb[\"writer\"],\n            producer = imdb[\"producer\"],\n            composer = imdb[\"composer\"],\n            cinematographer = imdb[\"cinematographer\"],\n            music_team = imdb[\"music_team\"],\n            distributors = imdb[\"distributors\"],\n            release_date = imdb['release_date'],\n            year = imdb['year'],\n            genres = imdb['genres'],\n            poster = imdb['poster'],\n            plot = imdb['plot'],\n            rating = imdb['rating'],\n            url = imdb['url'],\n            **locals()\n        )\n    else:\n        caption = \"<b>No Results</b>\"\n    if imdb.get('poster'):\n        try:\n            await quer_y.message.reply_photo(photo=imdb['poster'], caption=caption, reply_markup=InlineKeyboardMarkup(btn))\n        except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty):\n            pic = imdb.get('poster')\n            poster = pic.replace('.jpg', \"._V1_UX360.jpg\")\n            await quer_y.message.reply_photo(photo=poster, caption=caption, reply_markup=InlineKeyboardMarkup(btn))\n        except Exception as e:\n            logger.exception(e)\n            await quer_y.message.reply(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False)\n        await quer_y.message.delete()\n    else:\n        await quer_y.message.edit(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False)\n    await quer_y.answer()\n        \n\n        \n"
  },
  {
    "path": "plugins/p_ttishow.py",
    "content": "from pyrogram import Client, filters, enums\nfrom pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery\nfrom pyrogram.errors.exceptions.bad_request_400 import MessageTooLong, PeerIdInvalid\nfrom info import ADMINS, LOG_CHANNEL, SUPPORT_CHAT, MELCOW_VID\nfrom database.users_chats_db import db\nfrom database.ia_filterdb import Media\nfrom utils import get_size, temp, get_settings\nfrom Script import script\nfrom pyrogram.errors import ChatAdminRequired\nimport asyncio \n\n\n\n@Client.on_message(filters.new_chat_members & filters.group)\nasync def save_group(bot, message):\n    r_j_check = [u.id for u in message.new_chat_members]\n    if temp.ME in r_j_check:\n        if not await db.get_chat(message.chat.id):\n            total=await bot.get_chat_members_count(message.chat.id)\n            r_j = message.from_user.mention if message.from_user else \"Anonymous\" \n            await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, r_j))       \n            await db.add_chat(message.chat.id, message.chat.title)\n        if message.chat.id in temp.BANNED_CHATS:\n            buttons = [[\n                InlineKeyboardButton('🌐 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 🌐', url=f\"https://t.me/{SUPPORT_CHAT}\")\n            ]]\n            reply_markup=InlineKeyboardMarkup(buttons)\n            k = await message.reply(\n                text='<b>CHAT NOT ALLOWED 🐞\\n\\nMy admins has restricted me from working here ! If you want to know more about it contact support..</b>',\n                reply_markup=reply_markup,\n            )\n\n            try:\n                await k.pin()\n            except:\n                pass\n            await bot.leave_chat(message.chat.id)\n            return\n        buttons = [[\n            InlineKeyboardButton('🧩 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 🧩', url=f\"https://t.me/{SUPPORT_CHAT}\"),\n            InlineKeyboardButton('⚡𝖴𝗉𝖽𝖺𝗍𝖾𝗌 ⚡', url=f\"https://t.me/piroxbots\")\n        ]]\n        reply_markup=InlineKeyboardMarkup(buttons)\n        await message.reply_text(\n            text=f\"<b>Thankyou For Adding Me In {message.chat.title} ❣️\\n\\nIf you have any questions & doubts about using me contact 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 GROUP.</b>\",\n            reply_markup=reply_markup)\n    else:\n        settings = await get_settings(message.chat.id)\n        if settings[\"welcome\"]:\n            for u in message.new_chat_members:\n                if (temp.MELCOW).get('welcome') is not None:\n                    try:\n                        await (temp.MELCOW['welcome']).delete()\n                    except:\n                        pass\n                temp.MELCOW['welcome'] = await message.reply_video(\n                                                 video=(MELCOW_VID),\n                                                 caption=(script.MELCOW_ENG.format(u.mention, message.chat.title)),\n                                                 reply_markup=InlineKeyboardMarkup(\n        [[\n            InlineKeyboardButton('🧩 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 🧩', url=f\"https://t.me/{SUPPORT_CHAT}\"),\n            InlineKeyboardButton('⚡𝖴𝗉𝖽𝖺𝗍𝖾𝗌 ⚡', url=f\"https://t.me/piroxbots\")\n        ]]\n                                                 ),\n                                                 parse_mode=enums.ParseMode.HTML\n                )\n                \n        if settings[\"auto_delete\"]:\n            await asyncio.sleep(300)\n            await (temp.MELCOW['welcome']).delete()\n                \n               \n\n\n\n@Client.on_message(filters.command('leave') & filters.user(ADMINS))\nasync def leave_a_chat(bot, message):\n    if len(message.command) == 1:\n        return await message.reply('Give me a chat id')\n    chat = message.command[1]\n    try:\n        chat = int(chat)\n    except:\n        chat = chat\n    try:\n        buttons = [[\n            InlineKeyboardButton('🧩 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 🧩', url=f\"https://t.me/{SUPPORT_CHAT}\"),\n            InlineKeyboardButton('⚡𝖴𝗉𝖽𝖺𝗍𝖾𝗌 ⚡', url=f\"https://t.me/piroxbots\")\n        ]]\n        reply_markup=InlineKeyboardMarkup(buttons)\n        await bot.send_message(\n            chat_id=chat,\n            text='<b>Hello Friends, \\nMy admin has told me to leave from group so i go! If you wanna add me again contact my 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 GROUP.</b>',\n            reply_markup=reply_markup,\n        )\n\n        await bot.leave_chat(chat)\n        await message.reply(f\"left the chat `{chat}`\")\n    except Exception as e:\n        await message.reply(f'Error - {e}')\n\n@Client.on_message(filters.command('disable') & filters.user(ADMINS))\nasync def disable_chat(bot, message):\n    if len(message.command) == 1:\n        return await message.reply('Give me a chat id')\n    r = message.text.split(None)\n    if len(r) > 2:\n        reason = message.text.split(None, 2)[2]\n        chat = message.text.split(None, 2)[1]\n    else:\n        chat = message.command[1]\n        reason = \"No reason Provided\"\n    try:\n        chat_ = int(chat)\n    except:\n        return await message.reply('Give Me A Valid Chat ID')\n    cha_t = await db.get_chat(int(chat_))\n    if not cha_t:\n        return await message.reply(\"Chat Not Found In DB\")\n    if cha_t['is_disabled']:\n        return await message.reply(f\"This chat is already disabled:\\nReason-<code> {cha_t['reason']} </code>\")\n    await db.disable_chat(int(chat_), reason)\n    temp.BANNED_CHATS.append(int(chat_))\n    await message.reply('Chat Successfully Disabled')\n    try:\n        buttons = [[\n            InlineKeyboardButton('🧩 𝖲𝖴𝖯𝖯𝖮𝖱𝖳 🧩', url=f\"https://t.me/{SUPPORT_CHAT}\"),\n            InlineKeyboardButton('⚡𝖴𝗉𝖽𝖺𝗍𝖾𝗌 ⚡', url=f\"https://t.me/piroxbots\")\n        ]]\n        reply_markup=InlineKeyboardMarkup(buttons)\n        await bot.send_message(\n            chat_id=chat_, \n            text=f'<b>𝖧𝖾𝗅𝗅𝗈 𝖥𝗋𝗂𝖾𝗇𝖽𝗌, \\n𝖬𝗒 𝖺𝖽𝗆𝗂𝗇 𝗁𝖺𝗌 𝗍𝗈𝗅𝖽 𝗆𝖾 𝗍𝗈 𝗅𝖾𝖺𝗏𝖾 𝖿𝗋𝗈𝗆 𝗀𝗋𝗈𝗎𝗉 𝗌𝗈 𝗂 𝗀𝗈! 𝖨𝖿 𝗒𝗈𝗎 𝗐𝖺𝗇𝗇𝖺 𝖺𝖽𝖽 𝗆𝖾 𝖺𝗀𝖺𝗂𝗇 𝖼𝗈𝗇𝗍𝖺𝖼𝗍 𝗆𝗒 𝗌𝗎𝗉𝗉𝗈𝗋𝗍 𝗀𝗋𝗈𝗎𝗉.</b> \\nReason : <code>{reason}</code>',\n            reply_markup=reply_markup)\n        await bot.leave_chat(chat_)\n    except Exception as e:\n        await message.reply(f\"Error - {e}\")\n\n\n@Client.on_message(filters.command('enable') & filters.user(ADMINS))\nasync def re_enable_chat(bot, message):\n    if len(message.command) == 1:\n        return await message.reply('Give me a chat id')\n    chat = message.command[1]\n    try:\n        chat_ = int(chat)\n    except:\n        return await message.reply('Give Me A Valid Chat ID')\n    sts = await db.get_chat(int(chat))\n    if not sts:\n        return await message.reply(\"Chat Not Found In DB !\")\n    if not sts.get('is_disabled'):\n        return await message.reply('This chat is not yet disabled.')\n    await db.re_enable_chat(int(chat_))\n    temp.BANNED_CHATS.remove(int(chat_))\n    await message.reply(\"Chat Successfully re-enabled\")\n\n\n@Client.on_message(filters.command('stats') & filters.incoming)\nasync def get_ststs(bot, message):\n    rju = await message.reply('Fetching stats...')\n    total_users = await db.total_users_count()\n    totl_chats = await db.total_chat_count()\n    files = await Media.count_documents()\n    size = await db.get_db_size()\n    free = 536870912 - size\n    size = get_size(size)\n    free = get_size(free)\n    await rju.edit(script.STATUS_TXT.format(files, total_users, totl_chats, size, free))\n\n@Client.on_message(filters.command('invite') & filters.user(ADMINS))\nasync def gen_invite(bot, message):\n    if len(message.command) == 1:\n        return await message.reply('Give me a chat id')\n    chat = message.command[1]\n    try:\n        chat = int(chat)\n    except:\n        return await message.reply('Give Me A Valid Chat ID')\n    try:\n        link = await bot.create_chat_invite_link(chat)\n    except ChatAdminRequired:\n        return await message.reply(\"Invite Link Generation Failed, Iam Not Having Sufficient Rights\")\n    except Exception as e:\n        return await message.reply(f'Error {e}')\n    await message.reply(f'Here is your Invite Link {link.invite_link}')\n\n@Client.on_message(filters.command('ban') & filters.user(ADMINS))\nasync def ban_a_user(bot, message):\n    if len(message.command) == 1:\n        return await message.reply('Give me a user id / username')\n    r = message.text.split(None)\n    if len(r) > 2:\n        reason = message.text.split(None, 2)[2]\n        chat = message.text.split(None, 2)[1]\n    else:\n        chat = message.command[1]\n        reason = \"No reason Provided\"\n    try:\n        chat = int(chat)\n    except:\n        pass\n    try:\n        k = await bot.get_users(chat)\n    except PeerIdInvalid:\n        return await message.reply(\"This is an invalid user, make sure ia have met him before.\")\n    except IndexError:\n        return await message.reply(\"This might be a channel, make sure its a user.\")\n    except Exception as e:\n        return await message.reply(f'Error - {e}')\n    else:\n        jar = await db.get_ban_status(k.id)\n        if jar['is_banned']:\n            return await message.reply(f\"{k.mention} is already banned\\nReason: {jar['ban_reason']}\")\n        await db.ban_user(k.id, reason)\n        temp.BANNED_USERS.append(k.id)\n        await message.reply(f\"Successfully banned {k.mention}\")\n\n\n    \n@Client.on_message(filters.command('unban') & filters.user(ADMINS))\nasync def unban_a_user(bot, message):\n    if len(message.command) == 1:\n        return await message.reply('Give me a user id / username')\n    r = message.text.split(None)\n    if len(r) > 2:\n        reason = message.text.split(None, 2)[2]\n        chat = message.text.split(None, 2)[1]\n    else:\n        chat = message.command[1]\n        reason = \"No reason Provided\"\n    try:\n        chat = int(chat)\n    except:\n        pass\n    try:\n        k = await bot.get_users(chat)\n    except PeerIdInvalid:\n        return await message.reply(\"This is an invalid user, make sure ia have met him before.\")\n    except IndexError:\n        return await message.reply(\"Thismight be a channel, make sure its a user.\")\n    except Exception as e:\n        return await message.reply(f'Error - {e}')\n    else:\n        jar = await db.get_ban_status(k.id)\n        if not jar['is_banned']:\n            return await message.reply(f\"{k.mention} is not yet banned.\")\n        await db.remove_ban(k.id)\n        temp.BANNED_USERS.remove(k.id)\n        await message.reply(f\"Successfully unbanned {k.mention}\")\n\n\n    \n@Client.on_message(filters.command('users') & filters.user(ADMINS))\nasync def list_users(bot, message):\n    raju = await message.reply('Getting List Of Users')\n    users = await db.get_all_users()\n    out = \"Users Saved In DB Are:\\n\\n\"\n    async for user in users:\n        out += f\"<a href=tg://user?id={user['id']}>{user['name']}</a>\"\n        if user['ban_status']['is_banned']:\n            out += '( Banned User )'\n        out += '\\n'\n    try:\n        await raju.edit_text(out)\n    except MessageTooLong:\n        with open('users.txt', 'w+') as outfile:\n            outfile.write(out)\n        await message.reply_document('users.txt', caption=\"List Of Users\")\n\n@Client.on_message(filters.command('chats') & filters.user(ADMINS))\nasync def list_chats(bot, message):\n    raju = await message.reply('Getting List Of chats')\n    chats = await db.get_all_chats()\n    out = \"Chats Saved In DB Are:\\n\\n\"\n    async for chat in chats:\n        out += f\"**Title:** `{chat['title']}`\\n**- ID:** `{chat['id']}`\"\n        if chat['chat_status']['is_disabled']:\n            out += '( Disabled Chat )'\n        out += '\\n'\n    try:\n        await raju.edit_text(out)\n    except MessageTooLong:\n        with open('chats.txt', 'w+') as outfile:\n            outfile.write(out)\n        await message.reply_document('chats.txt', caption=\"List Of Chats\")"
  },
  {
    "path": "plugins/pm_filter.py",
    "content": "import asyncio\nimport re\nimport ast\nimport math\nimport random\nlock = asyncio.Lock()\n\nfrom pyrogram.errors.exceptions.bad_request_400 import MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty\nfrom Script import script\nimport pyrogram\nfrom database.connections_mdb import active_connection, all_connections, delete_connection, if_active, make_active, \\\n    make_inactive\nfrom info import ADMINS, AUTH_CHANNEL, AUTH_USERS, SUPPORT_CHAT_ID, SUPPORT_CHAT, CUSTOM_FILE_CAPTION, PICS, AUTH_GROUPS, P_TTI_SHOW_OFF, NOR_IMG, LOG_CHANNEL, SPELL_IMG, MAX_B_TN, IMDB, \\\n    SINGLE_BUTTON, SPELL_CHECK_REPLY, IMDB_TEMPLATE, NO_RESULTS_MSG\nfrom pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto\nfrom pyrogram import Client, filters, enums\nfrom pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid\nfrom utils import get_size, is_subscribed, get_poster, search_gagala, temp, get_settings, save_group_settings, send_all\nfrom database.users_chats_db import db\nfrom database.ia_filterdb import Media, get_file_details, get_search_results, get_bad_files\nfrom database.filters_mdb import (\n    del_all,\n    find_filter,\n    get_filters,\n)\nfrom database.gfilters_mdb import (\n    find_gfilter,\n    get_gfilters,\n    del_allg\n)\nimport logging\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.ERROR)\n\nBUTTONS = {}\nSPELL_CHECK = {}\n\n\n@Client.on_message(filters.group & filters.text & filters.incoming)\nasync def give_filter(client, message):\n    if message.chat.id != SUPPORT_CHAT_ID:\n        glob = await global_filters(client, message)\n        if glob == False:\n            manual = await manual_filters(client, message)\n            if manual == False:\n                settings = await get_settings(message.chat.id)\n                try:\n                    if settings['auto_ffilter']:\n                        await auto_filter(client, message)\n                except KeyError:\n                    grpid = await active_connection(str(message.from_user.id))\n                    await save_group_settings(grpid, 'auto_ffilter', True)\n                    settings = await get_settings(message.chat.id)\n                    if settings['auto_ffilter']:\n                        await auto_filter(client, message)\n    else: #a better logic to avoid repeated lines of code in auto_filter function\n        search = message.text\n        temp_files, temp_offset, total_results = await get_search_results(chat_id=message.chat.id, query=search.lower(), offset=0, filter=True)\n        if total_results == 0:\n            return\n        else:\n            return await message.reply_text(f\"<b>👋 𝖧𝖾𝗒 {message.from_user.mention} \\n📁 {str(total_results)} 𝖱𝖾𝗌𝗎𝗅𝗍𝗌 𝖺𝗋𝖾 𝖿𝗈𝗎𝗇𝖽 𝖿𝗈𝗋 𝗒𝗈𝗎𝗋 𝗊𝗎𝖾𝗋𝗒 {search}.\\n\\nKindly ask movies and series here ⬇\\n@blaster_arena & @blaster_movies</b>\")\n\n@Client.on_message(filters.private & filters.text & filters.incoming)\nasync def pv_filter(client, message):\n    kd = await global_filters(client, message)\n    if kd == False:\n        await auto_filter(client, message)\n\n@Client.on_callback_query(filters.regex(r\"^next\"))\nasync def next_page(bot, query):\n    ident, req, key, offset = query.data.split(\"_\")\n    if int(req) not in [query.from_user.id, 0]:\n        return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True)\n    try:\n        offset = int(offset)\n    except:\n        offset = 0\n    search = BUTTONS.get(key)\n    if not search:\n        await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name),show_alert=True)\n        return\n\n    files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=offset, filter=True)\n    try:\n        n_offset = int(n_offset)\n    except:\n        n_offset = 0\n\n    if not files:\n        return\n    settings = await get_settings(query.message.chat.id)\n    pre = 'filep' if settings['file_secure'] else 'file'\n    temp.FILES_IDS[key] = files\n    if settings['button']:\n        btn = [\n            [\n                InlineKeyboardButton(\n                   text=f\"🔖{get_size(file.file_size)}🔮{file.file_name}\", callback_data=f'{pre}#{file.file_id}'\n                ),\n            ]\n            for file in files\n        ]\n    else:\n        btn = [\n            [\n                InlineKeyboardButton(\n                    text=f\"{file.file_name}\", callback_data=f'{pre}#{file.file_id}'\n                ),\n                InlineKeyboardButton(\n                    text=f\"{get_size(file.file_size)}\",\n                    callback_data=f'{pre}#{file.file_id}',\n                ),\n            ]\n            for file in files\n        ]\n    try:\n        if settings['auto_delete']:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n\n        else:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n                \n    except KeyError:\n        grpid = await active_connection(str(query.message.from_user.id))\n        await save_group_settings(grpid, 'auto_delete', True)\n        settings = await get_settings(query.message.chat.id)\n        if settings['auto_delete']:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n\n        else:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n    try:\n        settings = await get_settings(query.message.chat.id)\n        if settings['max_btn']:\n            if 0 < offset <= 10:\n                off_set = 0\n            elif offset == 0:\n                off_set = None\n            else:\n                off_set = offset - 10\n            if n_offset == 0:\n                btn.append(\n                    [InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}\", callback_data=\"pages\")]\n                )\n            elif off_set is None:\n                btn.append([InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}\", callback_data=\"pages\"), InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")])\n            else:\n                btn.append(\n                    [\n                        InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"),\n                        InlineKeyboardButton(f\"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}\", callback_data=\"pages\"),\n                        InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")\n                    ],\n                )\n        else:\n            if 0 < offset <= int(MAX_B_TN):\n                off_set = 0\n            elif offset == 0:\n                off_set = None\n            else:\n                off_set = offset - int(MAX_B_TN)\n            if n_offset == 0:\n                btn.append(\n                    [InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}\", callback_data=\"pages\")]\n                )\n            elif off_set is None:\n                btn.append([InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}\", callback_data=\"pages\"), InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")])\n            else:\n                btn.append(\n                    [\n                        InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"),\n                        InlineKeyboardButton(f\"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}\", callback_data=\"pages\"),\n                        InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")\n                    ],\n                )\n    except KeyError:\n        await save_group_settings(query.message.chat.id, 'max_btn', False)\n        settings = await get_settings(query.message.chat.id)\n        if settings['max_btn']:\n            if 0 < offset <= 10:\n                off_set = 0\n            elif offset == 0:\n                off_set = None\n            else:\n                off_set = offset - 10\n            if n_offset == 0:\n                btn.append(\n                    [InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}\", callback_data=\"pages\")]\n                )\n            elif off_set is None:\n                btn.append([InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}\", callback_data=\"pages\"), InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")])\n            else:\n                btn.append(\n                    [\n                        InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"),\n                        InlineKeyboardButton(f\"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}\", callback_data=\"pages\"),\n                        InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")\n                    ],\n                )\n        else:\n            if 0 < offset <= int(MAX_B_TN):\n                off_set = 0\n            elif offset == 0:\n                off_set = None\n            else:\n                off_set = offset - int(MAX_B_TN)\n            if n_offset == 0:\n                btn.append(\n                    [InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}\", callback_data=\"pages\")]\n                )\n            elif off_set is None:\n                btn.append([InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(f\"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}\", callback_data=\"pages\"), InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")])\n            else:\n                btn.append(\n                    [\n                        InlineKeyboardButton(\"◀️ 𝖡𝖠𝖢𝖪\", callback_data=f\"next_{req}_{key}_{off_set}\"),\n                        InlineKeyboardButton(f\"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}\", callback_data=\"pages\"),\n                        InlineKeyboardButton(\"𝖭𝖤𝖷𝖳 ▶️\", callback_data=f\"next_{req}_{key}_{n_offset}\")\n                    ],\n                )\n    btn.insert(0, [\n        InlineKeyboardButton(f'🎬 {search} 🎬', 'rkbtn')\n    ])\n    btn.insert(2, [\n        InlineKeyboardButton(\"📤 𝖲𝖾𝗇𝖽 𝖠𝗅𝗅 𝖥𝗂𝗅𝖾𝗌 📤\", callback_data=f\"send_all#{req}#{key}#{pre}\")\n    ])\n    try:\n        await query.edit_message_reply_markup(\n            reply_markup=InlineKeyboardMarkup(btn)\n        )\n    except MessageNotModified:\n        pass\n    await query.answer()\n\n\n@Client.on_callback_query(filters.regex(r\"^spol\"))\nasync def advantage_spoll_choker(bot, query):\n    _, user, movie_, key = query.data.split('#')\n    movies = temp.SPELL_CHECK.get(key)\n    if not movies:\n        return await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name), show_alert=True)\n    if int(user) != 0 and query.from_user.id != int(user):\n        return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True)\n    if movie_ == \"close_spellcheck\":\n        return await query.message.delete()\n    movie = movies[(int(movie_))]\n    await query.answer(script.TOP_ALRT_MSG)\n    gl = await global_filters(bot, query.message, text=movie)\n    if gl == False:\n        k = await manual_filters(bot, query.message, text=movie)\n        if k == False:\n            files, offset, total_results = await get_search_results(query.message.chat.id, movie, offset=0, filter=True)\n            if files:\n                k = (movie, files, offset, total_results)\n                await auto_filter(bot, query, k)\n            else:\n                reqstr1 = query.from_user.id if query.from_user else 0\n                reqstr = await bot.get_users(reqstr1)\n                if NO_RESULTS_MSG:\n                    await bot.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, movie)))\n                k = await query.message.edit(script.MVE_NT_FND)\n                await asyncio.sleep(10)\n                await k.delete()\n\n\n@Client.on_callback_query()\nasync def cb_handler(client: Client, query: CallbackQuery):\n    if query.data == \"close_data\":\n        await query.message.delete()\n    elif query.data == \"gfiltersdeleteallconfirm\":\n        await del_allg(query.message, 'gfilters')\n        await query.answer(\"Done !\")\n        return\n    elif query.data == \"gfiltersdeleteallcancel\": \n        await query.message.reply_to_message.delete()\n        await query.message.delete()\n        await query.answer(\"Process Cancelled !\")\n        return\n    elif query.data == \"delallconfirm\":\n        userid = query.from_user.id\n        chat_type = query.message.chat.type\n\n        if chat_type == enums.ChatType.PRIVATE:\n            grpid = await active_connection(str(userid))\n            if grpid is not None:\n                grp_id = grpid\n                try:\n                    chat = await client.get_chat(grpid)\n                    title = chat.title\n                except:\n                    await query.message.edit_text(\"Make sure I'm present in your group!!\", quote=True)\n                    return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n            else:\n                await query.message.edit_text(\n                    \"I'm not connected to any groups!\\nCheck /connections or connect to any groups\",\n                    quote=True\n                )\n                return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n\n        elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n            grp_id = query.message.chat.id\n            title = query.message.chat.title\n\n        else:\n            return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n\n        st = await client.get_chat_member(grp_id, userid)\n        if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS):\n            await del_all(query.message, grp_id, title)\n        else:\n            await query.answer(\"You need to be Group Owner or an Auth User to do that!\", show_alert=True)\n    elif query.data == \"delallcancel\":\n        userid = query.from_user.id\n        chat_type = query.message.chat.type\n\n        if chat_type == enums.ChatType.PRIVATE:\n            await query.message.reply_to_message.delete()\n            await query.message.delete()\n\n        elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:\n            grp_id = query.message.chat.id\n            st = await client.get_chat_member(grp_id, userid)\n            if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS):\n                await query.message.delete()\n                try:\n                    await query.message.reply_to_message.delete()\n                except:\n                    pass\n            else:\n                await query.answer(\"That's not for you!!\", show_alert=True)\n    elif \"groupcb\" in query.data:\n        await query.answer()\n\n        group_id = query.data.split(\":\")[1]\n\n        act = query.data.split(\":\")[2]\n        hr = await client.get_chat(int(group_id))\n        title = hr.title\n        user_id = query.from_user.id\n\n        if act == \"\":\n            stat = \"CONNECT\"\n            cb = \"connectcb\"\n        else:\n            stat = \"DISCONNECT\"\n            cb = \"disconnect\"\n\n        keyboard = InlineKeyboardMarkup([\n            [InlineKeyboardButton(f\"{stat}\", callback_data=f\"{cb}:{group_id}\"),\n             InlineKeyboardButton(\"DELETE\", callback_data=f\"deletecb:{group_id}\")],\n            [InlineKeyboardButton(\"BACK\", callback_data=\"backcb\")]\n        ])\n\n        await query.message.edit_text(\n            f\"Group Name : **{title}**\\nGroup ID : `{group_id}`\",\n            reply_markup=keyboard,\n            parse_mode=enums.ParseMode.MARKDOWN\n        )\n        return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n    elif \"connectcb\" in query.data:\n        await query.answer()\n\n        group_id = query.data.split(\":\")[1]\n\n        hr = await client.get_chat(int(group_id))\n\n        title = hr.title\n\n        user_id = query.from_user.id\n\n        mkact = await make_active(str(user_id), str(group_id))\n\n        if mkact:\n            await query.message.edit_text(\n                f\"Connected to **{title}**\",\n                parse_mode=enums.ParseMode.MARKDOWN\n            )\n        else:\n            await query.message.edit_text('Disconnected from', parse_mode=enums.ParseMode.MARKDOWN)\n        return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n    elif \"disconnect\" in query.data:\n        await query.answer()\n\n        group_id = query.data.split(\":\")[1]\n\n        hr = await client.get_chat(int(group_id))\n\n        title = hr.title\n        user_id = query.from_user.id\n\n        mkinact = await make_inactive(str(user_id))\n\n        if mkinact:\n            await query.message.edit_text(\n                f\"Disconnected from **{title}**\",\n                parse_mode=enums.ParseMode.MARKDOWN\n            )\n        else:\n            await query.message.edit_text(\n                f\"Some error occurred!!\",\n                parse_mode=enums.ParseMode.MARKDOWN\n            )\n        return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n    elif \"deletecb\" in query.data:\n        await query.answer()\n\n        user_id = query.from_user.id\n        group_id = query.data.split(\":\")[1]\n\n        delcon = await delete_connection(str(user_id), str(group_id))\n\n        if delcon:\n            await query.message.edit_text(\n                \"Successfully deleted connection\"\n            )\n        else:\n            await query.message.edit_text(\n                f\"Some error occurred!!\",\n                parse_mode=enums.ParseMode.MARKDOWN\n            )\n        return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n    elif query.data == \"backcb\":\n        await query.answer()\n\n        userid = query.from_user.id\n\n        groupids = await all_connections(str(userid))\n        if groupids is None:\n            await query.message.edit_text(\n                \"There are no active connections!! Connect to some groups first.\",\n            )\n            return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n        buttons = []\n        for groupid in groupids:\n            try:\n                ttl = await client.get_chat(int(groupid))\n                title = ttl.title\n                active = await if_active(str(userid), str(groupid))\n                act = \" - ACTIVE\" if active else \"\"\n                buttons.append(\n                    [\n                        InlineKeyboardButton(\n                            text=f\"{title}{act}\", callback_data=f\"groupcb:{groupid}:{act}\"\n                        )\n                    ]\n                )\n            except:\n                pass\n        if buttons:\n            await query.message.edit_text(\n                \"Your connected group details ;\\n\\n\",\n                reply_markup=InlineKeyboardMarkup(buttons)\n            )\n    elif \"gfilteralert\" in query.data:\n        grp_id = query.message.chat.id\n        i = query.data.split(\":\")[1]\n        keyword = query.data.split(\":\")[2]\n        reply_text, btn, alerts, fileid = await find_gfilter('gfilters', keyword)\n        if alerts is not None:\n            alerts = ast.literal_eval(alerts)\n            alert = alerts[int(i)]\n            alert = alert.replace(\"\\\\n\", \"\\n\").replace(\"\\\\t\", \"\\t\")\n            await query.answer(alert, show_alert=True)\n    elif \"alertmessage\" in query.data:\n        grp_id = query.message.chat.id\n        i = query.data.split(\":\")[1]\n        keyword = query.data.split(\":\")[2]\n        reply_text, btn, alerts, fileid = await find_filter(grp_id, keyword)\n        if alerts is not None:\n            alerts = ast.literal_eval(alerts)\n            alert = alerts[int(i)]\n            alert = alert.replace(\"\\\\n\", \"\\n\").replace(\"\\\\t\", \"\\t\")\n            await query.answer(alert, show_alert=True)\n    if query.data.startswith(\"file\"):\n        clicked = query.from_user.id\n        try:\n            typed = query.message.reply_to_message.from_user.id\n        except:\n            typed = query.from_user.id\n        ident, file_id = query.data.split(\"#\")\n        files_ = await get_file_details(file_id)\n        if not files_:\n            return await query.answer('No such file exist.')\n        files = files_[0]\n        title = files.file_name\n        size = get_size(files.file_size)\n        f_caption = files.caption\n        settings = await get_settings(query.message.chat.id)\n        if CUSTOM_FILE_CAPTION:\n            try:\n                f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title,\n                                                       file_size='' if size is None else size,\n                                                       file_caption='' if f_caption is None else f_caption)\n            except Exception as e:\n                logger.exception(e)\n            f_caption = f_caption\n        if f_caption is None:\n            f_caption = f\"{files.file_name}\"\n\n        try:\n            if AUTH_CHANNEL and not await is_subscribed(client, query):\n                if clicked == typed:\n                    await query.answer(url=f\"https://t.me/{temp.U_NAME}?start={ident}_{file_id}\")\n                    return\n                else:\n                    await query.answer(f\"𝖧𝖾𝗒 {query.from_user.first_name}, 𝖳𝗁𝗂𝗌 𝗂𝗌 𝗇𝗈𝗍 𝗒𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 !\", show_alert=True)\n            elif settings['botpm']:\n                if clicked == typed:\n                    await query.answer(url=f\"https://t.me/{temp.U_NAME}?start={ident}_{file_id}\")\n                    return\n                else:\n                    await query.answer(f\"𝖧𝖾𝗒 {query.from_user.first_name}, 𝖳𝗁𝗂𝗌 𝗂𝗌 𝗇𝗈𝗍 𝗒𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 !\", show_alert=True)\n            else:\n                if clicked == typed:\n                    await client.send_cached_media(\n                        chat_id=query.from_user.id,\n                        file_id=file_id,\n                        caption=f_caption,\n                        protect_content=True if ident == \"filep\" else False,\n                        reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=\"https://t.me/piroxbots\") ] ] ))\n                else:\n                    await query.answer(f\"𝖧𝖾𝗒 {query.from_user.first_name}, 𝖳𝗁𝗂𝗌 𝗂𝗌 𝗇𝗈𝗍 𝗒𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 !\", show_alert=True)\n                await query.answer('𝖢𝗁𝖾𝖼𝗄 𝖯𝖬, 𝖨 𝗁𝖺𝗏𝖾 𝗌𝖾𝗇𝗍 𝖿𝗂𝗅𝖾𝗌 𝗂𝗇 𝖯𝖬', show_alert=True)\n        except UserIsBlocked:\n            await query.answer('𝖴𝗇𝖻𝗅𝗈𝖼𝗄 𝗍𝗁𝖾 𝖻𝗈𝗍 𝗆𝖺𝗇𝗁 !', show_alert=True)\n        except PeerIdInvalid:\n            await query.answer(url=f\"https://t.me/{temp.U_NAME}?start={ident}_{file_id}\")\n        except Exception as e:\n            await query.answer(url=f\"https://t.me/{temp.U_NAME}?start={ident}_{file_id}\")\n    elif query.data.startswith(\"checksub\"):\n        if AUTH_CHANNEL and not await is_subscribed(client, query):\n            await query.answer(\"𝖨 𝖫𝗂𝗄𝖾 𝖸𝗈𝗎𝗋 𝖲𝗆𝖺𝗋𝗍𝗇𝖾𝗌𝗌, 𝖡𝗎𝗍 𝖣𝗈𝗇'𝗍 𝖡𝖾 𝖮𝗏𝖾𝗋𝗌𝗆𝖺𝗋𝗍 😒 \\n𝖩𝗈𝗂𝗇 𝖴𝗉𝖽𝖺𝗍𝖾 𝖢𝗁𝖺𝗇𝗇𝖾𝗅 𝖿𝗂𝗋𝗌𝗍 ;)\", show_alert=True)\n            return\n        ident, file_id = query.data.split(\"#\")\n        files_ = await get_file_details(file_id)\n        if not files_:\n            return await query.answer('No such file exist.')\n        files = files_[0]\n        title = files.file_name\n        size = get_size(files.file_size)\n        f_caption = files.caption\n        if CUSTOM_FILE_CAPTION:\n            try:\n                f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title,\n                                                       file_size='' if size is None else size,\n                                                       file_caption='' if f_caption is None else f_caption)\n            except Exception as e:\n                logger.exception(e)\n                f_caption = f_caption\n        if f_caption is None:\n            f_caption = f\"{title}\"\n        await query.answer()\n        await client.send_cached_media(\n            chat_id=query.from_user.id,\n            file_id=file_id,\n            caption=f_caption,\n            protect_content=True if ident == 'checksubp' else False,\n            reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=\"https://t.me/piroxbots\") ] ] ))\n    elif query.data == \"pages\":\n        await query.answer()\n\n    elif query.data.startswith(\"send_all\"):\n        _, req, key, pre = query.data.split(\"#\")\n        if int(req) not in [query.from_user.id, 0]:\n            return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True)\n        \n        await query.answer(url=f\"https://t.me/{temp.U_NAME}?start=all_{key}_{pre}\")\n        \n\n    elif query.data.startswith(\"killfilesdq\"):\n        ident, keyword = query.data.split(\"#\")\n        await query.message.edit_text(f\"<b>Fetching Files for your query {keyword} on DB... Please wait...</b>\")\n        files, total = await get_bad_files(keyword)\n        await query.message.edit_text(f\"<b>Found {total} files for your query {keyword} !\\n\\nFile deletion process will start in 5 seconds !</b>\")\n        await asyncio.sleep(5)\n        deleted = 0\n        async with lock:\n            try:\n                for file in files:\n                    file_ids = file.file_id\n                    file_name = file.file_name\n                    result = await Media.collection.delete_one({\n                        '_id': file_ids,\n                    })\n                    if result.deleted_count:\n                        logger.info(f'File Found for your query {keyword}! Successfully deleted {file_name} from database.')\n                    deleted += 1\n                    if deleted % 20 == 0:\n                        await query.message.edit_text(f\"<b>Process started for deleting files from DB. Successfully deleted {str(deleted)} files from DB for your query {keyword} !\\n\\nPlease wait...</b>\")\n            except Exception as e:\n                logger.exception(e)\n                await query.message.edit_text(f'Error: {e}')\n            else:\n                await query.message.edit_text(f\"<b>Process Completed for file deletion !\\n\\nSuccessfully deleted {str(deleted)} files from database for your query {keyword}.</b>\")\n\n    elif query.data.startswith(\"opnsetgrp\"):\n        ident, grp_id = query.data.split(\"#\")\n        userid = query.from_user.id if query.from_user else None\n        st = await client.get_chat_member(grp_id, userid)\n        if (\n                st.status != enums.ChatMemberStatus.ADMINISTRATOR\n                and st.status != enums.ChatMemberStatus.OWNER\n                and str(userid) not in ADMINS\n        ):\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n            return\n        title = query.message.chat.title\n        settings = await get_settings(grp_id)\n        if settings is not None:\n            buttons = [\n                [\n                    InlineKeyboardButton('𝖥𝗂𝗅𝗍𝖾𝗋 𝖡𝗎𝗍𝗍𝗈𝗇',\n                                         callback_data=f'setgs#button#{settings[\"button\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('𝖲𝗂𝗇𝗀𝗅𝖾 𝖡𝗎𝗍𝗍𝗈𝗇' if settings[\"button\"] else '𝖣𝗈𝗎𝖻𝗅𝖾',\n                                         callback_data=f'setgs#button#{settings[\"button\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖥𝗂𝗅𝖾 𝖲𝖾𝗇𝖽 𝖬𝗈𝖽𝖾', callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('𝖬𝖺𝗇𝗎𝖺𝗅 𝖲𝗍𝖺𝗋𝗍' if settings[\"botpm\"] else '𝖠𝗎𝗍𝗈 𝖲𝖾𝗇𝖽',\n                                         callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖯𝗋𝗈𝗍𝖾𝖼𝗍 𝖢𝗈𝗇𝗍𝖾𝗇𝗍',\n                                         callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"file_secure\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖨𝖬𝖣𝖻', callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"imdb\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖲𝗉𝖾𝗅𝗅 𝖢𝗁𝖾𝖼𝗄',\n                                         callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"spell_check\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖶𝖾𝗅𝖼𝗈𝗆𝖾 𝖬𝖾𝗌𝗌𝖺𝗀𝖾', callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"welcome\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖠𝗎𝗍𝗈 𝖣𝖾𝗅𝖾𝗍𝖾',\n                                         callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('5 𝖬𝗂𝗇' if settings[\"auto_delete\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖠𝗎𝗍𝗈-𝖥𝗂𝗅𝗍𝖾𝗋',\n                                         callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"auto_ffilter\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖬𝖺𝗑 𝖡𝗎𝗍𝗍𝗈𝗇𝗌',\n                                         callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('10' if settings[\"max_btn\"] else f'{MAX_B_TN}',\n                                         callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{str(grp_id)}')\n                ]\n            ]\n            reply_markup = InlineKeyboardMarkup(buttons)\n            await query.message.edit_text(\n                text=f\"<b>𝖢𝗁𝖺𝗇𝗀𝖾 𝖸𝗈𝗎𝗋 𝖲𝖾𝗍𝗍𝗂𝗇𝗀𝗌 𝖥𝗈𝗋 {title} 𝖠𝗌 𝖸𝗈𝗎𝗋 𝖶𝗂𝗌𝗁</b>\",\n                disable_web_page_preview=True,\n                parse_mode=enums.ParseMode.HTML\n            )\n            await query.message.edit_reply_markup(reply_markup)\n        \n    elif query.data.startswith(\"opnsetpm\"):\n        ident, grp_id = query.data.split(\"#\")\n        userid = query.from_user.id if query.from_user else None\n        st = await client.get_chat_member(grp_id, userid)\n        if (\n                st.status != enums.ChatMemberStatus.ADMINISTRATOR\n                and st.status != enums.ChatMemberStatus.OWNER\n                and str(userid) not in ADMINS\n        ):\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n            return\n        title = query.message.chat.title\n        settings = await get_settings(grp_id)\n        btn2 = [[\n                 InlineKeyboardButton(\"➡ 𝖮𝗉𝖾𝗇 𝗂𝗇 𝖯𝖬 ➡\", url=f\"t.me/{temp.U_NAME}\")\n               ]]\n        reply_markup = InlineKeyboardMarkup(btn2)\n        await query.message.edit_text(f\"<b>𝖸𝗈𝗎𝗋 𝗌𝖾𝗍𝗍𝗂𝗇𝗀𝗌 𝗆𝖾𝗇𝗎 𝖿𝗈𝗋 {title} 𝗁𝖺𝗌 𝖻𝖾𝖾𝗇 𝗌𝖾𝗇𝗍 𝗍𝗈 𝗒𝗈𝗎𝗋 𝖯𝖬</b>\")\n        await query.message.edit_reply_markup(reply_markup)\n        if settings is not None:\n            buttons = [\n                [\n                    InlineKeyboardButton('𝖥𝗂𝗅𝗍𝖾𝗋 𝖡𝗎𝗍𝗍𝗈𝗇',\n                                         callback_data=f'setgs#button#{settings[\"button\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('𝖲𝗂𝗇𝗀𝗅𝖾 𝖡𝗎𝗍𝗍𝗈𝗇' if settings[\"button\"] else '𝖣𝗈𝗎𝖻𝗅𝖾',\n                                         callback_data=f'setgs#button#{settings[\"button\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖥𝗂𝗅𝖾 𝖲𝖾𝗇𝖽 𝖬𝗈𝖽𝖾', callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('𝖬𝖺𝗇𝗎𝖺𝗅 𝖲𝗍𝖺𝗋𝗍' if settings[\"botpm\"] else '𝖠𝗎𝗍𝗈 𝖲𝖾𝗇𝖽',\n                                         callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖯𝗋𝗈𝗍𝖾𝖼𝗍 𝖢𝗈𝗇𝗍𝖾𝗇𝗍',\n                                         callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"file_secure\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖨𝖬𝖣𝖻', callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"imdb\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖲𝗉𝖾𝗅𝗅 𝖢𝗁𝖾𝖼𝗄',\n                                         callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"spell_check\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖶𝖾𝗅𝖼𝗈𝗆𝖾 𝖬𝖾𝗌𝗌𝖺𝗀𝖾', callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"welcome\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖠𝗎𝗍𝗈 𝖣𝖾𝗅𝖾𝗍𝖾',\n                                         callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('5 𝖬𝗂𝗇' if settings[\"auto_delete\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖠𝗎𝗍𝗈-𝖥𝗂𝗅𝗍𝖾𝗋',\n                                         callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"auto_ffilter\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖬𝖺𝗑 𝖡𝗎𝗍𝗍𝗈𝗇𝗌',\n                                         callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('10' if settings[\"max_btn\"] else f'{MAX_B_TN}',\n                                         callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{str(grp_id)}')\n                ]\n            ]\n            reply_markup = InlineKeyboardMarkup(buttons)\n            await client.send_message(\n                chat_id=userid,\n                text=f\"<b>𝖢𝗁𝖺𝗇𝗀𝖾 𝖸𝗈𝗎𝗋 𝖲𝖾𝗍𝗍𝗂𝗇𝗀𝗌 𝖥𝗈𝗋 {title} 𝖠𝗌 𝖸𝗈𝗎𝗋 𝖶𝗂𝗌𝗁</b>\",\n                reply_markup=reply_markup,\n                disable_web_page_preview=True,\n                parse_mode=enums.ParseMode.HTML,\n                reply_to_message_id=query.message.id\n            )\n\n    elif query.data.startswith(\"show_option\"):\n        ident, from_user = query.data.split(\"#\")\n        btn = [[\n                InlineKeyboardButton(\"⚠ 𝖴𝗇𝖺𝗏𝖺𝗂𝖺𝗅𝖺𝖻𝗅𝖾 ⚠\", callback_data=f\"unavailable#{from_user}\"),\n                InlineKeyboardButton(\"✅ 𝖴𝗉𝗅𝗈𝖺𝖽𝖾𝖽 ✅\", callback_data=f\"uploaded#{from_user}\")\n             ],[\n                InlineKeyboardButton(\"🔰 𝖠𝗅𝗋𝖾𝖺𝖽𝗒 𝖠𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 🔰\", callback_data=f\"already_available#{from_user}\")\n              ]]\n        btn2 = [[\n                 InlineKeyboardButton(\"❕ 𝖵𝗂𝖾𝗐 𝖲𝗍𝖺𝗍𝗎𝗌 ❕\", url=f\"{query.message.link}\")\n               ]]\n        if query.from_user.id in ADMINS:\n            user = await client.get_users(from_user)\n            reply_markup = InlineKeyboardMarkup(btn)\n            await query.message.edit_reply_markup(reply_markup)\n            await query.answer(\"𝖧𝖾𝗋𝖾 𝖺𝗋𝖾 𝗍𝗁𝖾 𝗈𝗉𝗍𝗂𝗈𝗇𝗌\")\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n        \n    elif query.data.startswith(\"unavailable\"):\n        ident, from_user = query.data.split(\"#\")\n        btn = [[\n                InlineKeyboardButton(\"⚠ 𝖴𝗇𝖺𝗏𝖺𝗂𝖺𝗅𝖺𝖻𝗅𝖾 ⚠\", callback_data=f\"unalert#{from_user}\")\n              ]]\n        btn2 = [[\n                 InlineKeyboardButton(\"❕ 𝖵𝗂𝖾𝗐 𝖲𝗍𝖺𝗍𝗎𝗌 ❕\", url=f\"{query.message.link}\")\n               ]]\n        if query.from_user.id in ADMINS:\n            user = await client.get_users(from_user)\n            reply_markup = InlineKeyboardMarkup(btn)\n            content = query.message.text\n            await query.message.edit_text(f\"<b><strike>{content}</strike></b>\")\n            await query.message.edit_reply_markup(reply_markup)\n            await query.answer(\"𝖲𝖾𝗍 𝗍𝗈 𝖴𝗇𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾\")\n            try:\n                await client.send_message(chat_id=int(from_user), text=f\"<b>𝖧𝖾𝗒 {user.mention}, 𝖲𝗈𝗋𝗋𝗒 𝗒𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝗎𝗇𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾. 𝖲𝗈 𝗆𝗈𝖽𝖾𝗋𝖺𝗍𝗈𝗋𝗌 𝖼𝖺𝗇'𝗍 𝖺𝖽𝖽 𝗂𝗍 !</b>\", reply_markup=InlineKeyboardMarkup(btn2))\n            except UserIsBlocked:\n                await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f\"<b>𝖧𝖾𝗒 {user.mention}, 𝖲𝗈𝗋𝗋𝗒 𝗒𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝗎𝗇𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾. 𝖲𝗈 𝗆𝗈𝖽𝖾𝗋𝖺𝗍𝗈𝗋𝗌 𝖼𝖺𝗇'𝗍 𝖺𝖽𝖽 𝗂𝗍 !\\n\\n📝 𝖭𝗈𝗍𝖾: 𝖳𝗁𝗂𝗌 𝗆𝖾𝗌𝗌𝖺𝗀𝖾 𝗂𝗌 𝗌𝖾𝗇𝗍 𝗂𝗇 𝖦𝗋𝗈𝗎𝗉 𝖻𝖾𝖼𝖺𝗎𝗌𝖾 𝗒𝗈𝗎 𝗁𝖺𝗏𝖾 𝖡𝗅𝗈𝖼𝗄𝖾𝖽 𝗍𝗁𝖾 𝖡𝗈𝗍 ! 𝖴𝗇𝖻𝗅𝗈𝖼𝗄 𝗍𝗁𝖾 𝖡𝗈𝗍 !</b>\", reply_markup=InlineKeyboardMarkup(btn2))\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n\n    elif query.data.startswith(\"uploaded\"):\n        ident, from_user = query.data.split(\"#\")\n        btn = [[\n                InlineKeyboardButton(\"✅ 𝖴𝗉𝗅𝗈𝖺𝖽𝖾𝖽 ✅\", callback_data=f\"upalert#{from_user}\")\n              ]]\n        btn2 = [[\n                 InlineKeyboardButton(\"❕ 𝖵𝗂𝖾𝗐 𝖲𝗍𝖺𝗍𝗎𝗌 ❕\", url=f\"{query.message.link}\")\n               ]]\n        if query.from_user.id in ADMINS:\n            user = await client.get_users(from_user)\n            reply_markup = InlineKeyboardMarkup(btn)\n            content = query.message.text\n            await query.message.edit_text(f\"<b><strike>{content}</strike></b>\")\n            await query.message.edit_reply_markup(reply_markup)\n            await query.answer(\"𝖲𝖾𝗍 𝗍𝗈 𝖴𝗉𝗅𝗈𝖺𝖽𝖾𝖽\")\n            try:\n                await client.send_message(chat_id=int(from_user), text=f\"<b>𝖧𝖾𝗒 {user.mention}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗁𝖺𝗌 𝖻𝖾𝖾𝗇 𝗎𝗉𝗅𝗈𝖺𝖽𝖾𝖽 𝖻𝗒 𝗆𝗈𝖽𝖾𝗋𝖺𝗍𝗈𝗋. 𝖪𝗂𝗇𝖽𝗅𝗒 𝗌𝖾𝖺𝗋𝖼𝗁 𝖺𝗀𝖺𝗂𝗇 @blaster_arena & @blaster_movies !</b>\", reply_markup=InlineKeyboardMarkup(btn2))\n            except UserIsBlocked:\n                await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f\"<b>𝖧𝖾𝗒 {user.mention}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗁𝖺𝗌 𝖻𝖾𝖾𝗇 𝗎𝗉𝗅𝗈𝖺𝖽𝖾𝖽 𝖻𝗒 𝗆𝗈𝖽𝖾𝗋𝖺𝗍𝗈𝗋. 𝖪𝗂𝗇𝖽𝗅𝗒 𝗌𝖾𝖺𝗋𝖼𝗁 𝖺𝗀𝖺𝗂𝗇 @blaster_arena & @blaster_movies !\\n\\n📝 𝖭𝗈𝗍𝖾: 𝖳𝗁𝗂𝗌 𝗆𝖾𝗌𝗌𝖺𝗀𝖾 𝗂𝗌 𝗌𝖾𝗇𝗍 𝗂𝗇 𝖦𝗋𝗈𝗎𝗉 𝖻𝖾𝖼𝖺𝗎𝗌𝖾 𝗒𝗈𝗎 𝗁𝖺𝗏𝖾 𝖡𝗅𝗈𝖼𝗄𝖾𝖽 𝗍𝗁𝖾 𝖡𝗈𝗍 ! 𝖴𝗇𝖻𝗅𝗈𝖼𝗄 𝗍𝗁𝖾 𝖡𝗈𝗍 !</b>\", reply_markup=InlineKeyboardMarkup(btn2))\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n\n    elif query.data.startswith(\"already_available\"):\n        ident, from_user = query.data.split(\"#\")\n        btn = [[\n                InlineKeyboardButton(\"🔰 𝖠𝗅𝗋𝖾𝖺𝖽𝗒 𝖠𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 🔰\", callback_data=f\"alalert#{from_user}\")\n              ]]\n        btn2 = [[\n                 InlineKeyboardButton(\"❕ 𝖵𝗂𝖾𝗐 𝖲𝗍𝖺𝗍𝗎𝗌 ❕\", url=f\"{query.message.link}\")\n               ]]\n        if query.from_user.id in ADMINS:\n            user = await client.get_users(from_user)\n            reply_markup = InlineKeyboardMarkup(btn)\n            content = query.message.text\n            await query.message.edit_text(f\"<b><strike>{content}</strike></b>\")\n            await query.message.edit_reply_markup(reply_markup)\n            await query.answer(\"𝖲𝖾𝗍 𝗍𝗈 𝖺𝗅𝗋𝖾𝖺𝖽𝗒 𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 !\")\n            try:\n                await client.send_message(chat_id=int(from_user), text=f\"<b>𝖧𝖾𝗒 {user.mention}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝖺𝗅𝗋𝖾𝖺𝖽𝗒 𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 𝗈𝗇 𝖡𝗈𝗍. 𝖪𝗂𝗇𝖽𝗅𝗒 𝗌𝖾𝖺𝗋𝖼𝗁 𝖺𝗀𝖺𝗂𝗇 @blaster_arena & @blaster_movies !</b>\", reply_markup=InlineKeyboardMarkup(btn2))\n            except UserIsBlocked:\n                await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f\"<b>𝖧𝖾𝗒 {user.mention}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝖺𝗅𝗋𝖾𝖺𝖽𝗒 𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 𝗈𝗇 𝖡𝗈𝗍. 𝖪𝗂𝗇𝖽𝗅𝗒 𝗌𝖾𝖺𝗋𝖼𝗁 𝖺𝗀𝖺𝗂𝗇 @blaster_arena & @blaster_movies !\\n\\n📝 𝖭𝗈𝗍𝖾: 𝖳𝗁𝗂𝗌 𝗆𝖾𝗌𝗌𝖺𝗀𝖾 𝗂𝗌 𝗌𝖾𝗇𝗍 𝗂𝗇 𝖦𝗋𝗈𝗎𝗉 𝖻𝖾𝖼𝖺𝗎𝗌𝖾 𝗒𝗈𝗎 𝗁𝖺𝗏𝖾 𝖡𝗅𝗈𝖼𝗄𝖾𝖽 𝗍𝗁𝖾 𝖡𝗈𝗍 ! 𝖴𝗇𝖻𝗅𝗈𝖼𝗄 𝗍𝗁𝖾 𝖡𝗈𝗍 !</b>\", reply_markup=InlineKeyboardMarkup(btn2))\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n\n    elif query.data.startswith(\"alalert\"):\n        ident, from_user = query.data.split(\"#\")\n        if int(query.from_user.id) == int(from_user):\n            user = await client.get_users(from_user)\n            await query.answer(f\"𝖧𝖾𝗒 {user.first_name}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝖺𝗅𝗋𝖾𝖺𝖽𝗒 𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 !\", show_alert=True)\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n\n    elif query.data.startswith(\"upalert\"):\n        ident, from_user = query.data.split(\"#\")\n        if int(query.from_user.id) == int(from_user):\n            user = await client.get_users(from_user)\n            await query.answer(f\"𝖧𝖾𝗒 {user.first_name}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝗎𝗉𝗅𝗈𝖺𝖽𝖾𝖽 !\", show_alert=True)\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n        \n    elif query.data.startswith(\"unalert\"):\n        ident, from_user = query.data.split(\"#\")\n        if int(query.from_user.id) == int(from_user):\n            user = await client.get_users(from_user)\n            await query.answer(f\"𝖧𝖾𝗒 {user.first_name}, 𝖸𝗈𝗎𝗋 𝗋𝖾𝗊𝗎𝖾𝗌𝗍 𝗂𝗌 𝖺𝗅𝗋𝖾𝖺𝖽𝗒 𝗎𝗇𝖺𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 !\", show_alert=True)\n        else:\n            await query.answer(\"𝖸𝗈𝗎 𝖽𝗈𝗇'𝗍 𝗁𝖺𝗏𝖾 𝗌𝗎𝖿𝖿𝗂𝖼𝗂𝖾𝗇𝗍 𝗋𝗂𝗀𝗁𝗍𝗌 𝗍𝗈 𝖽𝗈 𝗍𝗁𝗂𝗌 !\", show_alert=True)\n\n    elif query.data == 'rkbtn':\n        await query.answer(\"𝖧𝖾𝗒 𝖡𝗋𝗈 😍\\n\\n🎯 𝖢𝗅𝗂𝖼𝗄 𝖮𝗇 𝖳𝗁𝖾 𝖡𝗎𝗍𝗍𝗈𝗇 𝖻𝖾𝗅𝗈𝗐 𝖳𝗁𝖾 𝖥𝗂𝗅𝖾𝗌 𝖸𝗈𝗎 𝖶𝖺𝗇𝗍 𝖠𝗇𝖽 𝖲𝗍𝖺𝗋𝗍 𝖳𝗁𝖾 𝖡𝗈𝗍 ⬇️\", True)\n\n    elif query.data == 'info':\n        await query.answer(\"𝗥𝗲𝗾𝘂𝗲𝘀𝘁𝘀 𝗙𝗼𝗿𝗺𝗮𝘁𝘀\\n\\n• 𝖲𝗈𝗅𝗈 2017\\n• 𝖣𝗁𝗈𝗈𝗆 3 𝖧𝗂𝗇𝖽𝗂\\n• 𝖪𝗎𝗋𝗎𝗉 𝖪𝖺𝗇𝗇𝖺𝖽𝖺\\n• 𝖣𝖺𝗋𝗄 𝗌01\\n• 𝖲𝗁𝖾 𝖧𝗎𝗅𝗄 720𝗉\\n• 𝖥𝗋𝗂𝖾𝗇𝖽𝗌 𝗌03 1080𝗉\\n\\n‼️𝗗𝗼𝗻𝘁 𝗮𝗱𝗱 𝘄𝗼𝗿𝗱𝘀 & 𝘀𝘆𝗺𝗯𝗼𝗹𝘀  , . - 𝗹𝗶𝗸𝗲 send link movie series 𝗲𝘁𝗰‼️\", True)\n    \n    elif query.data == 'tips':\n        await query.answer(\"𝖳𝗁𝗂𝗌 𝖬𝖾𝗌𝗌𝖺𝗀𝖾 𝖶𝗂𝗅𝗅 𝖡𝖾 𝖣𝖾𝗅𝖾𝗍𝖾𝖽 𝖠𝖿𝗍𝖾𝗋 5 𝖬𝗂𝗇𝗎𝗍𝖾𝗌 𝗍𝗈 𝖯𝗋𝖾𝗏𝖾𝗇𝗍 𝖢𝗈𝗉𝗒𝗋𝗂𝗀𝗁𝗍 !\\n\\n𝖳𝗁𝖺𝗇𝗄 𝖸𝗈𝗎 𝖥𝗈𝗋 𝖴𝗌𝗂𝗇𝗀 𝖬𝖾 😊\\n\\n\\n𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖡𝗒 𝖯𝖨𝖱𝖮\", True)\n\n    elif query.data == \"start\":\n        buttons = [[\n                    InlineKeyboardButton('➕ 𝖠𝖽𝖽 𝖬𝖾 𝖳𝗈 𝖸𝗈𝗎𝗋 𝖦𝗋𝗈𝗎𝗉 ➕', url=f\"http://t.me/{temp.U_NAME}?startgroup=true\")\n                ],[\n                    InlineKeyboardButton('🛡 𝖮𝗐𝗇𝖾𝗋', callback_data=\"owner_info\"),\n                    InlineKeyboardButton('🧩 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉', url=f\"https://t.me/{SUPPORT_CHAT}\")\n                ],[\n                    InlineKeyboardButton('ℹ️ 𝖧𝖾𝗅𝗉', callback_data='help'),\n                    InlineKeyboardButton('😊 𝖠𝖻𝗈𝗎𝗍', callback_data='about'),\n                ],[\n                    InlineKeyboardButton('🔎 𝖨𝗇𝗅𝗂𝗇𝖾 𝖲𝖾𝖺𝗋𝖼𝗁', switch_inline_query_current_chat='')\n                  ]]\n        \n        reply_markup = InlineKeyboardMarkup(buttons)\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        await query.message.edit_text(\n            text=script.START_TXT.format(query.from_user.mention, temp.U_NAME, temp.B_NAME),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n        await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n\n    elif query.data == \"filters\":\n        buttons = [[\n            InlineKeyboardButton('✏ 𝖬𝖺𝗇𝗎𝖺𝗅 𝖥𝗂𝗅𝗍𝖾𝗋', callback_data='manuelfilter'),\n            InlineKeyboardButton('📊 𝖠𝗎𝗍𝗈 𝖥𝗂𝗅𝗍𝖾𝗋', callback_data='autofilter')\n        ],[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='help'),\n            InlineKeyboardButton('📈 𝖦𝗅𝗈𝖻𝖺𝗅 𝖥𝗂𝗅𝗍𝖾𝗋', callback_data='global_filters')\n        ]]\n        \n        reply_markup = InlineKeyboardMarkup(buttons)\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        await query.message.edit_text(\n            text=script.ALL_FILTERS.format(query.from_user.mention),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n\n    elif query.data == \"global_filters\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='filters')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.GFILTER_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    \n    elif query.data == \"help\":\n        buttons = [[\n            InlineKeyboardButton('💼 𝖥𝗂𝗅𝗍𝖾𝗋𝗌 𝖬𝗈𝖽𝖾', callback_data='filters'),\n            InlineKeyboardButton('🗂 𝖥𝗂𝗅𝖾 𝖲𝗍𝗈𝗋𝖾', callback_data='store_file')\n        ], [\n            InlineKeyboardButton('📟 𝖢𝗈𝗇𝗇𝖾𝖼𝗍𝗂𝗈𝗇𝗌', callback_data='coct'),\n            InlineKeyboardButton('⚙ 𝖤𝗑𝗍𝗋𝖺 𝖬𝗈𝖽𝖾𝗌', callback_data='extra')\n        ], [\n            InlineKeyboardButton('🏘 𝖧𝗈𝗆𝖾', callback_data='start'),\n            InlineKeyboardButton('♻️ Status', callback_data='stats')\n        ]]\n        \n        reply_markup = InlineKeyboardMarkup(buttons)\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        await query.message.edit_text(\n            text=script.HELP_TXT.format(query.from_user.mention),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"about\":\n        buttons = [[\n            InlineKeyboardButton('🧬 𝖲𝗎𝗉𝗉𝗈𝗋𝗍 𝖦𝗋𝗈𝗎𝗉', url=f\"https://t.me/{SUPPORT_CHAT}\"),\n            InlineKeyboardButton('📍 𝖲𝗈𝗎𝗋𝖼𝖾 𝖢𝗈𝖽𝖾', callback_data='source')\n        ],[\n            InlineKeyboardButton('🏘 𝖧𝗈𝗆𝖾', callback_data='start'),\n            InlineKeyboardButton('❌ 𝖢𝗅𝗈𝗌𝖾', callback_data='close_data')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.ABOUT_TXT.format(temp.B_NAME),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"source\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='about')\n        ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        await query.message.edit_text(\n            text=script.SOURCE_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"manuelfilter\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='filters'),\n            InlineKeyboardButton('⏺ 𝖡𝗎𝗍𝗍𝗈𝗇𝗌', callback_data='button')\n        ]]\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        await query.message.edit_text(\n            text=script.MANUELFILTER_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"button\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='manuelfilter')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.BUTTON_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"autofilter\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='filters')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.AUTOFILTER_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"coct\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='help')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.CONNECTION_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"extra\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='help'),\n            InlineKeyboardButton('⚠ 𝖠𝖽𝗆𝗂𝗇', callback_data='admin')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.EXTRAMOD_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    \n    elif query.data == \"store_file\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='help')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.FILE_STORE_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    \n    elif query.data == \"admin\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='extra')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        await query.message.edit_text(\n            text=script.ADMIN_TXT,\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"stats\":\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='help'),\n            InlineKeyboardButton('♻️ 𝖱𝖾𝖿𝗋𝖾𝗌𝗁', callback_data='rfrsh')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        total = await Media.count_documents()\n        users = await db.total_users_count()\n        chats = await db.total_chat_count()\n        monsize = await db.get_db_size()\n        free = 536870912 - monsize\n        monsize = get_size(monsize)\n        free = get_size(free)\n        await query.message.edit_text(\n            text=script.STATUS_TXT.format(total, users, chats, monsize, free),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"rfrsh\":\n        await query.answer(\"Fetching MongoDb DataBase...\")\n        buttons = [[\n            InlineKeyboardButton('👩‍🦯 𝖡𝖺𝖼𝗄', callback_data='help'),\n            InlineKeyboardButton('♻️ 𝖱𝖾𝖿𝗋𝖾𝗌𝗁', callback_data='rfrsh')\n        ]]\n        await client.edit_message_media(\n            query.message.chat.id, \n            query.message.id, \n            InputMediaPhoto(random.choice(PICS))\n        )\n        reply_markup = InlineKeyboardMarkup(buttons)\n        total = await Media.count_documents()\n        users = await db.total_users_count()\n        chats = await db.total_chat_count()\n        monsize = await db.get_db_size()\n        free = 536870912 - monsize\n        monsize = get_size(monsize)\n        free = get_size(free)\n        await query.message.edit_text(\n            text=script.STATUS_TXT.format(total, users, chats, monsize, free),\n            reply_markup=reply_markup,\n            parse_mode=enums.ParseMode.HTML\n        )\n    elif query.data == \"owner_info\":\n            btn = [[\n                    InlineKeyboardButton(\"👩‍🦯 𝖡𝖺𝖼𝗄\", callback_data=\"start\"),\n                    InlineKeyboardButton(\"📞 𝖢𝗈𝗇𝗍𝖺𝖼𝗍\", url=f\"t.me/rithesh_rkrm_17\")\n                  ]]\n            await client.edit_message_media(\n                query.message.chat.id, \n                query.message.id, \n                InputMediaPhoto(random.choice(PICS))\n            )\n            reply_markup = InlineKeyboardMarkup(btn)\n            await query.message.edit_text(\n                text=(script.OWNER_INFO),\n                reply_markup=reply_markup,\n                parse_mode=enums.ParseMode.HTML\n            )\n\n    elif query.data.startswith(\"setgs\"):\n        ident, set_type, status, grp_id = query.data.split(\"#\")\n        grpid = await active_connection(str(query.from_user.id))\n\n        if str(grp_id) != str(grpid):\n            await query.message.edit(\"Your Active Connection Has Been Changed. Go To /settings.\")\n            return await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n\n        if status == \"True\":\n            await save_group_settings(grpid, set_type, False)\n        else:\n            await save_group_settings(grpid, set_type, True)\n\n        settings = await get_settings(grpid)\n\n        if settings is not None:\n            buttons = [\n                [\n                    InlineKeyboardButton('𝖥𝗂𝗅𝗍𝖾𝗋 𝖡𝗎𝗍𝗍𝗈𝗇',\n                                         callback_data=f'setgs#button#{settings[\"button\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('𝖲𝗂𝗇𝗀𝗅𝖾 𝖡𝗎𝗍𝗍𝗈𝗇' if settings[\"button\"] else '𝖣𝗈𝗎𝖻𝗅𝖾',\n                                         callback_data=f'setgs#button#{settings[\"button\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖥𝗂𝗅𝖾 𝖲𝖾𝗇𝖽 𝖬𝗈𝖽𝖾', callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('𝖬𝖺𝗇𝗎𝖺𝗅 𝖲𝗍𝖺𝗋𝗍' if settings[\"botpm\"] else '𝖠𝗎𝗍𝗈 𝖲𝖾𝗇𝖽',\n                                         callback_data=f'setgs#botpm#{settings[\"botpm\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖯𝗋𝗈𝗍𝖾𝖼𝗍 𝖢𝗈𝗇𝗍𝖾𝗇𝗍',\n                                         callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"file_secure\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#file_secure#{settings[\"file_secure\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖨𝖬𝖣𝖻', callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"imdb\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#imdb#{settings[\"imdb\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖲𝗉𝖾𝗅𝗅 𝖢𝗁𝖾𝖼𝗄',\n                                         callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"spell_check\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#spell_check#{settings[\"spell_check\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖶𝖾𝗅𝖼𝗈𝗆𝖾 𝖬𝖾𝗌𝗌𝖺𝗀𝖾', callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"welcome\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#welcome#{settings[\"welcome\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖠𝗎𝗍𝗈 𝖣𝖾𝗅𝖾𝗍𝖾',\n                                         callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('5 𝖬𝗂𝗇' if settings[\"auto_delete\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#auto_delete#{settings[\"auto_delete\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖠𝗎𝗍𝗈-𝖥𝗂𝗅𝗍𝖾𝗋',\n                                         callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('✅ 𝖮𝗇' if settings[\"auto_ffilter\"] else '❌ 𝖮𝖿𝖿',\n                                         callback_data=f'setgs#auto_ffilter#{settings[\"auto_ffilter\"]}#{str(grp_id)}')\n                ],\n                [\n                    InlineKeyboardButton('𝖬𝖺𝗑 𝖡𝗎𝗍𝗍𝗈𝗇𝗌',\n                                         callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{str(grp_id)}'),\n                    InlineKeyboardButton('10' if settings[\"max_btn\"] else f'{MAX_B_TN}',\n                                         callback_data=f'setgs#max_btn#{settings[\"max_btn\"]}#{str(grp_id)}')\n                ]\n            ]\n            reply_markup = InlineKeyboardMarkup(buttons)\n            await query.message.edit_reply_markup(reply_markup)\n    await query.answer('𝖯𝗂𝗋𝖺𝖼𝗒 𝗂𝗌 𝖢𝗋𝗂𝗆𝖾 !')\n\n    \nasync def auto_filter(client, msg, spoll=False):\n    reqstr1 = msg.from_user.id if msg.from_user else 0\n    reqstr = await client.get_users(reqstr1)\n    if not spoll:\n        message = msg\n        settings = await get_settings(message.chat.id)\n        if message.text.startswith(\"/\"): return  # ignore commands\n        if re.findall(\"((^\\/|^,|^!|^\\.|^[\\U0001F600-\\U000E007F]).*)\", message.text):\n            return\n        if len(message.text) < 100:\n            search = message.text\n            files, offset, total_results = await get_search_results(message.chat.id ,search.lower(), offset=0, filter=True)\n            if not files:\n                if settings[\"spell_check\"]:\n                    return await advantage_spell_chok(client, msg)\n                else:\n                    if NO_RESULTS_MSG:\n                        await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, search)))\n                    return\n        else:\n            return\n    else:\n        message = msg.message.reply_to_message  # msg will be callback query\n        search, files, offset, total_results = spoll\n        settings = await get_settings(msg.message.chat.id)\n        \n    key = f\"{message.chat.id}-{message.id}\"\n    temp.FILES_IDS[key] = files\n    pre = 'filep' if settings['file_secure'] else 'file'\n    req = message.from_user.id if message.from_user else 0\n    BUTTONS[key] = search\n    \n    if settings[\"button\"]:\n        btn = [\n            [\n                InlineKeyboardButton(\n                    text=f\"🔖{get_size(file.file_size)}🔮{file.file_name}\", callback_data=f'{pre}#{file.file_id}'\n                ),\n            ]\n            for file in files\n        ]\n    else:\n        btn = [\n            [\n                InlineKeyboardButton(\n                    text=f\"{file.file_name}\",\n                    callback_data=f'{pre}#{file.file_id}',\n                ),\n                InlineKeyboardButton(\n                    text=f\"{get_size(file.file_size)}\",\n                    callback_data=f'{pre}#{file.file_id}',\n                ),\n            ]\n            for file in files\n        ]\n\n    try:\n        if settings['auto_delete']:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n\n        else:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n                \n    except KeyError:\n        grpid = await active_connection(str(message.from_user.id))\n        await save_group_settings(grpid, 'auto_delete', True)\n        settings = await get_settings(message.chat.id)\n        if settings['auto_delete']:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ]\n            )\n\n        else:\n            btn.insert(0, \n            [\n                InlineKeyboardButton(f'😇 Info', 'tips'),\n                InlineKeyboardButton(f'📝 𝖳𝗂𝗉𝗌', 'info')\n            ])\n            \n                      \n    btn.insert(0, [\n        InlineKeyboardButton(f'🎬 {search} 🎬', 'rkbtn')\n    ])\n    btn.insert(2, [\n        InlineKeyboardButton(\"📤 𝖲𝖾𝗇𝖽 𝖠𝗅𝗅 𝖥𝗂𝗅𝖾𝗌 📤\", callback_data=f\"send_all#{req}#{key}#{pre}\")\n    ])\n    \n    if offset != \"\":\n        try:\n            settings = await get_settings(message.chat.id)\n            if settings['max_btn']:\n                btn.append(\n                    [InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(text=f\"1/{math.ceil(int(total_results)/10)}\",callback_data=\"pages\"), InlineKeyboardButton(text=\"𝖭𝖤𝖷𝖳 ▶️\",callback_data=f\"next_{req}_{key}_{offset}\")]\n                )\n            else:\n                btn.append(\n                    [InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(text=f\"1/{math.ceil(int(total_results)/int(MAX_B_TN))}\",callback_data=\"pages\"), InlineKeyboardButton(text=\"𝖭𝖤𝖷𝖳 ▶️\",callback_data=f\"next_{req}_{key}_{offset}\")]\n                )\n        except KeyError:\n            await save_group_settings(message.chat.id, 'max_btn', False)\n            settings = await get_settings(message.chat.id)\n            if settings['max_btn']:\n                btn.append(\n                    [InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(text=f\"1/{math.ceil(int(total_results)/10)}\",callback_data=\"pages\"), InlineKeyboardButton(text=\"𝖭𝖤𝖷𝖳 ▶️\",callback_data=f\"next_{req}_{key}_{offset}\")]\n                )\n            else:\n                btn.append(\n                    [InlineKeyboardButton(\"📃\", callback_data=\"pages\"), InlineKeyboardButton(text=f\"1/{math.ceil(int(total_results)/int(MAX_B_TN))}\",callback_data=\"pages\"), InlineKeyboardButton(text=\"𝖭𝖤𝖷𝖳 ▶️\",callback_data=f\"next_{req}_{key}_{offset}\")]\n                )\n    else:\n        btn.append(\n            [InlineKeyboardButton(text=\"❌ 𝖭𝗈 𝖬𝗈𝗋𝖾 𝖯𝖺𝗀𝖾𝗌 𝖠𝗏𝖺𝗂𝗅𝖺𝖻𝗅𝖾 ! ❌\",callback_data=\"pages\")]\n        )\n    imdb = await get_poster(search, file=(files[0]).file_name) if settings[\"imdb\"] else None\n    TEMPLATE = settings['template']\n    if imdb:\n        cap = TEMPLATE.format(\n            query=search,\n            title=imdb['title'],\n            votes=imdb['votes'],\n            aka=imdb[\"aka\"],\n            seasons=imdb[\"seasons\"],\n            box_office=imdb['box_office'],\n            localized_title=imdb['localized_title'],\n            kind=imdb['kind'],\n            imdb_id=imdb[\"imdb_id\"],\n            cast=imdb[\"cast\"],\n            runtime=imdb[\"runtime\"],\n            countries=imdb[\"countries\"],\n            certificates=imdb[\"certificates\"],\n            languages=imdb[\"languages\"],\n            director=imdb[\"director\"],\n            writer=imdb[\"writer\"],\n            producer=imdb[\"producer\"],\n            composer=imdb[\"composer\"],\n            cinematographer=imdb[\"cinematographer\"],\n            music_team=imdb[\"music_team\"],\n            distributors=imdb[\"distributors\"],\n            release_date=imdb['release_date'],\n            year=imdb['year'],\n            genres=imdb['genres'],\n            poster=imdb['poster'],\n            plot=imdb['plot'],\n            rating=imdb['rating'],\n            url=imdb['url'],\n            **locals()\n        )\n    else:\n        cap = f\"<b>👋 𝖧𝖾𝗒 {message.from_user.mention}\\n📁 𝖸𝗈𝗎𝗋 𝖥𝗂𝗅𝖾𝗌 𝖠𝗋𝖾 𝖱𝖾𝖺𝖽𝗒\\n\\n♨️ 𝖯𝗈𝗐𝖾𝗋𝖾𝖽 𝖡𝗒 @piroxbots</b>\"\n    if imdb and imdb.get('poster'):\n        try:\n            hehe = await message.reply_photo(photo=imdb.get('poster'), caption=cap[:1024], reply_markup=InlineKeyboardMarkup(btn))\n            try:\n                if settings['auto_delete']:\n                    await asyncio.sleep(600)\n                    await hehe.delete()\n                    await message.delete()\n            except KeyError:\n                grpid = await active_connection(str(message.from_user.id))\n                await save_group_settings(grpid, 'auto_delete', True)\n                settings = await get_settings(message.chat.id)\n                if settings['auto_delete']:\n                    await asyncio.sleep(600)\n                    await hehe.delete()\n                    await message.delete()\n        except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty):\n            pic = imdb.get('poster')\n            poster = pic.replace('.jpg', \"._V1_UX360.jpg\")\n            hmm = await message.reply_photo(photo=poster, caption=cap[:1024], reply_markup=InlineKeyboardMarkup(btn))\n            try:\n                if settings['auto_delete']:\n                    await asyncio.sleep(600)\n                    await hmm.delete()\n                    await message.delete()\n            except KeyError:\n                grpid = await active_connection(str(message.from_user.id))\n                await save_group_settings(grpid, 'auto_delete', True)\n                settings = await get_settings(message.chat.id)\n                if settings['auto_delete']:\n                    await asyncio.sleep(600)\n                    await hmm.delete()\n                    await message.delete()\n        except Exception as e:\n            logger.exception(e)\n            fek = await message.reply_photo(photo=NOR_IMG, caption=cap, reply_markup=InlineKeyboardMarkup(btn))\n            try:\n                if settings['auto_delete']:\n                    await asyncio.sleep(600)\n                    await fek.delete()\n                    await message.delete()\n            except KeyError:\n                grpid = await active_connection(str(message.from_user.id))\n                await save_group_settings(grpid, 'auto_delete', True)\n                settings = await get_settings(message.chat.id)\n                if settings['auto_delete']:\n                    await asyncio.sleep(600)\n                    await fek.delete()\n                    await message.delete()\n    else:\n        fuk = await message.reply_photo(photo=NOR_IMG, caption=cap, reply_markup=InlineKeyboardMarkup(btn))\n        try:\n            if settings['auto_delete']:\n                await asyncio.sleep(600)\n                await fuk.delete()\n                await message.delete()\n        except KeyError:\n            grpid = await active_connection(str(message.from_user.id))\n            await save_group_settings(grpid, 'auto_delete', True)\n            settings = await get_settings(message.chat.id)\n            if settings['auto_delete']:\n                await asyncio.sleep(600)\n                await fuk.delete()\n                await message.delete()\n    if spoll:\n        await msg.message.delete()\n\nasync def advantage_spell_chok(client, msg):\n    mv_id = msg.id\n    mv_rqst = msg.text\n    reqstr1 = msg.from_user.id if msg.from_user else 0\n    reqstr = await client.get_users(reqstr1)\n    settings = await get_settings(msg.chat.id)\n    query = re.sub(\n        r\"\\b(pl(i|e)*?(s|z+|ease|se|ese|(e+)s(e)?)|((send|snd|giv(e)?|gib)(\\sme)?)|movie(s)?|new|latest|br((o|u)h?)*|^h(e|a)?(l)*(o)*|mal(ayalam)?|t(h)?amil|file|that|find|und(o)*|kit(t(i|y)?)?o(w)?|thar(u)?(o)*w?|kittum(o)*|aya(k)*(um(o)*)?|full\\smovie|any(one)|with\\ssubtitle(s)?)\",\n        \"\", msg.text, flags=re.IGNORECASE)  # plis contribute some common words\n    query = query.strip() + \" movie\"\n    try:\n        movies = await get_poster(mv_rqst, bulk=True)\n    except Exception as e:\n        logger.exception(e)\n        reqst_gle = mv_rqst.replace(\" \", \"+\")\n        button = [[\n                   InlineKeyboardButton(\"🔎 𝖦𝗈𝗈𝗀𝗅𝖾\", url=f\"https://www.google.com/search?q={reqst_gle}\")\n        ]]\n        if NO_RESULTS_MSG:\n            await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst)))\n        k = await msg.reply_photo(\n            photo=SPELL_IMG, \n            caption=script.I_CUDNT.format(mv_rqst),\n            reply_markup=InlineKeyboardMarkup(button)\n        )\n        await asyncio.sleep(30)\n        await k.delete()\n        return\n    movielist = []\n    if not movies:\n        reqst_gle = mv_rqst.replace(\" \", \"+\")\n        button = [[\n                   InlineKeyboardButton(\"🔎 𝖦𝗈𝗈𝗀𝗅𝖾\", url=f\"https://www.google.com/search?q={reqst_gle}\")\n        ]]\n        if NO_RESULTS_MSG:\n            await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst)))\n        k = await msg.reply_photo(\n            photo=SPELL_IMG, \n            caption=script.I_CUDNT.format(mv_rqst),\n            reply_markup=InlineKeyboardMarkup(button)\n        )\n        await asyncio.sleep(30)\n        await k.delete()\n        return\n    movielist += [movie.get('title') for movie in movies]\n    movielist += [f\"{movie.get('title')} {movie.get('year')}\" for movie in movies]\n    key=f\"{msg.chat.id}-{msg.id}\"\n    temp.SPELL_CHECK[key] = movielist\n    btn = [\n        [\n            InlineKeyboardButton(\n                text=movie_name.strip(),\n                callback_data=f\"spol#{reqstr1}#{k}#{key}\",\n            )\n        ]\n        for k, movie_name in enumerate(movielist)\n    ]\n    btn.append([InlineKeyboardButton(text=\"Close\", callback_data=f'spol#{reqstr1}#close_spellcheck#{key}')])\n    spell_check_del = await msg.reply_photo(\n        photo=(SPELL_IMG),\n        caption=(script.CUDNT_FND.format(mv_rqst)),\n        reply_markup=InlineKeyboardMarkup(btn)\n    )\n    try:\n        if settings['auto_delete']:\n            await asyncio.sleep(600)\n            await spell_check_del.delete()\n    except KeyError:\n            grpid = await active_connection(str(message.from_user.id))\n            await save_group_settings(grpid, 'auto_delete', True)\n            settings = await get_settings(message.chat.id)\n            if settings['auto_delete']:\n                await asyncio.sleep(600)\n                await spell_check_del.delete()\n\n\nasync def manual_filters(client, message, text=False):\n    settings = await get_settings(message.chat.id)\n    group_id = message.chat.id\n    name = text or message.text\n    reply_id = message.reply_to_message.id if message.reply_to_message else message.id\n    keywords = await get_filters(group_id)\n    for keyword in reversed(sorted(keywords, key=len)):\n        pattern = r\"( |^|[^\\w])\" + re.escape(keyword) + r\"( |$|[^\\w])\"\n        if re.search(pattern, name, flags=re.IGNORECASE):\n            reply_text, btn, alert, fileid = await find_filter(group_id, keyword)\n\n            if reply_text:\n                reply_text = reply_text.replace(\"\\\\n\", \"\\n\").replace(\"\\\\t\", \"\\t\")\n\n            if btn is not None:\n                try:\n                    if fileid == \"None\":\n                        if btn == \"[]\":\n                            piroxrk = await client.send_message(\n                                group_id, \n                                reply_text, \n                                disable_web_page_preview=True,\n                                protect_content=True if settings[\"file_secure\"] else False,\n                                reply_to_message_id=reply_id\n                            )\n                            try:\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message)\n                                    try:\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                else:\n                                    try:\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                            except KeyError:\n                                grpid = await active_connection(str(message.from_user.id))\n                                await save_group_settings(grpid, 'auto_ffilter', True)\n                                settings = await get_settings(message.chat.id)\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message)\n\n                        else:\n                            button = eval(btn)\n                            piroxrk = await client.send_message(\n                                group_id,\n                                reply_text,\n                                disable_web_page_preview=True,\n                                reply_markup=InlineKeyboardMarkup(button),\n                                protect_content=True if settings[\"file_secure\"] else False,\n                                reply_to_message_id=reply_id\n                            )\n                            try:\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message)\n                                    try:\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                else:\n                                    try:\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                            except KeyError:\n                                grpid = await active_connection(str(message.from_user.id))\n                                await save_group_settings(grpid, 'auto_ffilter', True)\n                                settings = await get_settings(message.chat.id)\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message)\n\n                    elif btn == \"[]\":\n                        piroxrk = await client.send_cached_media(\n                            group_id,\n                            fileid,\n                            caption=reply_text or \"\",\n                            protect_content=True if settings[\"file_secure\"] else False,\n                            reply_to_message_id=reply_id\n                        )\n                        try:\n                            if settings['auto_ffilter']:\n                                await auto_filter(client, message)\n                                try:\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_delete', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                            else:\n                                try:\n                                    if settings['auto_delete']:\n                                        await asyncio.sleep(600)\n                                        await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_delete', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_delete']:\n                                        await asyncio.sleep(600)\n                                        await piroxrk.delete()\n                        except KeyError:\n                            grpid = await active_connection(str(message.from_user.id))\n                            await save_group_settings(grpid, 'auto_ffilter', True)\n                            settings = await get_settings(message.chat.id)\n                            if settings['auto_ffilter']:\n                                await auto_filter(client, message)\n\n                    else:\n                        button = eval(btn)\n                        piroxrk = await message.reply_cached_media(\n                            fileid,\n                            caption=reply_text or \"\",\n                            reply_markup=InlineKeyboardMarkup(button),\n                            reply_to_message_id=reply_id\n                        )\n                        try:\n                            if settings['auto_ffilter']:\n                                await auto_filter(client, message)\n                                try:\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_delete', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                            else:\n                                try:\n                                    if settings['auto_delete']:\n                                        await asyncio.sleep(600)\n                                        await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_delete', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_delete']:\n                                        await asyncio.sleep(600)\n                                        await piroxrk.delete()\n                        except KeyError:\n                            grpid = await active_connection(str(message.from_user.id))\n                            await save_group_settings(grpid, 'auto_ffilter', True)\n                            settings = await get_settings(message.chat.id)\n                            if settings['auto_ffilter']:\n                                await auto_filter(client, message)\n\n                except Exception as e:\n                    logger.exception(e)\n                break\n    else:\n        return False\n\nasync def global_filters(client, message, text=False):\n    settings = await get_settings(message.chat.id)\n    group_id = message.chat.id\n    name = text or message.text\n    reply_id = message.reply_to_message.id if message.reply_to_message else message.id\n    keywords = await get_gfilters('gfilters')\n    for keyword in reversed(sorted(keywords, key=len)):\n        pattern = r\"( |^|[^\\w])\" + re.escape(keyword) + r\"( |$|[^\\w])\"\n        if re.search(pattern, name, flags=re.IGNORECASE):\n            reply_text, btn, alert, fileid = await find_gfilter('gfilters', keyword)\n\n            if reply_text:\n                reply_text = reply_text.replace(\"\\\\n\", \"\\n\").replace(\"\\\\t\", \"\\t\")\n\n            if btn is not None:\n                try:\n                    if fileid == \"None\":\n                        if btn == \"[]\":\n                            piroxrk = await client.send_message(\n                                group_id, \n                                reply_text, \n                                disable_web_page_preview=True,\n                                reply_to_message_id=reply_id\n                            )\n                            manual = await manual_filters(client, message)\n                            if manual == False:\n                                settings = await get_settings(message.chat.id)\n                                try:\n                                    if settings['auto_ffilter']:\n                                        await auto_filter(client, message)\n                                        try:\n                                            if settings['auto_delete']:\n                                                await piroxrk.delete()\n                                        except KeyError:\n                                            grpid = await active_connection(str(message.from_user.id))\n                                            await save_group_settings(grpid, 'auto_delete', True)\n                                            settings = await get_settings(message.chat.id)\n                                            if settings['auto_delete']:\n                                                await piroxrk.delete()\n                                    else:\n                                        try:\n                                            if settings['auto_delete']:\n                                                await asyncio.sleep(600)\n                                                await piroxrk.delete()\n                                        except KeyError:\n                                            grpid = await active_connection(str(message.from_user.id))\n                                            await save_group_settings(grpid, 'auto_delete', True)\n                                            settings = await get_settings(message.chat.id)\n                                            if settings['auto_delete']:\n                                                await asyncio.sleep(600)\n                                                await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_ffilter', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_ffilter']:\n                                        await auto_filter(client, message) \n                            else:\n                                try:\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_delete', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                            \n                        else:\n                            button = eval(btn)\n                            piroxrk = await client.send_message(\n                                group_id,\n                                reply_text,\n                                disable_web_page_preview=True,\n                                reply_markup=InlineKeyboardMarkup(button),\n                                reply_to_message_id=reply_id\n                            )\n                            manual = await manual_filters(client, message)\n                            if manual == False:\n                                settings = await get_settings(message.chat.id)\n                                try:\n                                    if settings['auto_ffilter']:\n                                        await auto_filter(client, message)\n                                        try:\n                                            if settings['auto_delete']:\n                                                await piroxrk.delete()\n                                        except KeyError:\n                                            grpid = await active_connection(str(message.from_user.id))\n                                            await save_group_settings(grpid, 'auto_delete', True)\n                                            settings = await get_settings(message.chat.id)\n                                            if settings['auto_delete']:\n                                                await piroxrk.delete()\n                                    else:\n                                        try:\n                                            if settings['auto_delete']:\n                                                await asyncio.sleep(600)\n                                                await piroxrk.delete()\n                                        except KeyError:\n                                            grpid = await active_connection(str(message.from_user.id))\n                                            await save_group_settings(grpid, 'auto_delete', True)\n                                            settings = await get_settings(message.chat.id)\n                                            if settings['auto_delete']:\n                                                await asyncio.sleep(600)\n                                                await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_ffilter', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_ffilter']:\n                                        await auto_filter(client, message) \n                            else:\n                                try:\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n                                except KeyError:\n                                    grpid = await active_connection(str(message.from_user.id))\n                                    await save_group_settings(grpid, 'auto_delete', True)\n                                    settings = await get_settings(message.chat.id)\n                                    if settings['auto_delete']:\n                                        await piroxrk.delete()\n\n                    elif btn == \"[]\":\n                        piroxrk = await client.send_cached_media(\n                            group_id,\n                            fileid,\n                            caption=reply_text or \"\",\n                            reply_to_message_id=reply_id\n                        )\n                        manual = await manual_filters(client, message)\n                        if manual == False:\n                            settings = await get_settings(message.chat.id)\n                            try:\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message)\n                                    try:\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                else:\n                                    try:\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                            except KeyError:\n                                grpid = await active_connection(str(message.from_user.id))\n                                await save_group_settings(grpid, 'auto_ffilter', True)\n                                settings = await get_settings(message.chat.id)\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message) \n                        else:\n                            try:\n                                if settings['auto_delete']:\n                                    await piroxrk.delete()\n                            except KeyError:\n                                grpid = await active_connection(str(message.from_user.id))\n                                await save_group_settings(grpid, 'auto_delete', True)\n                                settings = await get_settings(message.chat.id)\n                                if settings['auto_delete']:\n                                    await piroxrk.delete()\n\n                    else:\n                        button = eval(btn)\n                        piroxrk = await message.reply_cached_media(\n                            fileid,\n                            caption=reply_text or \"\",\n                            reply_markup=InlineKeyboardMarkup(button),\n                            reply_to_message_id=reply_id\n                        )\n                        manual = await manual_filters(client, message)\n                        if manual == False:\n                            settings = await get_settings(message.chat.id)\n                            try:\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message)\n                                    try:\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await piroxrk.delete()\n                                else:\n                                    try:\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                                    except KeyError:\n                                        grpid = await active_connection(str(message.from_user.id))\n                                        await save_group_settings(grpid, 'auto_delete', True)\n                                        settings = await get_settings(message.chat.id)\n                                        if settings['auto_delete']:\n                                            await asyncio.sleep(600)\n                                            await piroxrk.delete()\n                            except KeyError:\n                                grpid = await active_connection(str(message.from_user.id))\n                                await save_group_settings(grpid, 'auto_ffilter', True)\n                                settings = await get_settings(message.chat.id)\n                                if settings['auto_ffilter']:\n                                    await auto_filter(client, message) \n                        else:\n                            try:\n                                if settings['auto_delete']:\n                                    await piroxrk.delete()\n                            except KeyError:\n                                grpid = await active_connection(str(message.from_user.id))\n                                await save_group_settings(grpid, 'auto_delete', True)\n                                settings = await get_settings(message.chat.id)\n                                if settings['auto_delete']:\n                                    await piroxrk.delete()\n\n                except Exception as e:\n                    logger.exception(e)\n                break\n    else:\n        return False\n"
  },
  {
    "path": "plugins/route.py",
    "content": "from aiohttp import web\r\n\r\nroutes = web.RouteTableDef()\r\n\r\n@routes.get(\"/\", allow_head=True)\r\nasync def root_route_handler(request):\r\n    return web.json_response(\"PIROBOTS\")"
  },
  {
    "path": "render.yaml",
    "content": "services:\r\n  # A Docker web service\r\n  - type: web\r\n    name: PiroAutoFilterBot\r\n    env: python\r\n    startCommand: python3 bot.py\r\n    buildCommand: pip3 install -U -r requirements.txt\r\n    repo: https://github/ritheshrkrm/PiroAutoFilterBot.git # optional\r\n    region: oregon # optional (defaults to oregon)\r\n    plan: free # optional (defaults to starter)\r\n    branch: master # optional (defaults to master)\r\n    numInstances: 1 # optional (defaults to 1)\r\n    healthCheckPath: /\r\n\r\n#End of yaml\r\n"
  },
  {
    "path": "requirements.txt",
    "content": "pyrogram>=2.0.30\ntgcrypto\npymongo[srv]==3.12.3\nmotor==2.5.1\nmarshmallow==3.14.1\numongo==3.0.1\nrequests\nbs4\ngit+https://github.com/ritheshrkrm/cinemagoer\ndatetime\npytz\naiohttp\npsutil==5.9.4"
  },
  {
    "path": "runtime.txt",
    "content": "python-3.10.8"
  },
  {
    "path": "sample_info.py",
    "content": "# Bot information\r\nSESSION = 'Media_search'\r\nUSER_SESSION = 'User_Bot'\r\nAPI_ID = 12345\r\nAPI_HASH = '0123456789abcdef0123456789abcdef'\r\nBOT_TOKEN = '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11'\r\nUSERBOT_STRING_SESSION = ''\r\n\r\n# Bot settings\r\nCACHE_TIME = 300\r\nUSE_CAPTION_FILTER = False\r\n\r\n# Admins, Channels & Users\r\nADMINS = [12345789, 'admin123', 98765432]\r\nCHANNELS = [-10012345678, -100987654321, 'channelusername']\r\nAUTH_USERS = []\r\nAUTH_CHANNEL = None\r\n\r\n# MongoDB information\r\nDATABASE_URI = \"mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb]?retryWrites=true&w=majority\"\r\nDATABASE_NAME = 'Telegram'\r\nCOLLECTION_NAME = 'channel_files'  # If you are using the same database, then use different collection name for each bot\r\n\r\n\r\n"
  },
  {
    "path": "start.sh",
    "content": "if [ -z $UPSTREAM_REPO ]\nthen\n  echo \"Cloning main Repository\"\n  git clone https://github.com/ritheshrkrm/PiroAutoFilterBot.git /PiroAutoFilterBot\nelse\n  echo \"Cloning Custom Repo from $UPSTREAM_REPO \"\n  git clone $UPSTREAM_REPO /PiroAutoFilterBot\nfi\ncd /PiroAutoFilterBot\npip3 install -U -r requirements.txt\necho \"Starting PiroAutoFilterBot....\"\npython3 bot.py\n"
  },
  {
    "path": "utils.py",
    "content": "import logging\nfrom pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid\nfrom info import AUTH_CHANNEL, LONG_IMDB_DESCRIPTION, MAX_LIST_ELM, CUSTOM_FILE_CAPTION\nfrom imdb import Cinemagoer \nimport asyncio\nfrom pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup\nfrom pyrogram import enums\nfrom typing import Union\nimport random \nimport re\nimport os\nfrom datetime import datetime\nfrom typing import List\nfrom database.users_chats_db import db\nfrom bs4 import BeautifulSoup\nimport requests\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.INFO)\n\nBTN_URL_REGEX = re.compile(\n    r\"(\\[([^\\[]+?)\\]\\((buttonurl|buttonalert):(?:/{0,2})(.+?)(:same)?\\))\"\n)\n\nimdb = Cinemagoer() \n\nBANNED = {}\nSMART_OPEN = '“'\nSMART_CLOSE = '”'\nSTART_CHAR = ('\\'', '\"', SMART_OPEN)\n\n# temp db for banned \nclass temp(object):\n    BANNED_USERS = []\n    BANNED_CHATS = []\n    ME = None\n    CURRENT=int(os.environ.get(\"SKIP\", 2))\n    CANCEL = False\n    MELCOW = {}\n    FILES = {}\n    U_NAME = None\n    B_NAME = None\n    SETTINGS = {}\n    FILES_IDS = {}\n    SPELL_CHECK = {}\n\nasync def is_subscribed(bot, query):\n    try:\n        user = await bot.get_chat_member(AUTH_CHANNEL, query.from_user.id)\n    except UserNotParticipant:\n        pass\n    except Exception as e:\n        logger.exception(e)\n    else:\n        if user.status != enums.ChatMemberStatus.BANNED:\n            return True\n\n    return False\n\nasync def get_poster(query, bulk=False, id=False, file=None):\n    if not id:\n        query = (query.strip()).lower()\n        title = query\n        year = re.findall(r'[1-2]\\d{3}$', query, re.IGNORECASE)\n        if year:\n            year = list_to_str(year[:1])\n            title = (query.replace(year, \"\")).strip()\n        elif file is not None:\n            year = re.findall(r'[1-2]\\d{3}', file, re.IGNORECASE)\n            if year:\n                year = list_to_str(year[:1]) \n        else:\n            year = None\n        movieid = imdb.search_movie(title.lower(), results=10)\n        if not movieid:\n            return None\n        if year:\n            filtered=list(filter(lambda k: str(k.get('year')) == str(year), movieid))\n            if not filtered:\n                filtered = movieid\n        else:\n            filtered = movieid\n        movieid=list(filter(lambda k: k.get('kind') in ['movie', 'tv series'], filtered))\n        if not movieid:\n            movieid = filtered\n        if bulk:\n            return movieid\n        movieid = movieid[0].movieID\n    else:\n        movieid = query\n    movie = imdb.get_movie(movieid)\n    if movie.get(\"original air date\"):\n        date = movie[\"original air date\"]\n    elif movie.get(\"year\"):\n        date = movie.get(\"year\")\n    else:\n        date = \"N/A\"\n    plot = \"\"\n    if not LONG_IMDB_DESCRIPTION:\n        plot = movie.get('plot')\n        if plot and len(plot) > 0:\n            plot = plot[0]\n    else:\n        plot = movie.get('plot outline')\n    if plot and len(plot) > 800:\n        plot = plot[0:800] + \"...\"\n\n    return {\n        'title': movie.get('title'),\n        'votes': movie.get('votes'),\n        \"aka\": list_to_str(movie.get(\"akas\")),\n        \"seasons\": movie.get(\"number of seasons\"),\n        \"box_office\": movie.get('box office'),\n        'localized_title': movie.get('localized title'),\n        'kind': movie.get(\"kind\"),\n        \"imdb_id\": f\"tt{movie.get('imdbID')}\",\n        \"cast\": list_to_str(movie.get(\"cast\")),\n        \"runtime\": list_to_str(movie.get(\"runtimes\")),\n        \"countries\": list_to_str(movie.get(\"countries\")),\n        \"certificates\": list_to_str(movie.get(\"certificates\")),\n        \"languages\": list_to_str(movie.get(\"languages\")),\n        \"director\": list_to_str(movie.get(\"director\")),\n        \"writer\":list_to_str(movie.get(\"writer\")),\n        \"producer\":list_to_str(movie.get(\"producer\")),\n        \"composer\":list_to_str(movie.get(\"composer\")) ,\n        \"cinematographer\":list_to_str(movie.get(\"cinematographer\")),\n        \"music_team\": list_to_str(movie.get(\"music department\")),\n        \"distributors\": list_to_str(movie.get(\"distributors\")),\n        'release_date': date,\n        'year': movie.get('year'),\n        'genres': list_to_str(movie.get(\"genres\")),\n        'poster': movie.get('full-size cover url'),\n        'plot': plot,\n        'rating': str(movie.get(\"rating\")),\n        'url':f'https://www.imdb.com/title/tt{movieid}'\n    }\n\nasync def broadcast_messages(user_id, message):\n    try:\n        await message.copy(chat_id=user_id)\n        return True, \"Success\"\n    except FloodWait as e:\n        await asyncio.sleep(e.x)\n        return await broadcast_messages(user_id, message)\n    except InputUserDeactivated:\n        await db.delete_user(int(user_id))\n        logging.info(f\"{user_id}-Removed from Database, since deleted account.\")\n        return False, \"Deleted\"\n    except UserIsBlocked:\n        logging.info(f\"{user_id} -Blocked the bot.\")\n        return False, \"Blocked\"\n    except PeerIdInvalid:\n        await db.delete_user(int(user_id))\n        logging.info(f\"{user_id} - PeerIdInvalid\")\n        return False, \"Error\"\n    except Exception as e:\n        return False, \"Error\"\n\nasync def broadcast_messages_group(chat_id, message):\n    try:\n        kd = await message.copy(chat_id=chat_id)\n        try:\n            await kd.pin()\n        except:\n            pass\n        return True, \"Succes\"\n    except FloodWait as e:\n        await asyncio.sleep(e.x)\n        return await broadcast_messages_group(chat_id, message)\n    except Exception as e:\n        return False, \"Error\"\n\nasync def search_gagala(text):\n    usr_agent = {\n        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '\n        'Chrome/61.0.3163.100 Safari/537.36'\n        }\n    text = text.replace(\" \", '+')\n    url = f'https://www.google.com/search?q={text}'\n    response = requests.get(url, headers=usr_agent)\n    response.raise_for_status()\n    soup = BeautifulSoup(response.text, 'html.parser')\n    titles = soup.find_all( 'h3' )\n    return [title.getText() for title in titles]\n\n\nasync def get_settings(group_id):\n    settings = temp.SETTINGS.get(group_id)\n    if not settings:\n        settings = await db.get_settings(group_id)\n        temp.SETTINGS[group_id] = settings\n    return settings\n    \nasync def save_group_settings(group_id, key, value):\n    current = await get_settings(group_id)\n    current[key] = value\n    temp.SETTINGS[group_id] = current\n    await db.update_settings(group_id, current)\n    \ndef get_size(size):\n    \"\"\"Get size in readable format\"\"\"\n\n    units = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\"]\n    size = float(size)\n    i = 0\n    while size >= 1024.0 and i < len(units):\n        i += 1\n        size /= 1024.0\n    return \"%.2f %s\" % (size, units[i])\n\ndef split_list(l, n):\n    for i in range(0, len(l), n):\n        yield l[i:i + n]  \n\ndef get_file_id(msg: Message):\n    if msg.media:\n        for message_type in (\n            \"photo\",\n            \"animation\",\n            \"audio\",\n            \"document\",\n            \"video\",\n            \"video_note\",\n            \"voice\",\n            \"sticker\"\n        ):\n            obj = getattr(msg, message_type)\n            if obj:\n                setattr(obj, \"message_type\", message_type)\n                return obj\n\ndef extract_user(message: Message) -> Union[int, str]:\n    \"\"\"extracts the user from a message\"\"\"\n    user_id = None\n    user_first_name = None\n    if message.reply_to_message:\n        user_id = message.reply_to_message.from_user.id\n        user_first_name = message.reply_to_message.from_user.first_name\n\n    elif len(message.command) > 1:\n        if (\n            len(message.entities) > 1 and\n            message.entities[1].type == enums.MessageEntityType.TEXT_MENTION\n        ):\n           \n            required_entity = message.entities[1]\n            user_id = required_entity.user.id\n            user_first_name = required_entity.user.first_name\n        else:\n            user_id = message.command[1]\n            # don't want to make a request -_-\n            user_first_name = user_id\n        try:\n            user_id = int(user_id)\n        except ValueError:\n            pass\n    else:\n        user_id = message.from_user.id\n        user_first_name = message.from_user.first_name\n    return (user_id, user_first_name)\n\ndef list_to_str(k):\n    if not k:\n        return \"N/A\"\n    elif len(k) == 1:\n        return str(k[0])\n    elif MAX_LIST_ELM:\n        k = k[:int(MAX_LIST_ELM)]\n        return ' '.join(f'{elem}, ' for elem in k)\n    else:\n        return ' '.join(f'{elem}, ' for elem in k)\n\ndef last_online(from_user):\n    time = \"\"\n    if from_user.is_bot:\n        time += \"🤖 Bot :(\"\n    elif from_user.status == enums.UserStatus.RECENTLY:\n        time += \"Recently\"\n    elif from_user.status == enums.UserStatus.LAST_WEEK:\n        time += \"Within the last week\"\n    elif from_user.status == enums.UserStatus.LAST_MONTH:\n        time += \"Within the last month\"\n    elif from_user.status == enums.UserStatus.LONG_AGO:\n        time += \"A long time ago :(\"\n    elif from_user.status == enums.UserStatus.ONLINE:\n        time += \"Currently Online\"\n    elif from_user.status == enums.UserStatus.OFFLINE:\n        time += from_user.last_online_date.strftime(\"%a, %d %b %Y, %H:%M:%S\")\n    return time\n\n\ndef split_quotes(text: str) -> List:\n    if not any(text.startswith(char) for char in START_CHAR):\n        return text.split(None, 1)\n    counter = 1  # ignore first char -> is some kind of quote\n    while counter < len(text):\n        if text[counter] == \"\\\\\":\n            counter += 1\n        elif text[counter] == text[0] or (text[0] == SMART_OPEN and text[counter] == SMART_CLOSE):\n            break\n        counter += 1\n    else:\n        return text.split(None, 1)\n\n    # 1 to avoid starting quote, and counter is exclusive so avoids ending\n    key = remove_escapes(text[1:counter].strip())\n    # index will be in range, or `else` would have been executed and returned\n    rest = text[counter + 1:].strip()\n    if not key:\n        key = text[0] + text[0]\n    return list(filter(None, [key, rest]))\n\ndef gfilterparser(text, keyword):\n    if \"buttonalert\" in text:\n        text = (text.replace(\"\\n\", \"\\\\n\").replace(\"\\t\", \"\\\\t\"))\n    buttons = []\n    note_data = \"\"\n    prev = 0\n    i = 0\n    alerts = []\n    for match in BTN_URL_REGEX.finditer(text):\n        # Check if btnurl is escaped\n        n_escapes = 0\n        to_check = match.start(1) - 1\n        while to_check > 0 and text[to_check] == \"\\\\\":\n            n_escapes += 1\n            to_check -= 1\n\n        # if even, not escaped -> create button\n        if n_escapes % 2 == 0:\n            note_data += text[prev:match.start(1)]\n            prev = match.end(1)\n            if match.group(3) == \"buttonalert\":\n                # create a thruple with button label, url, and newline status\n                if bool(match.group(5)) and buttons:\n                    buttons[-1].append(InlineKeyboardButton(\n                        text=match.group(2),\n                        callback_data=f\"gfilteralert:{i}:{keyword}\"\n                    ))\n                else:\n                    buttons.append([InlineKeyboardButton(\n                        text=match.group(2),\n                        callback_data=f\"gfilteralert:{i}:{keyword}\"\n                    )])\n                i += 1\n                alerts.append(match.group(4))\n            elif bool(match.group(5)) and buttons:\n                buttons[-1].append(InlineKeyboardButton(\n                    text=match.group(2),\n                    url=match.group(4).replace(\" \", \"\")\n                ))\n            else:\n                buttons.append([InlineKeyboardButton(\n                    text=match.group(2),\n                    url=match.group(4).replace(\" \", \"\")\n                )])\n\n        else:\n            note_data += text[prev:to_check]\n            prev = match.start(1) - 1\n    else:\n        note_data += text[prev:]\n\n    try:\n        return note_data, buttons, alerts\n    except:\n        return note_data, buttons, None\n\ndef parser(text, keyword):\n    if \"buttonalert\" in text:\n        text = (text.replace(\"\\n\", \"\\\\n\").replace(\"\\t\", \"\\\\t\"))\n    buttons = []\n    note_data = \"\"\n    prev = 0\n    i = 0\n    alerts = []\n    for match in BTN_URL_REGEX.finditer(text):\n        # Check if btnurl is escaped\n        n_escapes = 0\n        to_check = match.start(1) - 1\n        while to_check > 0 and text[to_check] == \"\\\\\":\n            n_escapes += 1\n            to_check -= 1\n\n        # if even, not escaped -> create button\n        if n_escapes % 2 == 0:\n            note_data += text[prev:match.start(1)]\n            prev = match.end(1)\n            if match.group(3) == \"buttonalert\":\n                # create a thruple with button label, url, and newline status\n                if bool(match.group(5)) and buttons:\n                    buttons[-1].append(InlineKeyboardButton(\n                        text=match.group(2),\n                        callback_data=f\"alertmessage:{i}:{keyword}\"\n                    ))\n                else:\n                    buttons.append([InlineKeyboardButton(\n                        text=match.group(2),\n                        callback_data=f\"alertmessage:{i}:{keyword}\"\n                    )])\n                i += 1\n                alerts.append(match.group(4))\n            elif bool(match.group(5)) and buttons:\n                buttons[-1].append(InlineKeyboardButton(\n                    text=match.group(2),\n                    url=match.group(4).replace(\" \", \"\")\n                ))\n            else:\n                buttons.append([InlineKeyboardButton(\n                    text=match.group(2),\n                    url=match.group(4).replace(\" \", \"\")\n                )])\n\n        else:\n            note_data += text[prev:to_check]\n            prev = match.start(1) - 1\n    else:\n        note_data += text[prev:]\n\n    try:\n        return note_data, buttons, alerts\n    except:\n        return note_data, buttons, None\n\ndef remove_escapes(text: str) -> str:\n    res = \"\"\n    is_escaped = False\n    for counter in range(len(text)):\n        if is_escaped:\n            res += text[counter]\n            is_escaped = False\n        elif text[counter] == \"\\\\\":\n            is_escaped = True\n        else:\n            res += text[counter]\n    return res\n\n\ndef humanbytes(size):\n    if not size:\n        return \"\"\n    power = 2**10\n    n = 0\n    Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'}\n    while size > power:\n        size /= power\n        n += 1\n    return str(round(size, 2)) + \" \" + Dic_powerN[n] + 'B'\n\nasync def send_all(bot, userid, files, ident):\n    for file in files:\n        f_caption = file.caption\n        title = file.file_name\n        size = get_size(file.file_size)\n        if CUSTOM_FILE_CAPTION:\n            try:\n                f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title,\n                                                        file_size='' if size is None else size,\n                                                        file_caption='' if f_caption is None else f_caption)\n            except Exception as e:\n                print(e)\n                f_caption = f_caption\n        if f_caption is None:\n            f_caption = f\"{title}\"\n        await bot.send_cached_media(\n            chat_id=userid,\n            file_id=file.file_id,\n            caption=f_caption,\n            protect_content=True if ident == \"filep\" else False,\n            reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('⚔️ 𝖯𝖨𝖱𝖮 𝖴𝖯𝖣𝖠𝖳𝖤𝖲 ⚔️', url=\"https://t.me/piroxbots\") ] ] ))\n"
  }
]