diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c1b1139f0e44afc9a4e2ee13af92dcbdfe238535 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.10.8-slim-buster + +RUN apt update && apt upgrade -y +RUN apt install git -y +COPY requirements.txt /requirements.txt + +RUN cd / +RUN pip3 install -U pip && pip3 install -U -r requirements.txt +RUN mkdir /TheMovieProviderBot +WORKDIR /TheMovieProviderBot +COPY start.sh /start.sh +CMD ["/bin/bash", "/start.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d159169d1050894d3ea3b98e1c965c4058208fe1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000000000000000000000000000000000..b3276e25f2670db0a2d50ea1d0deca3634341047 --- /dev/null +++ b/Procfile @@ -0,0 +1,2 @@ +web: python3 bot.py +worker: python3 bot.py diff --git a/README.md b/README.md index b087b5ee4abf966d9d0e70093c19267098b0bafe..f3b17d95564274b9b9658bca0f94e3b6114a9c67 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,8 @@ ---- -title: File -emoji: ⚡ -colorFrom: red -colorTo: purple -sdk: gradio -sdk_version: 5.33.0 -app_file: app.py -pinned: false ---- +# TheMovieProviderBot Hugging Face Space -Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference +This Space provides a frontend to interact with your bot and download setup files. + +## Usage +- Clone the original bot: https://github.com/HarshalPurohitEdits/TheMovieProviderBot.git +- Replace the `bot` directory with your customized files +- Deploy to Hugging Face diff --git a/Script.py b/Script.py new file mode 100644 index 0000000000000000000000000000000000000000..68c79c4aa72ff0663f02f9d6c8addff96924c8e3 --- /dev/null +++ b/Script.py @@ -0,0 +1,449 @@ +class script(object): + START_TXT = """ʜᴇʏ {}, {}\n\nɪ ᴀᴍ ᴛʜᴇ ᴍᴏꜱᴛ ᴘᴏᴡᴇʀꜰᴜʟ ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ ʙᴏᴛ ᴡɪᴛʜ ᴘʀᴇᴍɪᴜᴍ ꜰᴇᴀᴛᴜʀᴇꜱ.\n\nᴍᴀɴᴛᴀɪɴᴇᴅ ʙʏ : ʜᴘ""" + + GSTART_TXT = """ʜᴇʏ {},\n\nɪ ᴀᴍ ᴛʜᴇ ᴍᴏꜱᴛ ᴘᴏᴡᴇʀꜰᴜʟ ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ ʙᴏᴛ ᴡɪᴛʜ ᴘʀᴇᴍɪᴜᴍ ꜰᴇᴀᴛᴜʀᴇꜱ.\n\nᴍᴀɴᴛᴀɪɴᴇᴅ ʙʏ : ʜᴘ""" + + HELP_TXT = """ʜᴇʏ {}, + +ᴡᴇ ʜᴀᴠᴇ ᴅᴇᴠɪᴅᴇᴅ ʙᴏᴛ ᴄᴏᴍᴍᴀɴᴅꜱ ꜰᴏʀ ɢʀᴏᴜᴘ ᴏᴡɴᴇʀꜱ ᴀɴᴅ ʙᴏᴛ ᴜꜱᴇʀꜱ.""" + + ABOUT_TXT = """‣ ᴍʏ ɴᴀᴍᴇ : {}\n‣ ᴄʀᴇᴀᴛᴏʀ : Hᴀʀꜱʜᴀʟ ❤️‍🔥\n‣ ʟɪʙʀᴀʀʏ : ᴘʏʀᴏɢʀᴀᴍ\n‣ ʟᴀɴɢᴜᴀɢᴇ : ᴘʏᴛʜᴏɴ\n‣ ᴅᴀᴛᴀ ʙᴀsᴇ : ᴍᴏɴɢᴏ ᴅʙ\n‣ ʜᴏsᴛᴇᴅ ᴏɴ : ʜᴇʀᴏᴋᴜ\n‣ ʙᴜɪʟᴅ sᴛᴀᴛᴜs : ᴠ4.2 [sᴛᴀʙʟᴇ]""" + + CHANNELS = """ +⚡ ɢʀᴏᴜᴘs & ᴄʜᴀɴɴᴇʟs ɪɴғᴏ ⚡ + +▫ ᴀʟʟ ɴᴇᴡ ᴍᴏᴠɪᴇs & sᴇʀɪᴇs. +▫ ғᴀsᴛᴇsᴛ ʙᴏᴛs ᴀʀᴇ ᴀᴅᴅᴇᴅ. +▫ ғʀᴇᴇ & ᴇᴀsʏ ᴛᴏ ᴜsᴇ. +▫ 𝟸𝟺x𝟽 sᴇʀᴠɪᴄᴇs ᴀᴠᴀɪʟᴀʙʟᴇ.""" + + STATUS_TXT = """ +‣ ᴛᴏᴛᴀʟ ꜰɪʟᴇꜱ : {} +‣ ᴛᴏᴛᴀʟ ᴜꜱᴇʀꜱ : {} +‣ ᴛᴏᴛᴀʟ ɢʀᴏᴜᴘꜱ : {} +‣ ᴜꜱᴇᴅ ꜱᴛᴏʀᴀɢᴇ : {} +‣ ꜰʀᴇᴇ ꜱᴛᴏʀᴀɢᴇ : {} +""" + + LOG_TEXT_G = """#NewGroup + +Gʀᴏᴜᴘ = {} +Iᴅ = {} +Tᴏᴛᴀʟ Mᴇᴍʙᴇʀs = {} +Aᴅᴅᴇᴅ Bʏ - {} + +Bʏ @TheMovieProviderBot""" + + LOG_TEXT_P = """#NewUser + +Iᴅ - {} +Nᴀᴍᴇ - {} + +Bʏ @TheMovieProviderBot""" + + ALRT_TXT = """ʜᴇʟʟᴏ {}, +ᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ, +ʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...""" + + OLD_ALRT_TXT = """ʜᴇʏ {}, +ʏᴏᴜ ᴀʀᴇ ᴜꜱɪɴɢ ᴏɴᴇ ᴏꜰ ᴍʏ ᴏʟᴅ ᴍᴇꜱꜱᴀɢᴇꜱ, +ᴘʟᴇᴀꜱᴇ ꜱᴇɴᴅ ᴛʜᴇ ʀᴇǫᴜᴇꜱᴛ ᴀɢᴀɪɴ.""" + + CUDNT_FND = """Sᴘᴇʟʟɪɴɢ Mɪꜱᴛᴀᴋᴇ Bʀᴏ ‼️\nᴅᴏɴ'ᴛ ᴡᴏʀʀʏ 😊 Cʜᴏᴏꜱᴇ ᴛʜᴇ ᴄᴏʀʀᴇᴄᴛ ᴏɴᴇ ʙᴇʟᴏᴡ 👇""" + + I_CUDNT = """sᴏʀʀʏ ɴᴏ ꜰɪʟᴇs ᴡᴇʀᴇ ꜰᴏᴜɴᴅ ꜰᴏʀ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ {} 😕 + +ᴍᴏᴠɪᴇ ɴᴏᴛ ᴀᴠᴀɪʟᴀʙʟᴇ ʀᴇᴀsᴏɴ : + +1) ᴏ.ᴛ.ᴛ ᴏʀ ᴅᴠᴅ ɴᴏᴛ ʀᴇʟᴇᴀsᴇᴅ + +2) ᴛʏᴘᴇ ɴᴀᴍᴇ ᴡɪᴛʜ ʏᴇᴀʀ + +3) ᴍᴏᴠɪᴇ ɪs ɴᴏᴛ ᴀᴠᴀɪʟᴀʙʟᴇ ɪɴ ᴛʜᴇ ᴅᴀᴛᴀʙᴀsᴇ ʀᴇᴘᴏʀᴛ ᴛᴏ ᴀᴅᴍɪɴs @HpMovieRequest""" + + I_CUD_NT = """ɪ ᴄᴏᴜʟᴅɴ'ᴛ ꜰɪɴᴅ ᴀɴʏ ᴍᴏᴠɪᴇ ʀᴇʟᴀᴛᴇᴅ ᴛᴏ {}. + +ᴍᴏᴠɪᴇ ɴᴏᴛ ᴀᴠᴀɪʟᴀʙʟᴇ ʀᴇᴀsᴏɴ : + +1) ᴏ.ᴛ.ᴛ ᴏʀ ᴅᴠᴅ ɴᴏᴛ ʀᴇʟᴇᴀsᴇᴅ + +2) ᴛʏᴘᴇ ɴᴀᴍᴇ ᴡɪᴛʜ ʏᴇᴀʀ + +3) ᴍᴏᴠɪᴇ ɪs ɴᴏᴛ ᴀᴠᴀɪʟᴀʙʟᴇ ɪɴ ᴛʜᴇ ᴅᴀᴛᴀʙᴀsᴇ ʀᴇᴘᴏʀᴛ ᴛᴏ ᴀᴅᴍɪɴs @HpMovieRequest""" + + MVE_NT_FND = """sᴏʀʀʏ ɴᴏ ꜰɪʟᴇs ᴡᴇʀᴇ ꜰᴏᴜɴᴅ ꜰᴏʀ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ 😕 + +ᴍᴏᴠɪᴇ ɴᴏᴛ ᴀᴠᴀɪʟᴀʙʟᴇ ʀᴇᴀsᴏɴ : + +1) ᴏ.ᴛ.ᴛ ᴏʀ ᴅᴠᴅ ɴᴏᴛ ʀᴇʟᴇᴀsᴇᴅ + +2) ᴛʏᴘᴇ ɴᴀᴍᴇ ᴡɪᴛʜ ʏᴇᴀʀ + +3) ᴍᴏᴠɪᴇ ɪs ɴᴏᴛ ᴀᴠᴀɪʟᴀʙʟᴇ ɪɴ ᴛʜᴇ ᴅᴀᴛᴀʙᴀsᴇ ʀᴇᴘᴏʀᴛ ᴛᴏ ᴀᴅᴍɪɴs @HpMovieRequest""" + + + TOP_ALRT_MSG = """ꜱᴇᴀʀᴄʜɪɴɢ ꜰᴏʀ ǫᴜᴇʀʏ ɪɴ ᴍʏ ᴅᴀᴛᴀʙᴀꜱᴇ...""" + + MELCOW_ENG = """👋 ʜᴇʏ {},\n\n🍁 ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ\n🌟 {} \n\n🔍 ʜᴇʀᴇ ʏᴏᴜ ᴄᴀɴ ꜱᴇᴀʀᴄʜ ʏᴏᴜʀ ꜰᴀᴠᴏᴜʀɪᴛᴇ ᴍᴏᴠɪᴇꜱ ᴏʀ ꜱᴇʀɪᴇꜱ ʙʏ ᴊᴜꜱᴛ ᴛʏᴘɪɴɢ ɪᴛ'ꜱ ɴᴀᴍᴇ 🔎\n\n⚠️ ɪꜰ ʏᴏᴜ'ʀᴇ ʜᴀᴠɪɴɢ ᴀɴʏ ᴘʀᴏʙʟᴇᴍ ʀᴇɢᴀʀᴅɪɴɢ ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ ᴏʀ ꜱᴏᴍᴇᴛʜɪɴɢ ᴇʟꜱᴇ ᴛʜᴇɴ ᴍᴇꜱꜱᴀɢᴇ ʜᴇʀᴇ 👇""" + + DISCLAIMER_TXT = """ +ᴛʜɪꜱ ɪꜱ ᴀɴ ᴏᴘᴇɴ ꜱᴏᴜʀᴄᴇ ᴘʀᴏᴊᴇᴄᴛ. + +ᴀʟʟ ᴛʜᴇ ꜰɪʟᴇꜱ ɪɴ ᴛʜɪꜱ ʙᴏᴛ ᴀʀᴇ ꜰʀᴇᴇʟʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴛʜᴇ ɪɴᴛᴇʀɴᴇᴛ ᴏʀ ᴘᴏꜱᴛᴇᴅ ʙʏ ꜱᴏᴍᴇʙᴏᴅʏ ᴇʟꜱᴇ. ᴊᴜꜱᴛ ꜰᴏʀ ᴇᴀꜱʏ ꜱᴇᴀʀᴄʜɪɴɢ ᴛʜɪꜱ ʙᴏᴛ ɪꜱ ɪɴᴅᴇxɪɴɢ ꜰɪʟᴇꜱ ᴡʜɪᴄʜ ᴀʀᴇ ᴀʟʀᴇᴀᴅʏ ᴜᴘʟᴏᴀᴅᴇᴅ ᴏɴ ᴛᴇʟᴇɢʀᴀᴍ. ᴡᴇ ʀᴇꜱᴘᴇᴄᴛ ᴀʟʟ ᴛʜᴇ ᴄᴏᴘʏʀɪɢʜᴛ ʟᴀᴡꜱ ᴀɴᴅ ᴡᴏʀᴋꜱ ɪɴ ᴄᴏᴍᴘʟɪᴀɴᴄᴇ ᴡɪᴛʜ ᴅᴍᴄᴀ ᴀɴᴅ ᴇᴜᴄᴅ. ɪꜰ ᴀɴʏᴛʜɪɴɢ ɪꜱ ᴀɢᴀɪɴꜱᴛ ʟᴀᴡ ᴘʟᴇᴀꜱᴇ ᴄᴏɴᴛᴀᴄᴛ ᴍᴇ ꜱᴏ ᴛʜᴀᴛ ɪᴛ ᴄᴀɴ ʙᴇ ʀᴇᴍᴏᴠᴇᴅ ᴀꜱᴀᴘ. ɪᴛ ɪꜱ ꜰᴏʀʙɪʙʙᴇɴ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ, ꜱᴛʀᴇᴀᴍ, ʀᴇᴘʀᴏᴅᴜᴄᴇ, ꜱʜᴀʀᴇ ᴏʀ ᴄᴏɴꜱᴜᴍᴇ ᴄᴏɴᴛᴇɴᴛ ᴡɪᴛʜᴏᴜᴛ ᴇxᴘʟɪᴄɪᴛ ᴘᴇʀᴍɪꜱꜱɪᴏɴ ꜰʀᴏᴍ ᴛʜᴇ ᴄᴏɴᴛᴇɴᴛ ᴄʀᴇᴀᴛᴏʀ ᴏʀ ʟᴇɢᴀʟ ᴄᴏᴘʏʀɪɢʜᴛ ʜᴏʟᴅᴇʀ. ɪꜰ ʏᴏᴜ ʙᴇʟɪᴇᴠᴇ ᴛʜɪꜱ ʙᴏᴛ ɪꜱ ᴠɪᴏʟᴀᴛɪɴɢ ʏᴏᴜʀ ɪɴᴛᴇʟʟᴇᴄᴛᴜᴀʟ ᴘʀᴏᴘᴇʀᴛʏ, ᴄᴏɴᴛᴀᴄᴛ ᴛʜᴇ ʀᴇꜱᴘᴇᴄᴛɪᴠᴇ ᴄʜᴀɴɴᴇʟꜱ ꜰᴏʀ ʀᴇᴍᴏᴠᴀʟ. ᴛʜᴇ ʙᴏᴛ ᴅᴏᴇꜱ ɴᴏᴛ ᴏᴡɴ ᴀɴʏ ᴏꜰ ᴛʜᴇꜱᴇ ᴄᴏɴᴛᴇɴᴛꜱ, ɪᴛ ᴏɴʟʏ ɪɴᴅᴇx ᴛʜᴇ ꜰɪʟᴇꜱ ꜰʀᴏᴍ ᴛᴇʟᴇɢʀᴀᴍ. + +🌿 ᴍᴀɪɴᴛᴀɪɴᴇᴅ ʙʏ : ʜᴘ""" + + USERS_TXT = """👋 ʜᴇʏ {}, + +📚 ʜᴇʀᴇ ᴀʀᴇ ᴍʏ ᴄᴏᴍᴍᴀɴᴅꜱ ʟɪꜱᴛ ꜰᴏʀ ᴀʟʟ ʙᴏᴛ ᴜꜱᴇʀꜱ ⇊ + +• /batch - ᴄʀᴇᴀᴛᴇ ᴀ ʙᴀᴛᴄʜ ʟɪɴᴋ ᴏғ ᴍᴜʟᴛɪᴘʟᴇ ғɪʟᴇs. +• /link - ᴄʀᴇᴀᴛᴇ ᴀ sɪɴɢʟᴇ ғɪʟᴇ sᴛᴏʀᴇ ʟɪɴᴋ. +• /pbatch - ᴊᴜsᴛ ʟɪᴋᴇ /batch, ʙᴜᴛ ᴛʜᴇ ғɪʟᴇs ᴡɪʟʟ ʙᴇ sᴇɴᴅ ᴡɪᴛʜ ғᴏʀᴡᴀʀᴅ ʀᴇsᴛʀɪᴄᴛɪᴏɴs. +• /plink - ᴊᴜsᴛ ʟɪᴋᴇ /link, ʙᴜᴛ ᴛʜᴇ ғɪʟᴇ ᴡɪʟʟ ʙᴇ sᴇɴᴅ ᴡɪᴛʜ ғᴏʀᴡᴀʀᴅ ʀᴇsᴛʀɪᴄᴛɪᴏɴ. +• /id - ɢᴇᴛ ɪᴅ ᴏꜰ ᴀ ꜱᴘᴇᴄɪꜰɪᴇᴅ ᴜꜱᴇʀ. +• /info - ɢᴇᴛ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ᴀʙᴏᴜᴛ ᴀ ᴜꜱᴇʀ. +• /imdb - ɢᴇᴛ ᴛʜᴇ ꜰɪʟᴍ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ꜰʀᴏᴍ ɪᴍᴅʙ ꜱᴏᴜʀᴄᴇ. +• /search - ɢᴇᴛ ᴛʜᴇ ꜰɪʟᴍ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ꜰʀᴏᴍ ᴠᴀʀɪᴏᴜꜱ ꜱᴏᴜʀᴄᴇꜱ. +• /stats - ɢᴇᴛ ꜱᴛᴀᴛᴜꜱ ᴏꜰ ꜰɪʟᴇꜱ ɪɴ ᴅʙ. +• /request - sᴇɴᴅ ᴀ Mᴏᴠɪᴇ/Sᴇʀɪᴇs ʀᴇᴏ̨ᴜᴇsᴛ ᴛᴏ ʙᴏᴛ ᴀᴅᴍɪɴs. ( ᴏɴʟʏ ᴡᴏʀᴋs ᴏɴ sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ ) +• /plan - ᴄʜᴇᴄᴋ ᴀᴠᴀɪʟᴀʙʟᴇ ᴘʀᴇᴍɪᴜᴍ ᴍᴇᴍʙᴇʀꜱʜɪᴘ ᴘʟᴀɴꜱ. +• /myplan - ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴄᴜʀʀᴜɴᴛ ᴘʟᴀɴ.""" + + GROUP_TXT = """👋 ʜᴇʏ {}, + +📚 ʜᴇʀᴇ ᴀʀᴇ ᴍʏ ᴄᴏᴍᴍᴀɴᴅꜱ ʟɪꜱᴛ ꜰᴏʀ ᴀʟʟ ɢʀᴏᴜᴘ ᴏᴡɴᴇʀꜱ ⇊ + +• /connect - ᴄᴏɴɴᴇᴄᴛ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ᴄʜᴀᴛ ᴛᴏ ʏᴏᴜʀ ᴘᴍ. +• /disconnect - ᴅɪꜱᴄᴏɴɴᴇᴄᴛ ꜰʀᴏᴍ ᴀ ᴄʜᴀᴛ. +• /shortlink - ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ꜱʜᴏʀᴛɴᴇʀ ᴡᴇʙꜱɪᴛᴇ. +• /set_tutorial - ꜱᴇᴛ ʏᴏᴜʀ ʜᴏᴡ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ᴠɪᴅᴇᴏ. +• /remove_tutorial - ꜱᴇᴛ ʏᴏᴜʀ ʜᴏᴡ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ᴠɪᴅᴇᴏ. +• /shortlink_info - ᴄʜᴇᴄᴋ ʏᴏᴜʀ ɢʀᴏᴜᴘ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ. +• /setshortlinkon - ᴏɴ ꜱʜᴏʀᴛʟɪɴᴋ ꜰᴏʀ ʏᴏᴜʀ ɢʀᴏᴜᴘ. +• /setshortlinkoff - ᴏꜰꜰ ꜱʜᴏʀᴛʟɪɴᴋ ꜰᴏʀ ʏᴏᴜʀ ɢʀᴏᴜᴘ. +• /connections - ʟɪꜱᴛ ᴀʟʟ ʏᴏᴜʀ ᴄᴏɴɴᴇᴄᴛɪᴏɴꜱ. +• /settings - ᴄʜᴀɴɢᴇ sᴇᴛᴛɪɴɢs ᴀs ʏᴏᴜʀ ᴡɪsʜ. +• /filter - ᴀᴅᴅ ᴀ ꜰɪʟᴛᴇʀ ɪɴ ᴀ ɢʀᴏᴜᴘ. +• /filters - ʟɪꜱᴛ ᴀʟʟ ᴛʜᴇ ꜰɪʟᴛᴇʀꜱ ᴏꜰ ᴀ ɢʀᴏᴜᴘ. +• /del - ᴅᴇʟᴇᴛᴇ ᴀ ꜱᴘᴇᴄɪꜰɪᴄ ꜰɪʟᴛᴇʀ ɪɴ ᴀ ɢʀᴏᴜᴘ. +• /delall - ᴅᴇʟᴇᴛᴇ ᴛʜᴇ ᴡʜᴏʟᴇ ꜰɪʟᴛᴇʀꜱ ɪɴ ᴀ ɢʀᴏᴜᴘ. +• /purge - ᴅᴇʟᴇᴛᴇ ᴀʟʟ ᴍᴇssᴀɢᴇs ꜰʀᴏᴍ ᴛʜᴇ ʀᴇᴘʟɪᴇᴅ ᴛᴏ ᴍᴇssᴀɢᴇ, ᴛᴏ ᴛʜᴇ ᴄᴜʀʀᴇɴᴛ ᴍᴇssᴀɢᴇ.""" + + ADMIC_TXT = """👋 ʜᴇʏ {}, + +📚 ʜᴇʀᴇ ᴀʀᴇ ᴍʏ ᴄᴏᴍᴍᴀɴᴅꜱ ʟɪꜱᴛ ꜰᴏʀ ᴀʟʟ ʙᴏᴛ ᴀᴅᴍɪɴꜱ ⇊ + +• /logs - ɢᴇᴛ ᴛʜᴇ ʀᴇᴄᴇɴᴛ ᴇʀʀᴏʀꜱ. +• /delete - ᴅᴇʟᴇᴛᴇ ᴀ ꜱᴘᴇᴄɪꜰɪᴄ ꜰɪʟᴇ ꜰʀᴏᴍ ᴅʙ. +• /users - ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴍʏ ᴜꜱᴇʀꜱ ᴀɴᴅ ɪᴅꜱ. +• /chats - ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴍʏ ᴄʜᴀᴛꜱ ᴀɴᴅ ɪᴅꜱ. +• /leave - ʟᴇᴀᴠᴇ ꜰʀᴏᴍ ᴀ ᴄʜᴀᴛ. +• /disable - ᴅɪꜱᴀʙʟᴇ ᴀ ᴄʜᴀᴛ. +• /ban - ʙᴀɴ ᴀ ᴜꜱᴇʀ. +• /unban - ᴜɴʙᴀɴ ᴀ ᴜꜱᴇʀ. +• /channel - ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴛᴏᴛᴀʟ ᴄᴏɴɴᴇᴄᴛᴇᴅ ɢʀᴏᴜᴘꜱ. +• /broadcast - ʙʀᴏᴀᴅᴄᴀꜱᴛ ᴀ ᴍᴇꜱꜱᴀɢᴇ ᴛᴏ ᴀʟʟ ᴜꜱᴇʀꜱ. +• /grp_broadcast - ʙʀᴏᴀᴅᴄᴀsᴛ ᴀ ᴍᴇssᴀɢᴇ ᴛᴏ ᴀʟʟ ᴄᴏɴɴᴇᴄᴛᴇᴅ ɢʀᴏᴜᴘs. +• /gfilter - ᴀᴅᴅ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs. +• /gfilters - ᴠɪᴇᴡ ʟɪsᴛ ᴏғ ᴀʟʟ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs. +• /delg - ᴅᴇʟᴇᴛᴇ ᴀ sᴘᴇᴄɪғɪᴄ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ. +• /delallg - ᴅᴇʟᴇᴛᴇ ᴀʟʟ Gғɪʟᴛᴇʀs ғʀᴏᴍ ᴛʜᴇ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. +• /deletefiles - ᴅᴇʟᴇᴛᴇ CᴀᴍRɪᴘ ᴀɴᴅ PʀᴇDVD ғɪʟᴇs ғʀᴏᴍ ᴛʜᴇ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. +• /send - ꜱᴇɴᴅ ᴍᴇꜱꜱᴀɢᴇ ᴛᴏ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ᴜꜱᴇʀ. +• /add_premium - ᴀᴅᴅ ᴀɴʏ ᴜꜱᴇʀ ᴛᴏ ᴘʀᴇᴍɪᴜᴍ. +• /remove_premium - ʀᴇᴍᴏᴠᴇ ᴀɴʏ ᴜꜱᴇʀ ꜰʀᴏᴍ ᴘʀᴇᴍɪᴜᴍ. +• /premium_users - ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀꜱ. +• /get_premium - ɢᴇᴛ ɪɴꜰᴏ ᴏꜰ ᴀɴʏ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀ. +• /restart - ʀᴇꜱᴛᴀʀᴛ ᴛʜᴇ ʙᴏᴛ.""" + + SHORTLINK_INFO = """ + ❗ʜᴏᴡ ᴛᴏ ᴇᴀʀɴ ᴍᴏɴᴇʏ ᴜꜱɪɴɢ ʙᴏᴛ❗ + +★ ɴᴏᴡ ʏᴏᴜ ᴄᴀɴ ꜱᴛᴀʀᴛ ᴇᴀʀɴɪɴɢ 💸 ᴍᴏɴᴇʏ ᴛᴏᴅᴀʏ ᴡɪᴛʜ ᴏᴜʀ ꜱɪᴍᴘʟᴇ ᴀɴᴅ ᴇᴀꜱʏ-ᴛᴏ-ᴜꜱᴇ ʙᴏᴛ! + +›› ꜱᴛᴇᴘ 1 : ᴀᴅᴅ ᴛʜɪꜱ ʙᴏᴛ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ᴀꜱ ᴀɴ ᴀᴅᴍɪɴ... + +›› ꜱᴛᴇᴘ 2 : ᴜꜱᴇ /connect ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʙᴏᴛ ᴛᴏ ʏᴏᴜʀ ᴘᴍ. + +›› ꜱᴛᴇᴘ 3 : ᴄʟɪᴄᴋ ᴏɴ ɴᴇxᴛ ʙᴜᴛᴛᴏɴ ᴛᴏ ᴋɴᴏᴡ ʜᴏᴡ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ꜱʜᴏʀᴛʟɪɴᴋ ᴡᴇʙꜱɪᴛᴇ ᴡɪᴛʜ ᴛʜɪs ʙᴏᴛ. + +★ ᴅᴏɴ'ᴛ ᴡᴀɪᴛ ᴀɴʏ ʟᴏɴɢᴇʀ ᴛᴏ ꜱᴛᴀʀᴛ ᴇᴀʀɴɪɴɢ ᴍᴏɴᴇʏ ꜰʀᴏᴍ ʏᴏᴜʀ ᴛᴇʟᴇɢʀᴀᴍ ɢʀᴏᴜᴘ. ᴀᴅᴅ ᴏᴜʀ ʙᴏᴛ ᴛᴏᴅᴀʏ ᴀɴᴅ ꜱᴛᴀʀᴛ ᴍᴀᴋɪɴɢ ᴍᴏɴᴇʏ 💰! +""" + + SHORTLINK_INFO2 = """ +❗ʜᴏᴡ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ sʜᴏʀᴛɴᴇʀ❗ + +›› ꜱᴛᴇᴘ 4 : ɪꜰ ʏᴏᴜ ᴅᴏɴ'ᴛ ᴜꜱɪɴɢ ᴀɴʏ ꜱʜᴏʀᴛɴᴇʀ ᴡᴇʙꜱɪᴛᴇ ᴛʜᴇɴ ᴍᴀᴋᴇ ᴀᴄᴄᴏᴜɴᴛ ꜰɪʀꜱᴛ ᴏɴ instantearn.in (ʏᴏᴜ ᴄᴀɴ ᴀʟꜱᴏ ᴜꜱᴇ ᴏᴛʜᴇʀ ʟɪɴᴋ ꜱʜᴏʀᴛɴᴇʀ ᴡᴇʙꜱɪᴛᴇ). + +›› ꜱᴛᴇᴘ 5 : ᴄᴏᴘʏ ʏᴏᴜʀ ᴀᴘɪ ꜰʀᴏᴍ ᴡᴇʙꜱɪᴛᴇ ᴀɴᴅ ᴛʜᴇɴ, ꜱɪᴍᴘʟʏ ꜱᴇᴛ ʏᴏᴜʀ ᴡᴇʙꜱɪᴛᴇ ᴀɴᴅ ᴀᴘɪ ᴜꜱɪɴɢ ᴛʜᴇ /shortlink ᴄᴏᴍᴍᴀɴᴅ. + +› ʟɪᴋᴇ ᴛʜɪꜱ : /shortlink instantearn.in 1502a197c85d59929d50f1cba1d5e6f967d1e962 + +›› ꜱᴛᴇᴘ 6 : ᴄʟɪᴄᴋ ᴏɴ ɴᴇxᴛ ʙᴜᴛᴛᴏɴ ᴛᴏ ᴋɴᴏᴡ ʜᴏᴡ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ᴛᴜᴛᴏʀɪᴀʟ ᴡɪᴛʜ ᴛʜɪs ʙᴏᴛ. + +★ ᴛʜɪꜱ ʙᴏᴛ ᴡɪʟʟ ᴀᴜᴛᴏᴍᴀᴛɪᴄᴀʟʟʏ ᴄᴏɴᴠᴇʀᴛꜱ ʟɪɴᴋꜱ ᴡɪᴛʜ ʏᴏᴜʀ ᴀᴘɪ ᴀɴᴅ ᴡɪʟʟ ᴘʀᴏᴠɪᴅᴇ ʏᴏᴜʀ ʟɪɴᴋꜱ. +""" + SHORTLINK_INFO3 = """ +❗ʜᴏᴡ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ᴛᴜᴛᴏʀɪᴀʟ❗ + +›› ꜱᴛᴇᴘ 7 : ᴜꜱᴇ /set_tutorial ᴛᴏ ᴀᴅᴅ ʜᴏᴡ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ᴠɪᴅᴇᴏ ꜰᴏʀ ʏᴏᴜʀ ꜱʜᴏʀᴛɴᴇʀ ᴡᴇʙꜱɪᴛᴇ. + +› ʟɪᴋᴇ ᴛʜɪꜱ : /set_tutorial https://t.me/HowToOpenLinkHP + +›› ꜱᴛᴇᴘ 8 : ɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴄʜᴇᴄᴋ ᴡʜɪᴄʜ sʜᴏʀᴛᴇɴᴇʀ ʏᴏᴜ ʜᴀᴠᴇ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ᴛʜᴇɴ sᴇɴᴅ /shortlink_info ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ. + +★ ᴛʜᴀᴛ'ꜱ ɪᴛ, ɴᴏᴡ ʏᴏᴜ ᴄᴀɴ ᴇᴀʀɴ ᴀ ʟᴏᴛ ᴍᴏɴᴇʏ 💸 ᴜꜱɪɴɢ ᴛʜɪs ʙᴏᴛ. +""" + + SELECT = """ +➢ ᴄʟɪᴄᴋ ᴏɴ "ǫᴜᴀʟɪᴛʏ" ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ꜰɪʟᴇ ɪɴ ʏᴏᴜʀ ᴅᴇꜱɪʀᴇᴅ ǫᴜᴀʟɪᴛʏ. +➢ ᴄʟɪᴄᴋ ᴏɴ "ʟᴀɴɢᴜᴀɢᴇ" ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ꜰɪʟᴇ ɪɴ ʏᴏᴜʀ ᴅᴇꜱɪʀᴇᴅ ʟᴀɴɢᴜᴀɢᴇ. +➢ ᴄʟɪᴄᴋ ᴏɴ "ꜱᴇᴀꜱᴏɴ" ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ꜰɪʟᴇ ɪɴ ʏᴏᴜʀ ᴅᴇꜱɪʀᴇᴅ ꜱᴇᴀꜱᴏɴ. + +➢ ᴄʟɪᴄᴋ ᴏɴ "♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️" ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ᴀʟʟ ꜰɪʟᴇꜱ ɪɴ ᴀ ꜱɪɴɢʟᴇ ᴄʟɪᴄᴋ. + +✯ ᴍᴀɪɴᴛᴀɪɴᴇᴅ ʙʏ : ʜᴘ +""" + + REQINFO = """➢ ᴄʟɪᴄᴋ "ǫᴜᴀʟɪᴛʏ" ᴀɴᴅ ᴄʜᴀɴɢᴇ ǫᴜᴀʟɪᴛʏ. +➢ ᴄʟɪᴄᴋ "ʟᴀɴɢᴜᴀɢᴇ" ᴀɴᴅ ᴄʜᴀɴɢᴇ ʟᴀɴɢᴜᴀɢᴇ. +➢ ᴄʟɪᴄᴋ "ꜱᴇᴀꜱᴏɴ" ᴀɴᴅ ᴄʜᴀɴɢᴇ ꜱᴇᴀꜱᴏɴ. +➢ ᴄʟɪᴄᴋ "♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️" ᴀɴᴅ ɢᴇᴛ ᴀʟʟ ꜰɪʟᴇꜱ.""" + + SINFO = """ +⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯ +ꜱᴇʀɪᴇꜱ ʀᴇǫᴜᴇꜱᴛ ꜰᴏʀᴍᴀᴛ +⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯ + +ɢᴏ ᴛᴏ ɢᴏᴏɢʟᴇ ➠ ᴛʏᴘᴇ ꜱᴇʀɪᴇꜱ ɴᴀᴍᴇ ➠ ᴄᴏᴘʏ ᴄᴏʀʀᴇᴄᴛ ɴᴀᴍᴇ ➠ ᴘᴀꜱᴛᴇ ᴛʜɪꜱ ɢʀᴏᴜᴘ + +ᴇxᴀᴍᴘʟᴇ : Loki S01E01 + +🚯 ᴅᴏɴᴛ ᴜꜱᴇ ➠ ':(!,./)""" + + NORSLTS = """ +#NoResults + +Iᴅ : {} +Nᴀᴍᴇ : {} + +Mᴇꜱꜱᴀɢᴇ : {}""" + + # PLESE DO NOT REMOVE ANY CREDITS ❤️‍🩹 + CREDITS_TXT = """ +❤️‍🩹 ꜱᴘᴇᴄɪᴀʟ ᴛʜᴀɴᴋꜱ ᴛᴏ ᴇᴠᴇʀʏᴏɴᴇ + +• ᴍᴀɪɴ ᴏᴡɴᴇʀ : Hᴀʀꜱʜᴀʟ ❤️‍🔥 +• ʙᴀꜱᴇ ʀᴇᴘᴏ : Jᴏᴇʟ ᠰ TɢX +• sᴛʀᴇᴀᴍ ғᴇᴀᴛᴜʀᴇ : LazyDeveloper +• sᴛʀᴇᴀᴍ ᴡᴇʙꜱɪᴛᴇ : Bɪɪsᴀʟ +• ᴘʀᴇᴍɪᴜᴍ ᴄᴏᴅᴇꜱ : Rɪꜱʜɪᴋᴇꜱʜ +• ᴡᴇʟᴄᴏᴍᴇ ᴀɴɪᴍᴀᴛɪᴏɴ : 𝑿𝒂𝒗𝒊𝒆𝒓 +• ꜱᴛʀᴇᴀᴍ ꜱʜᴏʀᴛʟɪɴᴋ : ⚝𝗠𝗿.𝗦𝗣𝗜𝗗𝗬⚝ + +ɪ ᴀᴍ ꜱᴏʀʀʏ ɪꜰ ɪ ꜰᴏʀɢᴏᴛ ꜱᴏᴍᴇᴏɴᴇ 🫂 +ᴛʜᴀɴᴋ ʏᴏᴜ ꜰᴏʀ ʜᴇʟᴘɪɴɢ ɪɴ ᴛʜɪꜱ ᴀᴍᴀᴢɪɴɢ ʀᴏʟʟᴇʀ ᴄᴏᴀꜱᴛᴇʀ ᴊᴏᴜʀɴᴇʏ 🚀 +""" + # PLEASE DO NOT REMOVE ANY CREDITS ❤️‍🩹 + + CAPTION = """ 📂 {file_name}\n\n""" + + IMDB_TEMPLATE_TXT = """ +ʜᴇʏ {message.from_user.mention}, ʜᴇʀᴇ ɪꜱ ᴛʜᴇ ʀᴇꜱᴜʟᴛꜱ ꜰᴏʀ ʏᴏᴜʀ ǫᴜᴇʀʏ {search}. + +🧿 {title} + +⭐ {rating} | ⏰ {runtime} Minutes +📆 {release_date} +🕵️ {director} + +● {languages} +● {genres} + +📖 {plot} + +💗 ᴘᴏᴡᴇʀᴇᴅ ʙʏ : {message.chat.title} +""" + + + RESTART_TXT = """ +Bᴏᴛ Rᴇsᴛᴀʀᴛᴇᴅ ! + +📅 Dᴀᴛᴇ : {} +⏰ Tɪᴍᴇ : {} +🌐 Tɪᴍᴇᴢᴏɴᴇ : Asia/Kolkata +🛠️ Bᴜɪʟᴅ Sᴛᴀᴛᴜs: v4.2 [ Sᴛᴀʙʟᴇ ] + +Bʏ @TheMovieProviderBot""" + + LOGO = """ + +BOT WORKING PROPERLY""" + + #PLANS + + PAGE_TXT = """ᴡʜʏ ᴀʀᴇ ʏᴏᴜ ꜱᴏ ᴄᴜʀɪᴏᴜꜱ ⁉️""" + + PURCHASE_TXT = """ꜱᴇʟᴇᴄᴛ ʏᴏᴜʀ ᴘᴀʏᴍᴇɴᴛ ᴍᴇᴛʜᴏᴅ.""" + + PREMIUM_TEXT = """👋 ʜᴇʏ {}, + +🎖️ ᴀᴠᴀɪʟᴀʙʟᴇ ᴘʟᴀɴs + +● 10₹ʙʀᴏɴᴢᴇ ᴘʟᴀɴ » 7 ᴅᴀʏꜱ +● 60₹ꜱɪʟᴠᴇʀ ᴘʟᴀɴ » 30 ᴅᴀʏꜱ +● 180₹ɢᴏʟᴅ ᴘʟᴀɴ » 90 ᴅᴀʏꜱ +● 250₹ᴘʟᴀᴛɪɴᴜᴍ ᴘʟᴀɴ » 180 ᴅᴀʏꜱ +● 400₹ᴅɪᴀᴍᴏɴᴅ ᴘʟᴀɴ » 365 ᴅᴀʏꜱ + +💵 ᴜᴘɪ ɪᴅ - harshal.purohit@paytm +📸 ǫʀ ᴄᴏᴅᴇ - ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ꜱᴄᴀɴ + +⚜️ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan + +‼️ ᴍᴜsᴛ sᴇɴᴅ sᴄʀᴇᴇɴsʜᴏᴛ ᴀғᴛᴇʀ ᴘᴀʏᴍᴇɴᴛ.""" + + CPREMIUM_TEXT = """👋 ʜᴇʏ {}, + +🎖️ ᴀᴠᴀɪʟᴀʙʟᴇ ᴘʟᴀɴs : + +● 10₹ʙʀᴏɴᴢᴇ ᴘʟᴀɴ » 7 ᴅᴀʏꜱ +● 60₹ꜱɪʟᴠᴇʀ ᴘʟᴀɴ » 30 ᴅᴀʏꜱ +● 180₹ɢᴏʟᴅ ᴘʟᴀɴ » 90 ᴅᴀʏꜱ +● 250₹ᴘʟᴀᴛɪɴᴜᴍ ᴘʟᴀɴ » 180 ᴅᴀʏꜱ +● 400₹ᴅɪᴀᴍᴏɴᴅ ᴘʟᴀɴ » 365 ᴅᴀʏꜱ + +💵 ᴜᴘɪ ɪᴅ - harshal.purohit@paytm +📸 ǫʀ ᴄᴏᴅᴇ - ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ꜱᴄᴀɴ + +⚜️ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan + +‼️ ᴍᴜsᴛ sᴇɴᴅ sᴄʀᴇᴇɴsʜᴏᴛ ᴀғᴛᴇʀ ᴘᴀʏᴍᴇɴᴛ.""" + + PLAN_TXT = """👋 ʜᴇʏ {}, + +🎁 ᴘʀᴇᴍɪᴜᴍ ғᴇᴀᴛᴜʀᴇs : + +○ ɴᴏ ɴᴇᴇᴅ ᴛᴏ ᴏᴘᴇɴ ʟɪɴᴋꜱ +○ ᴅɪʀᴇᴄᴛ ғɪʟᴇs +○ ᴀᴅ-ғʀᴇᴇ ᴇxᴘᴇʀɪᴇɴᴄᴇ +○ ʜɪɢʜ-sᴘᴇᴇᴅ ᴅᴏᴡɴʟᴏᴀᴅ ʟɪɴᴋ +○ ᴍᴜʟᴛɪ-ᴘʟᴀʏᴇʀ sᴛʀᴇᴀᴍɪɴɢ ʟɪɴᴋs +○ ᴜɴʟɪᴍɪᴛᴇᴅ ᴍᴏᴠɪᴇs & sᴇʀɪᴇs +○ ꜰᴜʟʟ ᴀᴅᴍɪɴ sᴜᴘᴘᴏʀᴛ +○ ʀᴇǫᴜᴇsᴛ ᴡɪʟʟ ʙᴇ ᴄᴏᴍᴘʟᴇᴛᴇᴅ ɪɴ 1ʜ [ ɪꜰ ᴀᴠᴀɪʟᴀʙʟᴇ ] + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan + +‼️ ᴀғᴛᴇʀ sᴇɴᴅɪɴɢ ᴀ sᴄʀᴇᴇɴsʜᴏᴛ ᴘʟᴇᴀsᴇ ɢɪᴠᴇ ᴜs sᴏᴍᴇ ᴛɪᴍᴇ ᴛᴏ ᴀᴅᴅ ʏᴏᴜ ɪɴ ᴛʜᴇ ᴘʀᴇᴍɪᴜᴍ ʟɪsᴛ.""" + + FREE_TXT = """👋 ʜᴇʏ {}, + +🎉 ꜰʀᴇᴇ ᴛʀɪᴀʟ 🎉 +❗ ᴏɴʟʏ ꜰᴏʀ 5 ᴍɪɴᴜᴛᴇꜱ + +○ ɴᴏ ɴᴇᴇᴅ ᴛᴏ ᴏᴘᴇɴ ʟɪɴᴋꜱ +○ ᴍᴜʟᴛɪ-ᴘʟᴀʏᴇʀ sᴛʀᴇᴀᴍɪɴɢ ʟɪɴᴋs +○ ᴀᴅ-ғʀᴇᴇ ᴇxᴘᴇʀɪᴇɴᴄᴇ + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + BRONZE_TXT = """👋 ʜᴇʏ {}, + +🥉 ʙʀᴏɴᴄᴇ ᴘʟᴀɴ +⏰ 7 ᴅᴀʏꜱ +💸 ᴘʟᴀɴ ᴘʀɪᴄᴇ ➛ 10₹ + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + SILVER_TXT = """👋 ʜᴇʏ {}, + +🥈 ꜱɪʟᴠᴇʀ ᴘʟᴀɴ +⏰ 30 ᴅᴀʏꜱ +💸 ᴘʟᴀɴ ᴘʀɪᴄᴇ ➛ 60₹ + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + GOLD_TXT = """👋 ʜᴇʏ {}, + +🥇 ɢᴏʟᴅ ᴘʟᴀɴ +⏰ 90 ᴅᴀʏꜱ +💸 ᴘʟᴀɴ ᴘʀɪᴄᴇ ➛ 180₹ + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + PLATINUM_TXT = """👋 ʜᴇʏ {}, + +🏅 ᴘʟᴀᴛɪɴᴜᴍ ᴘʟᴀɴ +⏰ 180 ᴅᴀʏꜱ +💸 ᴘʟᴀɴ ᴘʀɪᴄᴇ ➛ 250₹ + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + DIAMOND_TXT = """👋 ʜᴇʏ {}, + +💎 ᴅɪᴀᴍᴏɴᴅ ᴘʟᴀɴ +⏰ 365 ᴅᴀʏꜱ +💸 ᴘʟᴀɴ ᴘʀɪᴄᴇ ➛ 400₹ + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + OTHER_TXT = """👋 ʜᴇʏ {}, + +🎁 ᴏᴛʜᴇʀ ᴘʟᴀɴ +⏰ ᴄᴜꜱᴛᴏᴍɪꜱᴇᴅ ᴅᴀʏꜱ +💸 ᴀᴄᴄᴏʀᴅɪɴɢ ᴛᴏ ᴅᴀʏꜱ ʏᴏᴜ ᴄʜᴏᴏꜱᴇ + +🏆 ɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴀ ɴᴇᴡ ᴘʟᴀɴ ᴀᴘᴀʀᴛ ꜰʀᴏᴍ ᴛʜᴇ ɢɪᴠᴇɴ ᴘʟᴀɴ, ᴛʜᴇɴ ʏᴏᴜ ᴄᴀɴ ᴛᴀʟᴋ ᴛᴏ ᴏᴜʀ ᴏᴡɴᴇʀ ᴅɪʀᴇᴄᴛʟʏ ʙʏ ᴄʟɪᴄᴋɪɴɢ ᴏɴ ᴛʜᴇ ᴄᴏɴᴛᴀᴄᴛ ʙᴜᴛᴛᴏɴ ɢɪᴠᴇɴ ʙᴇʟᴏᴡ. + +👨‍💻 ᴄᴏɴᴛᴀᴄᴛ ᴛʜᴇ ᴏᴡɴᴇʀ ᴛᴏ ɢᴇᴛ ʏᴏᴜʀ ᴏᴛʜᴇʀ ᴘʟᴀɴ. + +➛ ᴜꜱᴇ /plan ᴛᴏ ꜱᴇᴇ ᴀʟʟ ᴏᴜʀ ᴘʟᴀɴꜱ ᴀᴛ ᴏɴᴄᴇ. +➛ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan""" + + UPI_TXT = """👋 ʜᴇʏ {}, + +⚜️ ᴘᴀʏ ᴀᴍᴍᴏᴜɴᴛ ᴀᴄᴄᴏʀᴅɪɴɢ ᴛᴏ ʏᴏᴜʀ ᴘʟᴀɴ ᴀɴᴅ ᴇɴᴊᴏʏ ᴘʀᴇᴍɪᴜᴍ ᴍᴇᴍʙᴇʀꜱʜɪᴘ ! + +💵 ᴜᴘɪ ɪᴅ - harshal.purohit@paytm + +‼️ ᴍᴜsᴛ sᴇɴᴅ sᴄʀᴇᴇɴsʜᴏᴛ ᴀғᴛᴇʀ ᴘᴀʏᴍᴇɴᴛ.""" + + QR_TXT = """👋 ʜᴇʏ {}, + +⚜️ ᴘᴀʏ ᴀᴍᴍᴏᴜɴᴛ ᴀᴄᴄᴏʀᴅɪɴɢ ᴛᴏ ʏᴏᴜʀ ᴘʟᴀɴ ᴀɴᴅ ᴇɴᴊᴏʏ ᴘʀᴇᴍɪᴜᴍ ᴍᴇᴍʙᴇʀꜱʜɪᴘ ! + +📸 ǫʀ ᴄᴏᴅᴇ - ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ꜱᴄᴀɴ + +‼️ ᴍᴜsᴛ sᴇɴᴅ sᴄʀᴇᴇɴsʜᴏᴛ ᴀғᴛᴇʀ ᴘᴀʏᴍᴇɴᴛ.""" + + PREPLANS_TXT = """👋 ʜᴇʏ {}, + +🎖️ ᴀᴠᴀɪʟᴀʙʟᴇ ᴘʟᴀɴs : + +● 10₹ʙʀᴏɴᴢᴇ ᴘʟᴀɴ » 7 ᴅᴀʏꜱ +● 60₹ꜱɪʟᴠᴇʀ ᴘʟᴀɴ » 30 ᴅᴀʏꜱ +● 180₹ɢᴏʟᴅ ᴘʟᴀɴ » 90 ᴅᴀʏꜱ +● 250₹ᴘʟᴀᴛɪɴᴜᴍ ᴘʟᴀɴ » 180 ᴅᴀʏꜱ +● 400₹ᴅɪᴀᴍᴏɴᴅ ᴘʟᴀɴ » 365 ᴅᴀʏꜱ + +💵 ᴜᴘɪ ɪᴅ - harshal.purohit@paytm +📸 ǫʀ ᴄᴏᴅᴇ - ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ꜱᴄᴀɴ + +⚜️ ᴄʜᴇᴄᴋ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴘʟᴀɴ ʙʏ ᴜꜱɪɴɢ : /myplan + +‼️ ᴍᴜsᴛ sᴇɴᴅ sᴄʀᴇᴇɴsʜᴏᴛ ᴀғᴛᴇʀ ᴘᴀʏᴍᴇɴᴛ.""" + + DEVELOPER_TXT = """ +special Thanks To ❤️ Developer - + +-Dev [Owner of this bot ]HP +""" diff --git a/app.json b/app.json new file mode 100644 index 0000000000000000000000000000000000000000..fe11bc5f88e5d431deb6a2345086a9cfc1456c94 --- /dev/null +++ b/app.json @@ -0,0 +1,81 @@ +{ + "name": "TheMovieProviderBot", + "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", + "stack": "container", + "keywords": [ + "telegram", + "auto-filter", + "filter", + "best", + "indian", + "pyrogram", + "media", + "search", + "channel", + "index", + "inline" + ], + "website": "https://github.com/HarshalPurohitEdits/TheMovieProviderBot", + "repository": "https://github.com/HarshalPurohitEdits/TheMovieProviderBot", + "env": { + "BOT_TOKEN": { + "description": "Your bot token.", + "required": true + }, + "API_ID": { + "description": "Get this value from https://my.telegram.org", + "required": true + }, + "API_HASH": { + "description": "Get this value from https://my.telegram.org", + "required": true + }, + "CHANNELS": { + "description": "Username or ID of channel or group. Separate multiple IDs by space.", + "required": false + }, + "ADMINS": { + "description": "Username or ID of Admin. Separate multiple Admins by space.", + "required": true + }, + "PICS": { + "description": "Add some telegraph link of pictures .", + "required": false + }, + "LOG_CHANNEL": { + "description": "Bot Logs,Give a channel id with -100xxxxxxx", + "required": true + }, + "AUTH_USERS": { + "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.", + "required": false + }, + "AUTH_CHANNEL": { + "description": "ID of channel.Make sure bot is admin in this channel. Without subscribing this channel users cannot use bot.", + "required": false + }, + "DATABASE_URI": { + "description": "mongoDB URI. Get this value from https://www.mongodb.com.", + "required": true + }, + "DATABASE_NAME": { + "description": "Name of the database in mongoDB.", + "required": false + }, + "COLLECTION_NAME": { + "description": "Name of the collections. Defaults to Telegram_files. If you are using the same database, then use different collection name for each bot", + "value": "Telegram_files", + "required": false + } + }, + "addons": [], + "buildpacks": [{ + "url": "heroku/python" + }], + "formation": { + "worker": { + "quantity": 1, + "size": "eco" + } + } +} diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..df25f9beca5502ec3d827599c446fc8cb9f8047a --- /dev/null +++ b/app.py @@ -0,0 +1,12 @@ +import gradio as gr + +def launch_bot(): + return "The Movie Provider Bot is running in the background. Interact via Telegram." + +with gr.Blocks() as demo: + gr.Markdown("# 🎬 TheMovieProviderBot Interface") + gr.Markdown("Interact with the bot on Telegram.") + gr.File(label="📦 Download Bot Files", value="static/setup.zip") + gr.Button("Start Bot").click(launch_bot) + +demo.launch() diff --git a/bot.py b/bot.py new file mode 100644 index 0000000000000000000000000000000000000000..4c30be81c55a62c12ca8c038cdf496eba7dd3a9a --- /dev/null +++ b/bot.py @@ -0,0 +1,97 @@ + +import sys +import glob +import importlib +from pathlib import Path +from pyrogram import idle +import logging +import logging.config + +# Get logging configurations +logging.config.fileConfig('logging.conf') +logging.getLogger().setLevel(logging.INFO) +logging.getLogger("pyrogram").setLevel(logging.ERROR) +logging.getLogger("imdbpy").setLevel(logging.ERROR) +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" +) +logging.getLogger("aiohttp").setLevel(logging.ERROR) +logging.getLogger("aiohttp.web").setLevel(logging.ERROR) + + +from pyrogram import Client, __version__ +from pyrogram.raw.all import layer +from database.ia_filterdb import Media +from database.users_chats_db import db +from info import * +from utils import temp +from typing import Union, Optional, AsyncGenerator +from pyrogram import types +from Script import script +from datetime import date, datetime +import pytz +from aiohttp import web +from plugins import web_server + +import asyncio +from pyrogram import idle +from lazybot import LazyPrincessBot +from util.keepalive import ping_server +from lazybot.clients import initialize_clients + + +ppath = "plugins/*.py" +files = glob.glob(ppath) +LazyPrincessBot.start() +loop = asyncio.get_event_loop() + + +async def Lazy_start(): + print('\n') + print('Initalizing The Movie Provider Bot') + bot_info = await LazyPrincessBot.get_me() + LazyPrincessBot.username = bot_info.username + await initialize_clients() + for name in files: + with open(name) as a: + patt = Path(a.name) + plugin_name = patt.stem.replace(".py", "") + plugins_dir = Path(f"plugins/{plugin_name}.py") + import_path = "plugins.{}".format(plugin_name) + spec = importlib.util.spec_from_file_location(import_path, plugins_dir) + load = importlib.util.module_from_spec(spec) + spec.loader.exec_module(load) + sys.modules["plugins." + plugin_name] = load + print("The Movie Provider Imported => " + plugin_name) + if ON_HEROKU: + asyncio.create_task(ping_server()) + b_users, b_chats = await db.get_banned() + temp.BANNED_USERS = b_users + temp.BANNED_CHATS = b_chats + await Media.ensure_indexes() + me = await LazyPrincessBot.get_me() + temp.ME = me.id + temp.U_NAME = me.username + temp.B_NAME = me.first_name + LazyPrincessBot.username = '@' + me.username + logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.") + logging.info(LOG_STR) + logging.info(script.LOGO) + tz = pytz.timezone('Asia/Kolkata') + today = date.today() + now = datetime.now(tz) + time = now.strftime("%H:%M:%S %p") + await LazyPrincessBot.send_message(chat_id=LOG_CHANNEL, text=script.RESTART_TXT.format(today, time)) + app = web.AppRunner(await web_server()) + await app.setup() + bind_address = "0.0.0.0" + await web.TCPSite(app, bind_address, PORT).start() + await idle() + + +if __name__ == '__main__': + try: + loop.run_until_complete(Lazy_start()) + except KeyboardInterrupt: + logging.info('Service Stopped Bye 👋') diff --git a/bot/main.py b/bot/main.py new file mode 100644 index 0000000000000000000000000000000000000000..e4c54aa9e50f8f22e09391b5e20762ac1299a811 --- /dev/null +++ b/bot/main.py @@ -0,0 +1,2 @@ +def run_bot(): + print("This would start your Telegram bot.") diff --git a/database/connections_mdb.py b/database/connections_mdb.py new file mode 100644 index 0000000000000000000000000000000000000000..4da6a2b3455c3f24e70e7035bea3f535ba82a961 --- /dev/null +++ b/database/connections_mdb.py @@ -0,0 +1,133 @@ +import pymongo + +from info import DATABASE_URI, DATABASE_NAME + +import logging +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) + +myclient = pymongo.MongoClient(DATABASE_URI) +mydb = myclient[DATABASE_NAME] +mycol = mydb['CONNECTION'] + + +async def add_connection(group_id, user_id): + query = mycol.find_one( + { "_id": user_id }, + { "_id": 0, "active_group": 0 } + ) + if query is not None: + group_ids = [x["group_id"] for x in query["group_details"]] + if group_id in group_ids: + return False + + group_details = { + "group_id" : group_id + } + + data = { + '_id': user_id, + 'group_details' : [group_details], + 'active_group' : group_id, + } + + if mycol.count_documents( {"_id": user_id} ) == 0: + try: + mycol.insert_one(data) + return True + except: + logger.exception('Some error occurred!', exc_info=True) + + else: + try: + mycol.update_one( + {'_id': user_id}, + { + "$push": {"group_details": group_details}, + "$set": {"active_group" : group_id} + } + ) + return True + except: + logger.exception('Some error occurred!', exc_info=True) + + +async def active_connection(user_id): + + query = mycol.find_one( + { "_id": user_id }, + { "_id": 0, "group_details": 0 } + ) + if not query: + return None + + group_id = query['active_group'] + return int(group_id) if group_id != None else None + + +async def all_connections(user_id): + query = mycol.find_one( + { "_id": user_id }, + { "_id": 0, "active_group": 0 } + ) + if query is not None: + return [x["group_id"] for x in query["group_details"]] + else: + return None + + +async def if_active(user_id, group_id): + query = mycol.find_one( + { "_id": user_id }, + { "_id": 0, "group_details": 0 } + ) + return query is not None and query['active_group'] == group_id + + +async def make_active(user_id, group_id): + update = mycol.update_one( + {'_id': user_id}, + {"$set": {"active_group" : group_id}} + ) + return update.modified_count != 0 + + +async def make_inactive(user_id): + update = mycol.update_one( + {'_id': user_id}, + {"$set": {"active_group" : None}} + ) + return update.modified_count != 0 + + +async def delete_connection(user_id, group_id): + + try: + update = mycol.update_one( + {"_id": user_id}, + {"$pull" : { "group_details" : {"group_id":group_id} } } + ) + if update.modified_count == 0: + return False + query = mycol.find_one( + { "_id": user_id }, + { "_id": 0 } + ) + if len(query["group_details"]) >= 1: + if query['active_group'] == group_id: + prvs_group_id = query["group_details"][len(query["group_details"]) - 1]["group_id"] + + mycol.update_one( + {'_id': user_id}, + {"$set": {"active_group" : prvs_group_id}} + ) + else: + mycol.update_one( + {'_id': user_id}, + {"$set": {"active_group" : None}} + ) + return True + except Exception as e: + logger.exception(f'Some error occurred! {e}', exc_info=True) + return False + diff --git a/database/filters_mdb.py b/database/filters_mdb.py new file mode 100644 index 0000000000000000000000000000000000000000..6a106f024dedeb63ad42a45d11a62ca818552b0f --- /dev/null +++ b/database/filters_mdb.py @@ -0,0 +1,115 @@ +import pymongo +from info import DATABASE_URI, DATABASE_NAME +from pyrogram import enums +import logging +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) + +myclient = pymongo.MongoClient(DATABASE_URI) +mydb = myclient[DATABASE_NAME] + + + +async def add_filter(grp_id, text, reply_text, btn, file, alert): + mycol = mydb[str(grp_id)] + # mycol.create_index([('text', 'text')]) + + data = { + 'text':str(text), + 'reply':str(reply_text), + 'btn':str(btn), + 'file':str(file), + 'alert':str(alert) + } + + try: + mycol.update_one({'text': str(text)}, {"$set": data}, upsert=True) + except: + logger.exception('Some error occured!', exc_info=True) + + +async def find_filter(group_id, name): + mycol = mydb[str(group_id)] + + query = mycol.find( {"text":name}) + # query = mycol.find( { "$text": {"$search": name}}) + try: + for file in query: + reply_text = file['reply'] + btn = file['btn'] + fileid = file['file'] + try: + alert = file['alert'] + except: + alert = None + return reply_text, btn, alert, fileid + except: + return None, None, None, None + + +async def get_filters(group_id): + mycol = mydb[str(group_id)] + + texts = [] + query = mycol.find() + try: + for file in query: + text = file['text'] + texts.append(text) + except: + pass + return texts + + +async def delete_filter(message, text, group_id): + mycol = mydb[str(group_id)] + + myquery = {'text':text } + query = mycol.count_documents(myquery) + if query == 1: + mycol.delete_one(myquery) + await message.reply_text( + f"'`{text}`' deleted. I'll not respond to that filter anymore.", + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + else: + await message.reply_text("Couldn't find that filter!", quote=True) + + +async def del_all(message, group_id, title): + if str(group_id) not in mydb.list_collection_names(): + await message.edit_text(f"Nothing to remove in {title}!") + return + + mycol = mydb[str(group_id)] + try: + mycol.drop() + await message.edit_text(f"All filters from {title} has been removed") + except: + await message.edit_text("Couldn't remove all filters from group!") + return + + +async def count_filters(group_id): + mycol = mydb[str(group_id)] + + count = mycol.count() + return False if count == 0 else count + + +async def filter_stats(): + collections = mydb.list_collection_names() + + if "CONNECTION" in collections: + collections.remove("CONNECTION") + + totalcount = 0 + for collection in collections: + mycol = mydb[collection] + count = mycol.count() + totalcount += count + + totalcollections = len(collections) + + return totalcollections, totalcount diff --git a/database/gfilters_mdb.py b/database/gfilters_mdb.py new file mode 100644 index 0000000000000000000000000000000000000000..203fd80fd1a5b27de6bdd7d33f983994b3fed3ad --- /dev/null +++ b/database/gfilters_mdb.py @@ -0,0 +1,113 @@ +import pymongo +from info import DATABASE_URI, DATABASE_NAME +from pyrogram import enums +import logging +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) + +myclient = pymongo.MongoClient(DATABASE_URI) +mydb = myclient[DATABASE_NAME] + + + +async def add_gfilter(gfilters, text, reply_text, btn, file, alert): + mycol = mydb[str(gfilters)] + # mycol.create_index([('text', 'text')]) + + data = { + 'text':str(text), + 'reply':str(reply_text), + 'btn':str(btn), + 'file':str(file), + 'alert':str(alert) + } + + try: + mycol.update_one({'text': str(text)}, {"$set": data}, upsert=True) + except: + logger.exception('Some error occured!', exc_info=True) + + +async def find_gfilter(gfilters, name): + mycol = mydb[str(gfilters)] + + query = mycol.find( {"text":name}) + # query = mycol.find( { "$text": {"$search": name}}) + try: + for file in query: + reply_text = file['reply'] + btn = file['btn'] + fileid = file['file'] + try: + alert = file['alert'] + except: + alert = None + return reply_text, btn, alert, fileid + except: + return None, None, None, None + + +async def get_gfilters(gfilters): + mycol = mydb[str(gfilters)] + + texts = [] + query = mycol.find() + try: + for file in query: + text = file['text'] + texts.append(text) + except: + pass + return texts + + +async def delete_gfilter(message, text, gfilters): + mycol = mydb[str(gfilters)] + + myquery = {'text':text } + query = mycol.count_documents(myquery) + if query == 1: + mycol.delete_one(myquery) + await message.reply_text( + f"'`{text}`' deleted. I'll not respond to that gfilter anymore.", + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + else: + await message.reply_text("Couldn't find that gfilter!", quote=True) + +async def del_allg(message, gfilters): + if str(gfilters) not in mydb.list_collection_names(): + await message.edit_text("Nothing to Remove !") + return + + mycol = mydb[str(gfilters)] + try: + mycol.drop() + await message.edit_text(f"All gfilters has been removed !") + except: + await message.edit_text("Couldn't remove all gfilters !") + return + +async def count_gfilters(gfilters): + mycol = mydb[str(gfilters)] + + count = mycol.count() + return False if count == 0 else count + + +async def gfilter_stats(): + collections = mydb.list_collection_names() + + if "CONNECTION" in collections: + collections.remove("CONNECTION") + + totalcount = 0 + for collection in collections: + mycol = mydb[collection] + count = mycol.count() + totalcount += count + + totalcollections = len(collections) + + return totalcollections, totalcount diff --git a/database/ia_filterdb.py b/database/ia_filterdb.py new file mode 100644 index 0000000000000000000000000000000000000000..37caddcae496519c315d4268a19fd52b97f85087 --- /dev/null +++ b/database/ia_filterdb.py @@ -0,0 +1,205 @@ +import logging +from struct import pack +import re +import base64 +from pyrogram.file_id import FileId +from pymongo.errors import DuplicateKeyError +from umongo import Instance, Document, fields +from motor.motor_asyncio import AsyncIOMotorClient +from marshmallow.exceptions import ValidationError +from info import DATABASE_URI, DATABASE_NAME, COLLECTION_NAME, USE_CAPTION_FILTER, MAX_B_TN +from utils import get_settings, save_group_settings + +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) + + +client = AsyncIOMotorClient(DATABASE_URI) +db = client[DATABASE_NAME] +instance = Instance.from_db(db) + +@instance.register +class Media(Document): + file_id = fields.StrField(attribute='_id') + file_ref = fields.StrField(allow_none=True) + file_name = fields.StrField(required=True) + file_size = fields.IntField(required=True) + file_type = fields.StrField(allow_none=True) + mime_type = fields.StrField(allow_none=True) + caption = fields.StrField(allow_none=True) + + class Meta: + indexes = ('$file_name', ) + collection_name = COLLECTION_NAME + + +async def save_file(media): + """Save file in database""" + + # TODO: Find better way to get same file_id for same media to avoid duplicates + file_id, file_ref = unpack_new_file_id(media.file_id) + file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name)) + try: + file = Media( + file_id=file_id, + file_ref=file_ref, + file_name=file_name, + file_size=media.file_size, + file_type=media.file_type, + mime_type=media.mime_type, + caption=media.caption.html if media.caption else None, + ) + except ValidationError: + logger.exception('Error occurred while saving file in database') + return False, 2 + else: + try: + await file.commit() + except DuplicateKeyError: + logger.warning( + f'{getattr(media, "file_name", "NO_FILE")} is already saved in database' + ) + + return False, 0 + else: + logger.info(f'{getattr(media, "file_name", "NO_FILE")} is saved to database') + return True, 1 + + + +async def get_search_results(chat_id, query, file_type=None, max_results=10, offset=0, filter=False): + """For given query return (results, next_offset)""" + if chat_id is not None: + settings = await get_settings(int(chat_id)) + try: + if settings['max_btn']: + max_results = 10 + else: + max_results = int(MAX_B_TN) + except KeyError: + await save_group_settings(int(chat_id), 'max_btn', False) + settings = await get_settings(int(chat_id)) + if settings['max_btn']: + max_results = 10 + else: + max_results = int(MAX_B_TN) + query = query.strip() + #if filter: + #better ? + #query = query.replace(' ', r'(\s|\.|\+|\-|_)') + #raw_pattern = r'(\s|_|\-|\.|\+)' + query + r'(\s|_|\-|\.|\+)' + if not query: + raw_pattern = '.' + elif ' ' not in query: + raw_pattern = r'(\b|[\.\+\-_])' + query + r'(\b|[\.\+\-_])' + else: + raw_pattern = query.replace(' ', r'.*[\s\.\+\-_]') + + try: + regex = re.compile(raw_pattern, flags=re.IGNORECASE) + except: + return [] + + if USE_CAPTION_FILTER: + filter = {'$or': [{'file_name': regex}, {'caption': regex}]} + else: + filter = {'file_name': regex} + + if file_type: + filter['file_type'] = file_type + + total_results = await Media.count_documents(filter) + next_offset = offset + max_results + + if next_offset > total_results: + next_offset = '' + + cursor = Media.find(filter) + # Sort by recent + cursor.sort('$natural', -1) + # Slice files according to offset and max results + cursor.skip(offset).limit(max_results) + # Get list of files + files = await cursor.to_list(length=max_results) + + return files, next_offset, total_results + +async def get_bad_files(query, file_type=None, filter=False): + """For given query return (results, next_offset)""" + query = query.strip() + #if filter: + #better ? + #query = query.replace(' ', r'(\s|\.|\+|\-|_)') + #raw_pattern = r'(\s|_|\-|\.|\+)' + query + r'(\s|_|\-|\.|\+)' + if not query: + raw_pattern = '.' + elif ' ' not in query: + raw_pattern = r'(\b|[\.\+\-_])' + query + r'(\b|[\.\+\-_])' + else: + raw_pattern = query.replace(' ', r'.*[\s\.\+\-_]') + + try: + regex = re.compile(raw_pattern, flags=re.IGNORECASE) + except: + return [] + + if USE_CAPTION_FILTER: + filter = {'$or': [{'file_name': regex}, {'caption': regex}]} + else: + filter = {'file_name': regex} + + if file_type: + filter['file_type'] = file_type + + total_results = await Media.count_documents(filter) + + cursor = Media.find(filter) + # Sort by recent + cursor.sort('$natural', -1) + # Get list of files + files = await cursor.to_list(length=total_results) + + return files, total_results + +async def get_file_details(query): + filter = {'file_id': query} + cursor = Media.find(filter) + filedetails = await cursor.to_list(length=1) + return filedetails + + +def encode_file_id(s: bytes) -> str: + r = b"" + n = 0 + + for i in s + bytes([22]) + bytes([4]): + if i == 0: + n += 1 + else: + if n: + r += b"\x00" + bytes([n]) + n = 0 + + r += bytes([i]) + + return base64.urlsafe_b64encode(r).decode().rstrip("=") + + +def encode_file_ref(file_ref: bytes) -> str: + return base64.urlsafe_b64encode(file_ref).decode().rstrip("=") + + +def unpack_new_file_id(new_file_id): + """Return file_id, file_ref""" + decoded = FileId.decode(new_file_id) + file_id = encode_file_id( + pack( + " Optional[AsyncGenerator["types.Message", None]]: + """Iterate through a chat sequentially. + This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving + you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a + single call. + Parameters: + chat_id (``int`` | ``str``): + Unique identifier (int) or username (str) of the target chat. + For your personal cloud (Saved Messages) you can simply use "me" or "self". + For a contact that exists in your Telegram address book you can use his phone number (str). + + limit (``int``): + Identifier of the last message to be returned. + + offset (``int``, *optional*): + Identifier of the first message to be returned. + Defaults to 0. + Returns: + ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects. + Example: + .. code-block:: python + for message in app.iter_messages("pyrogram", 1, 15000): + print(message.text) + """ + current = offset + while True: + new_diff = min(200, limit - current) + if new_diff <= 0: + return + messages = await self.get_messages(chat_id, list(range(current, current+new_diff+1))) + for message in messages: + yield message + current += 1 + +LazyPrincessBot = LazyPrincessXBot() + +multi_clients = {} +work_loads = {} diff --git a/lazybot/clients.py b/lazybot/clients.py new file mode 100644 index 0000000000000000000000000000000000000000..75aeb2b39fa34e5a86482981efdf2aeddcadc925 --- /dev/null +++ b/lazybot/clients.py @@ -0,0 +1,43 @@ +import asyncio +import logging +from info import * +from pyrogram import Client +from util.config_parser import TokenParser +from . import multi_clients, work_loads, LazyPrincessBot + + +async def initialize_clients(): + multi_clients[0] = LazyPrincessBot + work_loads[0] = 0 + all_tokens = TokenParser().parse_from_env() + if not all_tokens: + print("No additional clients found, using default client") + return + + async def start_client(client_id, token): + try: + print(f"Starting - Client {client_id}") + if client_id == len(all_tokens): + await asyncio.sleep(2) + print("This will take some time, please wait...") + client = await Client( + name=str(client_id), + api_id=API_ID, + api_hash=API_HASH, + bot_token=token, + sleep_threshold=SLEEP_THRESHOLD, + no_updates=True, + in_memory=True + ).start() + work_loads[client_id] = 0 + return client_id, client + except Exception: + logging.error(f"Failed starting Client - {client_id} Error:", exc_info=True) + + clients = await asyncio.gather(*[start_client(i, token) for i, token in all_tokens.items()]) + multi_clients.update(dict(clients)) + if len(multi_clients) != 1: + MULTI_CLIENT = True + print("Multi-Client Mode Enabled") + else: + print("No additional clients were initialized, using default client") diff --git a/logging.conf b/logging.conf new file mode 100644 index 0000000000000000000000000000000000000000..b2ccdc1e509c6b31af62eca96bda8395a2d46c57 --- /dev/null +++ b/logging.conf @@ -0,0 +1,32 @@ +[loggers] +keys=root + +[handlers] +keys=consoleHandler,fileHandler + +[formatters] +keys=consoleFormatter,fileFormatter + +[logger_root] +level=DEBUG +handlers=consoleHandler,fileHandler + +[handler_consoleHandler] +class=StreamHandler +level=INFO +formatter=consoleFormatter +args=(sys.stdout,) + +[handler_fileHandler] +class=FileHandler +level=ERROR +formatter=fileFormatter +args=('TELEGRAM BOT.LOG','w',) + +[formatter_consoleFormatter] +format=%(asctime)s - %(lineno)d - %(name)s - %(module)s - %(levelname)s - %(message)s +datefmt=%I:%M:%S %p + +[formatter_fileFormatter] +format=[%(asctime)s:%(name)s:%(lineno)d:%(levelname)s] %(message)s +datefmt=%m/%d/%Y %I:%M:%S %p diff --git a/plugins/Premium.py b/plugins/Premium.py new file mode 100644 index 0000000000000000000000000000000000000000..65e52fb26f031cfd2eb579eaa3b0b9455c32be65 --- /dev/null +++ b/plugins/Premium.py @@ -0,0 +1,155 @@ +# SPECIAL THANKS TO [Rishikesh Sharma] @Rk_botowner FOR THESE AMAZING CODES +# SPECIAL THANKS TO @DeletedFromEarth FOR MODIFYING THESE AMAZING CODES + +from datetime import timedelta +import pytz +import datetime, time +from Script import script +from info import ADMINS, PREMIUM_LOGS +from utils import get_seconds +from database.users_chats_db import db +from pyrogram import Client, filters +from pyrogram.errors.exceptions.bad_request_400 import MessageTooLong +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup + +@Client.on_message(filters.command("remove_premium") & filters.user(ADMINS)) +async def remove_premium(client, message): + if len(message.command) == 2: + user_id = int(message.command[1]) # Convert the user_id to integer + user = await client.get_users(user_id) + if await db.remove_premium_access(user_id): + await message.reply_text("ᴜꜱᴇʀ ʀᴇᴍᴏᴠᴇᴅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ !") + await client.send_message( + chat_id=user_id, + text=f"ʜᴇʏ {user.mention},\n\nʏᴏᴜʀ ᴘʀᴇᴍɪᴜᴍ ᴀᴄᴄᴇss ʜᴀs ʙᴇᴇɴ ʀᴇᴍᴏᴠᴇᴅ.\nᴛʜᴀɴᴋ ʏᴏᴜ ꜰᴏʀ ᴜsɪɴɢ ᴏᴜʀ sᴇʀᴠɪᴄᴇ 😊\nᴄʟɪᴄᴋ ᴏɴ /plan ᴛᴏ ᴄʜᴇᴄᴋ ᴏᴜᴛ ᴏᴛʜᴇʀ ᴘʟᴀɴꜱ." + ) + else: + await message.reply_text("ᴜɴᴀʙʟᴇ ᴛᴏ ʀᴇᴍᴏᴠᴇ ᴜꜱᴇᴅ !\nᴀʀᴇ ʏᴏᴜ ꜱᴜʀᴇ, ɪᴛ ᴡᴀꜱ ᴀ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀ ɪᴅ ?") + else: + await message.reply_text("ᴜꜱᴀɢᴇ : /remove_premium user_id") + +@Client.on_message(filters.command("myplan")) +async def myplan(client, message): + user = message.from_user.mention + user_id = message.from_user.id + data = await db.get_user(message.from_user.id) # Convert the user_id to integer + if data and data.get("expiry_time"): + #expiry_time = datetime.datetime.now() + datetime.timedelta(seconds=data) + expiry = data.get("expiry_time") + expiry_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")) + expiry_str_in_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y\n⏱️ ᴇxᴘɪʀʏ ᴛɪᴍᴇ : %I:%M:%S %p") + # Calculate time difference + current_time = datetime.datetime.now(pytz.timezone("Asia/Kolkata")) + time_left = expiry_ist - current_time + + # Calculate days, hours, and minutes + days = time_left.days + hours, remainder = divmod(time_left.seconds, 3600) + minutes, seconds = divmod(remainder, 60) + + # Format time left as a string + time_left_str = f"{days} ᴅᴀʏꜱ, {hours} ʜᴏᴜʀꜱ, {minutes} ᴍɪɴᴜᴛᴇꜱ" + await message.reply_text(f"⚜️ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀ ᴅᴀᴛᴀ :\n\n👤 ᴜꜱᴇʀ : {user}\n⚡ ᴜꜱᴇʀ ɪᴅ : {user_id}\n⏰ ᴛɪᴍᴇ ʟᴇꜰᴛ : {time_left_str}\n⌛️ ᴇxᴘɪʀʏ ᴅᴀᴛᴇ : {expiry_str_in_ist}") + else: + await message.reply_text(f"ʜᴇʏ {user},\n\nʏᴏᴜ ᴅᴏ ɴᴏᴛ ʜᴀᴠᴇ ᴀɴʏ ᴀᴄᴛɪᴠᴇ ᴘʀᴇᴍɪᴜᴍ ᴘʟᴀɴs, ɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴛᴀᴋᴇ ᴘʀᴇᴍɪᴜᴍ ᴛʜᴇɴ ᴄʟɪᴄᴋ ᴏɴ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ 👇", + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("💸 ᴄʜᴇᴄᴋᴏᴜᴛ ᴘʀᴇᴍɪᴜᴍ ᴘʟᴀɴꜱ 💸", callback_data='seeplans')]])) + +@Client.on_message(filters.command("get_premium") & filters.user(ADMINS)) +async def get_premium(client, message): + if len(message.command) == 2: + user_id = int(message.command[1]) + user = await client.get_users(user_id) + data = await db.get_user(user_id) # Convert the user_id to integer + if data and data.get("expiry_time"): + #expiry_time = datetime.datetime.now() + datetime.timedelta(seconds=data) + expiry = data.get("expiry_time") + expiry_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")) + expiry_str_in_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y\n⏱️ ᴇxᴘɪʀʏ ᴛɪᴍᴇ : %I:%M:%S %p") + # Calculate time difference + current_time = datetime.datetime.now(pytz.timezone("Asia/Kolkata")) + time_left = expiry_ist - current_time + + # Calculate days, hours, and minutes + days = time_left.days + hours, remainder = divmod(time_left.seconds, 3600) + minutes, seconds = divmod(remainder, 60) + + # Format time left as a string + time_left_str = f"{days} days, {hours} hours, {minutes} minutes" + await message.reply_text(f"⚜️ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀ ᴅᴀᴛᴀ :\n\n👤 ᴜꜱᴇʀ : {user.mention}\n⚡ ᴜꜱᴇʀ ɪᴅ : {user_id}\n⏰ ᴛɪᴍᴇ ʟᴇꜰᴛ : {time_left_str}\n⌛️ ᴇxᴘɪʀʏ ᴅᴀᴛᴇ : {expiry_str_in_ist}") + else: + await message.reply_text("ɴᴏ ᴀɴʏ ᴘʀᴇᴍɪᴜᴍ ᴅᴀᴛᴀ ᴏꜰ ᴛʜᴇ ᴡᴀꜱ ꜰᴏᴜɴᴅ ɪɴ ᴅᴀᴛᴀʙᴀꜱᴇ !") + else: + await message.reply_text("ᴜꜱᴀɢᴇ : /get_premium user_id") + +@Client.on_message(filters.command("add_premium") & filters.user(ADMINS)) +async def give_premium_cmd_handler(client, message): + if len(message.command) == 4: + time_zone = datetime.datetime.now(pytz.timezone("Asia/Kolkata")) + current_time = time_zone.strftime("%d-%m-%Y\n⏱️ ᴊᴏɪɴɪɴɢ ᴛɪᴍᴇ : %I:%M:%S %p") + user_id = int(message.command[1]) # Convert the user_id to integer + user = await client.get_users(user_id) + time = message.command[2]+" "+message.command[3] + seconds = await get_seconds(time) + if seconds > 0: + expiry_time = datetime.datetime.now() + datetime.timedelta(seconds=seconds) + user_data = {"id": user_id, "expiry_time": expiry_time} # Using "id" instead of "user_id" + await db.update_user(user_data) # Use the update_user method to update or insert user data + data = await db.get_user(user_id) + expiry = data.get("expiry_time") + expiry_str_in_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y\n⏱️ ᴇxᴘɪʀʏ ᴛɪᴍᴇ : %I:%M:%S %p") + await message.reply_text(f"ᴘʀᴇᴍɪᴜᴍ ᴀᴅᴅᴇᴅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ✅\n\n👤 ᴜꜱᴇʀ : {user.mention}\n⚡ ᴜꜱᴇʀ ɪᴅ : {user_id}\n⏰ ᴘʀᴇᴍɪᴜᴍ ᴀᴄᴄᴇꜱꜱ : {time}\n\n⏳ ᴊᴏɪɴɪɴɢ ᴅᴀᴛᴇ : {current_time}\n\n⌛️ ᴇxᴘɪʀʏ ᴅᴀᴛᴇ : {expiry_str_in_ist}", disable_web_page_preview=True) + await client.send_message( + chat_id=user_id, + text=f"👋 ʜᴇʏ {user.mention},\nᴛʜᴀɴᴋ ʏᴏᴜ ꜰᴏʀ ᴘᴜʀᴄʜᴀꜱɪɴɢ ᴘʀᴇᴍɪᴜᴍ.\nᴇɴᴊᴏʏ !! ✨🎉\n\n⏰ ᴘʀᴇᴍɪᴜᴍ ᴀᴄᴄᴇꜱꜱ : {time}\n⏳ ᴊᴏɪɴɪɴɢ ᴅᴀᴛᴇ : {current_time}\n\n⌛️ ᴇxᴘɪʀʏ ᴅᴀᴛᴇ : {expiry_str_in_ist}", disable_web_page_preview=True + ) + await client.send_message(PREMIUM_LOGS, text=f"#Added_Premium\n\n👤 ᴜꜱᴇʀ : {user.mention}\n⚡ ᴜꜱᴇʀ ɪᴅ : {user_id}\n⏰ ᴘʀᴇᴍɪᴜᴍ ᴀᴄᴄᴇꜱꜱ : {time}\n\n⏳ ᴊᴏɪɴɪɴɢ ᴅᴀᴛᴇ : {current_time}\n\n⌛️ ᴇxᴘɪʀʏ ᴅᴀᴛᴇ : {expiry_str_in_ist}", disable_web_page_preview=True) + + else: + await message.reply_text("Invalid time format. Please use '1 day for days', '1 hour for hours', or '1 min for minutes', or '1 month for months' or '1 year for year'") + else: + await message.reply_text("Usage : /add_premium user_id time (e.g., '1 day for days', '1 hour for hours', or '1 min for minutes', or '1 month for months' or '1 year for year')") + +@Client.on_message(filters.command("premium_users") & filters.user(ADMINS)) +async def premium_user(client, message): + aa = await message.reply_text("ꜰᴇᴛᴄʜɪɴɢ...") + new = f"⚜️ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀꜱ ʟɪꜱᴛ :\n\n" + user_count = 1 + users = await db.get_all_users() + async for user in users: + data = await db.get_user(user['id']) + if data and data.get("expiry_time"): + expiry = data.get("expiry_time") + expiry_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")) + expiry_str_in_ist = expiry.astimezone(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y\n⏱️ ᴇxᴘɪʀʏ ᴛɪᴍᴇ : %I:%M:%S %p") + current_time = datetime.datetime.now(pytz.timezone("Asia/Kolkata")) + time_left = expiry_ist - current_time + days = time_left.days + hours, remainder = divmod(time_left.seconds, 3600) + minutes, seconds = divmod(remainder, 60) + time_left_str = f"{days} days, {hours} hours, {minutes} minutes" + new += f"{user_count}. {(await client.get_users(user['id'])).mention}\n👤 ᴜꜱᴇʀ ɪᴅ : {user['id']}\n⏳ ᴇxᴘɪʀʏ ᴅᴀᴛᴇ : {expiry_str_in_ist}\n⏰ ᴛɪᴍᴇ ʟᴇꜰᴛ : {time_left_str}\n" + user_count += 1 + else: + pass + try: + await aa.edit_text(new) + except MessageTooLong: + with open('usersplan.txt', 'w+') as outfile: + outfile.write(new) + await message.reply_document('usersplan.txt', caption="Paid Users:") + + + +@Client.on_message(filters.command("plan")) +async def plan(client, message): + user_id = message.from_user.id + users = message.from_user.mention + btn = [[ + + InlineKeyboardButton("📲 ꜱᴇɴᴅ ᴘᴀʏᴍᴇɴᴛ ꜱᴄʀᴇᴇɴꜱʜᴏᴛ ʜᴇʀᴇ", user_id=int(767250672))],[InlineKeyboardButton("❌ ᴄʟᴏꜱᴇ ❌", callback_data="close_data") + ]] + await message.reply_photo(photo="https://telegra.ph/file/734170f40b8169830d821.jpg", caption=script.PREMIUM_TEXT.format(message.from_user.mention), reply_markup=InlineKeyboardMarkup(btn)) + +# SPECIAL THANKS TO [Rishikesh Sharma] @Rk_botowner FOR THESE AMAZING CODES +# SPECIAL THANKS TO @DeletedFromEarth FOR MODIFYING THESE AMAZING CODES diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..280f615fe8a7e973d9ea25ea62595acdaec0c51f --- /dev/null +++ b/plugins/__init__.py @@ -0,0 +1,8 @@ +from aiohttp import web +from .route import routes + + +async def web_server(): + web_app = web.Application(client_max_size=30000000) + web_app.add_routes(routes) + return web_app diff --git a/plugins/banned.py b/plugins/banned.py new file mode 100644 index 0000000000000000000000000000000000000000..dc890179d76448a2138b6c1609e3d88ab1de129f --- /dev/null +++ b/plugins/banned.py @@ -0,0 +1,40 @@ +from pyrogram import Client, filters +from utils import temp +from pyrogram.types import Message +from database.users_chats_db import db +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from info import SUPPORT_CHAT + +async def banned_users(_, client, message: Message): + return ( + message.from_user is not None or not message.sender_chat + ) and message.from_user.id in temp.BANNED_USERS + +banned_user = filters.create(banned_users) + +async def disabled_chat(_, client, message: Message): + return message.chat.id in temp.BANNED_CHATS + +disabled_group=filters.create(disabled_chat) + + +@Client.on_message(filters.private & banned_user & filters.incoming) +async def ban_reply(bot, message): + ban = await db.get_ban_status(message.from_user.id) + await message.reply(f'Sorry Dude, You are Banned to use Me. \nBan Reason : {ban["ban_reason"]}') + +@Client.on_message(filters.group & disabled_group & filters.incoming) +async def grp_bd(bot, message): + buttons = [[ + InlineKeyboardButton('Support', url=f'https://t.me/HpRequestBot') + ]] + reply_markup=InlineKeyboardMarkup(buttons) + vazha = await db.get_chat(message.chat.id) + k = await message.reply( + text=f"CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..\nReason : {vazha['reason']}.", + reply_markup=reply_markup) + try: + await k.pin() + except: + pass + await bot.leave_chat(message.chat.id) diff --git a/plugins/broadcast.py b/plugins/broadcast.py new file mode 100644 index 0000000000000000000000000000000000000000..895dc80482c4cd120ea3f8c4c0dc40546768eafc --- /dev/null +++ b/plugins/broadcast.py @@ -0,0 +1,67 @@ +from pyrogram import Client, filters +import datetime +import time +from database.users_chats_db import db +from info import ADMINS +from utils import broadcast_messages, broadcast_messages_group +import asyncio + +@Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply) +# https://t.me/GetTGLink/4178 +async def verupikkals(bot, message): + users = await db.get_all_users() + b_msg = message.reply_to_message + sts = await message.reply_text( + text='Broadcasting your messages...' + ) + start_time = time.time() + total_users = await db.total_users_count() + done = 0 + blocked = 0 + deleted = 0 + failed =0 + + success = 0 + async for user in users: + pti, sh = await broadcast_messages(int(user['id']), b_msg) + if pti: + success += 1 + elif pti == False: + if sh == "Blocked": + blocked+=1 + elif sh == "Deleted": + deleted += 1 + elif sh == "Error": + failed += 1 + done += 1 + await asyncio.sleep(2) + if not done % 20: + await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") + time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) + 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}") + +@Client.on_message(filters.command("grp_broadcast") & filters.user(ADMINS) & filters.reply) +async def broadcast_group(bot, message): + groups = await db.get_all_chats() + b_msg = message.reply_to_message + sts = await message.reply_text( + text='Broadcasting your messages To Groups...' + ) + start_time = time.time() + total_groups = await db.total_chat_count() + done = 0 + failed =0 + + success = 0 + async for group in groups: + pti, sh = await broadcast_messages_group(int(group['id']), b_msg) + if pti: + success += 1 + elif sh == "Error": + failed += 1 + done += 1 + if not done % 20: + await sts.edit(f"Broadcast in progress:\n\nTotal Groups {total_groups}\nCompleted: {done} / {total_groups}\nSuccess: {success}") + time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) + await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Groups {total_groups}\nCompleted: {done} / {total_groups}\nSuccess: {success}") + diff --git a/plugins/channel.py b/plugins/channel.py new file mode 100644 index 0000000000000000000000000000000000000000..7fc3ad727928f306d6f9619ef5e4232bc5c923d4 --- /dev/null +++ b/plugins/channel.py @@ -0,0 +1,20 @@ +from pyrogram import Client, filters +from info import CHANNELS +from database.ia_filterdb import save_file + +media_filter = filters.document | filters.video | filters.audio + + +@Client.on_message(filters.chat(CHANNELS) & media_filter) +async def media(bot, message): + """Media Handler""" + for file_type in ("document", "video", "audio"): + media = getattr(message, file_type, None) + if media is not None: + break + else: + return + + media.file_type = file_type + media.caption = message.caption + await save_file(media) diff --git a/plugins/commands.py b/plugins/commands.py new file mode 100644 index 0000000000000000000000000000000000000000..94fddbcedc792e734d7369de0bb33da52ed6fbae --- /dev/null +++ b/plugins/commands.py @@ -0,0 +1,1272 @@ +import os +import logging +import random +import asyncio +import pytz +from Script import script +from datetime import datetime +from pyrogram import Client, filters, enums +from pyrogram.errors import ChatAdminRequired, FloodWait +from pyrogram.types import * +from database.ia_filterdb import Media, get_file_details, unpack_new_file_id, get_bad_files +from database.users_chats_db import db +from info import CHANNELS, ADMINS, AUTH_CHANNEL, LOG_CHANNEL, PICS, BATCH_FILE_CAPTION, CUSTOM_FILE_CAPTION, PROTECT_CONTENT, CHNL_LNK, GRP_LNK, REQST_CHANNEL, SUPPORT_CHAT_ID, SUPPORT_CHAT, MAX_B_TN, VERIFY, HOWTOVERIFY, SHORTLINK_API, SHORTLINK_URL, TUTORIAL, IS_TUTORIAL, PREMIUM_USER, PICS, SUBSCRIPTION +from utils import get_settings, get_size, is_req_subscribed, save_group_settings, temp, verify_user, check_token, check_verification, get_token, get_shortlink, get_tutorial +from database.connections_mdb import active_connection +# from plugins.pm_filter import ENABLE_SHORTLINK +import re, asyncio, os, sys +import json +import base64 +logger = logging.getLogger(__name__) + +TIMEZONE = "Asia/Kolkata" +BATCH_FILES = {} + +@Client.on_message(filters.command("start") & filters.incoming) +async def start(client, message): + if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + buttons = [[ + InlineKeyboardButton('☆ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ☆', url=f'http://t.me/{temp.U_NAME}?startgroup=true') + ],[ + InlineKeyboardButton('🍁 ʜᴏᴡ ᴛᴏ ᴜꜱᴇ 🍁', url="https://t.me/{temp.U_NAME}?start=help") + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await message.reply(script.GSTART_TXT.format(message.from_user.mention if message.from_user else message.chat.title, temp.U_NAME, temp.B_NAME), reply_markup=reply_markup, disable_web_page_preview=True) + await asyncio.sleep(2) # 😢 https://github.com/EvamariaTG/EvaMaria/blob/master/plugins/p_ttishow.py#L17 😬 wait a bit, before checking. + if not await db.get_chat(message.chat.id): + total=await client.get_chat_members_count(message.chat.id) + await client.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, "Unknown")) + await db.add_chat(message.chat.id, message.chat.title) + return + if not await db.is_user_exist(message.from_user.id): + await db.add_user(message.from_user.id, message.from_user.first_name) + await client.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(message.from_user.id, message.from_user.mention)) + if len(message.command) != 2: + buttons = [[ + InlineKeyboardButton('☆ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ☆', url=f'http://telegram.me/{temp.U_NAME}?startgroup=true') + ],[ + InlineKeyboardButton('💸 ᴇᴀʀɴ ᴍᴏɴᴇʏ 💸', callback_data="shortlink_info"), + InlineKeyboardButton('• ᴜᴘᴅᴀᴛᴇꜱ •', callback_data='channels') + ],[ + InlineKeyboardButton('• ᴄᴏᴍᴍᴀɴᴅꜱ •', callback_data='help'), + InlineKeyboardButton('• ᴀʙᴏᴜᴛ •', callback_data='about') + ],[ + InlineKeyboardButton('✨ ʙᴜʏ ꜱᴜʙꜱᴄʀɪᴘᴛɪᴏɴ : ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ✨', callback_data="premium_info") + ]] + reply_markup = InlineKeyboardMarkup(buttons) + current_time = datetime.now(pytz.timezone(TIMEZONE)) + curr_time = current_time.hour + if curr_time < 12: + gtxt = "ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ 👋" + elif curr_time < 17: + gtxt = "ɢᴏᴏᴅ ᴀғᴛᴇʀɴᴏᴏɴ 👋" + elif curr_time < 21: + gtxt = "ɢᴏᴏᴅ ᴇᴠᴇɴɪɴɢ 👋" + else: + gtxt = "ɢᴏᴏᴅ ɴɪɢʜᴛ 👋" + m=await message.reply_text("ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ ʙᴏᴛ.\nʜᴏᴘᴇ ʏᴏᴜ'ʀᴇ ᴅᴏɪɴɢ ᴡᴇʟʟ...") + await asyncio.sleep(0.4) + await m.edit_text("👀") + await asyncio.sleep(0.5) + await m.edit_text("⚡") + await asyncio.sleep(0.5) + await m.edit_text("ꜱᴛᴀʀᴛɪɴɢ...") + await asyncio.sleep(0.4) + await m.delete() + m=await message.reply_sticker("CAACAgQAAxkBAAEKeqNlIpmeUoOEsEWOWEiPxPi3hH5q-QACbg8AAuHqsVDaMQeY6CcRojAE") + await asyncio.sleep(1) + await m.delete() + await message.reply_photo( + photo=random.choice(PICS), + caption=script.START_TXT.format(message.from_user.mention, gtxt, temp.U_NAME, temp.B_NAME), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + return + + if AUTH_CHANNEL and not await is_req_subscribed(client, message): + try: + invite_link = await client.create_chat_invite_link(int(AUTH_CHANNEL), creates_join_request=True) + except ChatAdminRequired: + logger.error("Make sure Bot is admin in Forcesub channel") + return + btn = [ + [ + InlineKeyboardButton( + "📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌", url=invite_link.invite_link + ) + ] + ] + + if message.command[1] != "subscribe": + try: + kk, file_id = message.command[1].split("_", 1) + btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", callback_data=f"checksub#{kk}#{file_id}")]) + except (IndexError, ValueError): + btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", url=f"https://t.me/{temp.U_NAME}?start={message.command[1]}")]) + await client.send_message( + chat_id=message.from_user.id, + text="ᴊᴏɪɴ ᴏᴜʀ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ ᴀɴᴅ ᴛʜᴇɴ ᴄʟɪᴄᴋ ᴏɴ ᴛʀʏ ᴀɢᴀɪɴ ᴛᴏ ɢᴇᴛ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛᴇᴅ ꜰɪʟᴇ.", + reply_markup=InlineKeyboardMarkup(btn), + parse_mode=enums.ParseMode.MARKDOWN + ) + return + if len(message.command) == 2 and message.command[1] in ["subscribe", "error", "okay", "help"]: + buttons = [[ + InlineKeyboardButton('☆ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ☆', url=f'http://telegram.me/{temp.U_NAME}?startgroup=true') + ],[ + InlineKeyboardButton('💸 ᴇᴀʀɴ ᴍᴏɴᴇʏ 💸', callback_data="shortlink_info"), + InlineKeyboardButton('• ᴜᴘᴅᴀᴛᴇꜱ •', callback_data='channels') + ],[ + InlineKeyboardButton('• ᴄᴏᴍᴍᴀɴᴅꜱ •', callback_data='help'), + InlineKeyboardButton('• ᴀʙᴏᴜᴛ •', callback_data='about') + ],[ + InlineKeyboardButton('✨ ʙᴜʏ ꜱᴜʙꜱᴄʀɪᴘᴛɪᴏɴ : ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ✨', callback_data="premium_info") + ]] + reply_markup = InlineKeyboardMarkup(buttons) + current_time = datetime.now(pytz.timezone(TIMEZONE)) + curr_time = current_time.hour + if curr_time < 12: + gtxt = "ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ 👋" + elif curr_time < 17: + gtxt = "ɢᴏᴏᴅ ᴀғᴛᴇʀɴᴏᴏɴ 👋" + elif curr_time < 21: + gtxt = "ɢᴏᴏᴅ ᴇᴠᴇɴɪɴɢ 👋" + else: + gtxt = "ɢᴏᴏᴅ ɴɪɢʜᴛ 👋" + m=await message.reply_text("ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ ʙᴏᴛ.\nʜᴏᴘᴇ ʏᴏᴜ'ʀᴇ ᴅᴏɪɴɢ ᴡᴇʟʟ...") + await asyncio.sleep(0.4) + await m.edit_text("👀") + await asyncio.sleep(0.5) + await m.edit_text("⚡") + await asyncio.sleep(0.5) + await m.edit_text("ꜱᴛᴀʀᴛɪɴɢ...") + await asyncio.sleep(0.4) + await m.delete() + m=await message.reply_sticker("CAACAgQAAxkBAAEKeqNlIpmeUoOEsEWOWEiPxPi3hH5q-QACbg8AAuHqsVDaMQeY6CcRojAE") + await asyncio.sleep(1) + await m.delete() + await message.reply_photo( + photo=random.choice(PICS), + caption=script.START_TXT.format(message.from_user.mention, gtxt, temp.U_NAME, temp.B_NAME), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + return + + + if len(message.command) == 2 and message.command[1] in ["premium"]: + buttons = [[ + InlineKeyboardButton('📲 ꜱᴇɴᴅ ᴘᴀʏᴍᴇɴᴛ ꜱᴄʀᴇᴇɴꜱʜᴏᴛ', user_id=int(767250672)) + ],[ + InlineKeyboardButton('❌ ᴄʟᴏꜱᴇ ❌', callback_data='close_data') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await message.reply_photo( + photo=(SUBSCRIPTION), + caption=script.PREPLANS_TXT.format(message.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + return + data = message.command[1] + try: + pre, file_id = data.split('_', 1) + except: + file_id = data + pre = "" + if data.split("-", 1)[0] == "BATCH": + sts = await message.reply("Please wait...") + file_id = data.split("-", 1)[1] + msgs = BATCH_FILES.get(file_id) + if not msgs: + file = await client.download_media(file_id) + try: + with open(file) as file_data: + msgs=json.loads(file_data.read()) + except: + await sts.edit("FAILED") + return await client.send_message(LOG_CHANNEL, "UNABLE TO OPEN FILE.") + os.remove(file) + BATCH_FILES[file_id] = msgs + for msg in msgs: + title = msg.get("title") + size=get_size(int(msg.get("size", 0))) + f_caption=msg.get("caption", "") + if BATCH_FILE_CAPTION: + try: + 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) + except Exception as e: + logger.exception(e) + f_caption=f_caption + if f_caption is None: + f_caption = f"{title}" + try: + await client.send_cached_media( + chat_id=message.from_user.id, + file_id=msg.get("file_id"), + caption=f_caption, + protect_content=msg.get('protect', False), + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ / ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿', callback_data=f'generate_stream_link:{file_id}'), + ], + [ + InlineKeyboardButton('📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌', url=f'https://t.me/HP_MOVIES_WORLD') #Don't change anything without contacting me @LazyDeveloperr + ] + ] + ) + ) + except FloodWait as e: + await asyncio.sleep(e.x) + logger.warning(f"Floodwait of {e.x} sec.") + await client.send_cached_media( + chat_id=message.from_user.id, + file_id=msg.get("file_id"), + caption=f_caption, + protect_content=msg.get('protect', False), + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ / ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿', callback_data=f'generate_stream_link:{file_id}'), + ], + [ + InlineKeyboardButton('📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌', url=f'https://t.me/HP_MOVIES_WORLD') #Don't change anything without contacting me @LazyDeveloperr + ] + ] + ) + ) + except Exception as e: + logger.warning(e, exc_info=True) + continue + await asyncio.sleep(1) + await sts.delete() + return + + elif data.split("-", 1)[0] == "DSTORE": + sts = await message.reply("Please wait...") + b_string = data.split("-", 1)[1] + decoded = (base64.urlsafe_b64decode(b_string + "=" * (-len(b_string) % 4))).decode("ascii") + try: + f_msg_id, l_msg_id, f_chat_id, protect = decoded.split("_", 3) + except: + f_msg_id, l_msg_id, f_chat_id = decoded.split("_", 2) + protect = "/pbatch" if PROTECT_CONTENT else "batch" + diff = int(l_msg_id) - int(f_msg_id) + async for msg in client.iter_messages(int(f_chat_id), int(l_msg_id), int(f_msg_id)): + if msg.media: + media = getattr(msg, msg.media.value) + if BATCH_FILE_CAPTION: + try: + f_caption=BATCH_FILE_CAPTION.format(file_name=getattr(media, 'file_name', ''), file_size=getattr(media, 'file_size', ''), file_caption=getattr(msg, 'caption', '')) + except Exception as e: + logger.exception(e) + f_caption = getattr(msg, 'caption', '') + else: + media = getattr(msg, msg.media.value) + file_name = getattr(media, 'file_name', '') + f_caption = getattr(msg, 'caption', file_name) + try: + await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False) + except FloodWait as e: + await asyncio.sleep(e.x) + await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False) + except Exception as e: + logger.exception(e) + continue + elif msg.empty: + continue + else: + try: + await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False) + except FloodWait as e: + await asyncio.sleep(e.x) + await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False) + except Exception as e: + logger.exception(e) + continue + await asyncio.sleep(1) + return await sts.delete() + + elif data.split("-", 1)[0] == "verify": + userid = data.split("-", 2)[1] + token = data.split("-", 3)[2] + if str(message.from_user.id) != str(userid): + return await message.reply_text( + text="Invalid link or Expired link !", + protect_content=True + ) + is_valid = await check_token(client, userid, token) + if is_valid == True: + await message.reply_text( + text=f"Hey {message.from_user.mention}, You are successfully verified !\nNow you have unlimited access for all movies till today midnight.", + protect_content=True + ) + await verify_user(client, userid, token) + else: + return await message.reply_text( + text="Invalid link or Expired link !", + protect_content=True + ) + if data.startswith("sendfiles"): + protect_content=True + current_time = datetime.now(pytz.timezone(TIMEZONE)) + curr_time = current_time.hour + if curr_time < 12: + gtxt = "ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ 👋" + elif curr_time < 17: + gtxt = "ɢᴏᴏᴅ ᴀғᴛᴇʀɴᴏᴏɴ 👋" + elif curr_time < 21: + gtxt = "ɢᴏᴏᴅ ᴇᴠᴇɴɪɴɢ 👋" + else: + gtxt = "ɢᴏᴏᴅ ɴɪɢʜᴛ 👋" + chat_id = int("-" + file_id.split("-")[1]) + userid = message.from_user.id if message.from_user else None + g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{file_id}") + k = await client.send_message(chat_id=message.from_user.id,text=f"🫂 ʜᴇʏ {message.from_user.mention}, {gtxt}\n\n‼️ ɢᴇᴛ ᴀʟʟ ꜰɪʟᴇꜱ ɪɴ ᴀ ꜱɪɴɢʟᴇ ʟɪɴᴋ ‼️\n\n✅ ʏᴏᴜʀ ʟɪɴᴋ ɪꜱ ʀᴇᴀᴅʏ, ᴋɪɴᴅʟʏ ᴄʟɪᴄᴋ ᴏɴ ᴅᴏᴡɴʟᴏᴀᴅ ʙᴜᴛᴛᴏɴ.\n\n", reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('📁 ᴅᴏᴡɴʟᴏᴀᴅ 📁', url=g) + ], [ + InlineKeyboardButton('⚡ ʜᴏᴡ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ⚡', url=await get_tutorial(chat_id)) + ], [ + InlineKeyboardButton('✨ ʙᴜʏ ꜱᴜʙꜱᴄʀɪᴘᴛɪᴏɴ : ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ✨', callback_data="seeplans") + ] + ] + ) + ) + await asyncio.sleep(300) + await k.edit("ʏᴏᴜʀ ᴍᴇꜱꜱᴀɢᴇ ɪꜱ ᴅᴇʟᴇᴛᴇᴅ !\nᴋɪɴᴅʟʏ ꜱᴇᴀʀᴄʜ ᴀɢᴀɪɴ.") + return + + + elif data.startswith("short"): + protect_content=True + current_time = datetime.now(pytz.timezone(TIMEZONE)) + curr_time = current_time.hour + if curr_time < 12: + gtxt = "ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ 👋" + elif curr_time < 17: + gtxt = "ɢᴏᴏᴅ ᴀғᴛᴇʀɴᴏᴏɴ 👋" + elif curr_time < 21: + gtxt = "ɢᴏᴏᴅ ᴇᴠᴇɴɪɴɢ 👋" + else: + gtxt = "ɢᴏᴏᴅ ɴɪɢʜᴛ 👋" + user_id = message.from_user.id + chat_id = temp.SHORT.get(user_id) + files_ = await get_file_details(file_id) + files = files_[0] + g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}") + k = await client.send_message( + chat_id=user_id, + text=f"🫂 ʜᴇʏ {message.from_user.mention}, {gtxt}\n\n✅ ʏᴏᴜʀ ʟɪɴᴋ ɪꜱ ʀᴇᴀᴅʏ, ᴋɪɴᴅʟʏ ᴄʟɪᴄᴋ ᴏɴ ᴅᴏᴡɴʟᴏᴀᴅ ʙᴜᴛᴛᴏɴ.\n\n⚠️ ꜰɪʟᴇ ɴᴀᴍᴇ : {files.file_name} \n\n📥 ꜰɪʟᴇ ꜱɪᴢᴇ : {get_size(files.file_size)}\n\n", + reply_markup=InlineKeyboardMarkup( + [[ + InlineKeyboardButton('📁 ᴅᴏᴡɴʟᴏᴀᴅ 📁', url=g) + ], [ + InlineKeyboardButton('⚡ ʜᴏᴡ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ⚡', url=await get_tutorial(chat_id)) + ], [ + InlineKeyboardButton('✨ ʙᴜʏ ꜱᴜʙꜱᴄʀɪᴘᴛɪᴏɴ : ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ✨', callback_data="seeplans") + ]] + ) + ) + await asyncio.sleep(600) + await k.edit("ʏᴏᴜʀ ᴍᴇꜱꜱᴀɢᴇ ɪꜱ ᴅᴇʟᴇᴛᴇᴅ !\nᴋɪɴᴅʟʏ ꜱᴇᴀʀᴄʜ ᴀɢᴀɪɴ.") + return + + elif data.startswith("all"): + protect_content=True + user_id = message.from_user.id + files = temp.GETALL.get(file_id) + if not files: + return await message.reply('ɴᴏ ꜱᴜᴄʜ ꜰɪʟᴇ ᴇxɪꜱᴛꜱ !') + filesarr = [] + for file in files: + file_id = file.file_id + files_ = await get_file_details(file_id) + files1 = files_[0] + title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split())) + size=get_size(files1.file_size) + f_caption=files1.caption + if CUSTOM_FILE_CAPTION: + try: + 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) + except Exception as e: + logger.exception(e) + f_caption=f_caption + if f_caption is None: + f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))}" + + if not await check_verification(client, message.from_user.id) and VERIFY == True: + btn = [[ + InlineKeyboardButton("♻️ ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ᴠᴇʀɪꜰʏ ♻️", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=")) + ],[ + InlineKeyboardButton("⁉️ ʜᴏᴡ ᴛᴏ ᴠᴇʀɪꜰʏ ⁉️", url=HOWTOVERIFY) + ]] + await message.reply_text( + text="👋 ʜᴇʏ {message.from_user.mention}, ʏᴏᴜ'ʀᴇ ᴀʀᴇ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴠᴇʀɪꜰɪᴇᴅ ✅\n\nɴᴏᴡ ʏᴏᴜ'ᴠᴇ ᴜɴʟɪᴍɪᴛᴇᴅ ᴀᴄᴄᴇꜱꜱ ᴛɪʟʟ ɴᴇxᴛ ᴠᴇʀɪꜰɪᴄᴀᴛɪᴏɴ 🎉", + protect_content=True, + reply_markup=InlineKeyboardMarkup(btn) + ) + return + msg = await client.send_cached_media( + chat_id=message.from_user.id, + file_id=file_id, + caption=f_caption, + protect_content=True if pre == 'filep' else False, + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ / ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿', callback_data=f'generate_stream_link:{file_id}'), + ], + [ + InlineKeyboardButton('📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌', url=f'https://t.me/HP_MOVIES_WORLD') #Don't change anything without contacting me @LazyDeveloperr + ] + ] + ) + ) + filesarr.append(msg) + k = await client.send_message(chat_id = message.from_user.id, text=f"❗️ ɪᴍᴘᴏʀᴛᴀɴᴛ ❗️\n\nᴛʜᴇꜱᴇ ᴠɪᴅᴇᴏꜱ / ꜰɪʟᴇꜱ ᴡɪʟʟ ʙᴇ ᴅᴇʟᴇᴛᴇᴅ ɪɴ 10 ᴍɪɴᴜᴛᴇꜱ (ᴅᴜᴇ ᴛᴏ ᴄᴏᴘʏʀɪɢʜᴛ ɪꜱꜱᴜᴇꜱ).\n\n📌 ᴘʟᴇᴀꜱᴇ ꜰᴏʀᴡᴀʀᴅ ᴛʜᴇꜱᴇ ᴠɪᴅᴇᴏꜱ / ꜰɪʟᴇꜱ ᴛᴏ ꜱᴏᴍᴇᴡʜᴇʀᴇ ᴇʟꜱᴇ ᴀɴᴅ ꜱᴛᴀʀᴛ ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ ᴛʜᴇʀᴇ.") + await asyncio.sleep(600) + for x in filesarr: + await x.delete() + await k.edit_text("ʏᴏᴜʀ ᴠɪᴅᴇᴏꜱ / ꜰɪʟᴇꜱ ᴀʀᴇ ᴅᴇʟᴇᴛᴇᴅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ !\nᴋɪɴᴅʟʏ ꜱᴇᴀʀᴄʜ ᴀɢᴀɪɴ.") + return + + elif data.startswith("files"): + current_time = datetime.now(pytz.timezone(TIMEZONE)) + curr_time = current_time.hour + if curr_time < 12: + gtxt = "ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ 👋" + elif curr_time < 17: + gtxt = "ɢᴏᴏᴅ ᴀғᴛᴇʀɴᴏᴏɴ 👋" + elif curr_time < 21: + gtxt = "ɢᴏᴏᴅ ᴇᴠᴇɴɪɴɢ 👋" + else: + gtxt = "ɢᴏᴏᴅ ɴɪɢʜᴛ 👋" + user_id = message.from_user.id + if temp.SHORT.get(user_id)==None: + return await message.reply_text(text="Please Search Again in Group") + else: + chat_id = temp.SHORT.get(user_id) + settings = await get_settings(chat_id) + if not await db.has_premium_access(user_id) and settings['is_shortlink']: #Don't change anything without my permission @CoderluffyTG + files_ = await get_file_details(file_id) + files = files_[0] + g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}") + k = await client.send_message(chat_id=message.from_user.id,text=f"🫂 ʜᴇʏ {message.from_user.mention}, {gtxt}\n\n✅ ʏᴏᴜʀ ʟɪɴᴋ ɪꜱ ʀᴇᴀᴅʏ, ᴋɪɴᴅʟʏ ᴄʟɪᴄᴋ ᴏɴ ᴅᴏᴡɴʟᴏᴀᴅ ʙᴜᴛᴛᴏɴ.\n\n⚠️ ꜰɪʟᴇ ɴᴀᴍᴇ : {files.file_name} \n\n📥 ꜰɪʟᴇ ꜱɪᴢᴇ : {get_size(files.file_size)}\n\n", reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('📁 ᴅᴏᴡɴʟᴏᴀᴅ 📁', url=g) + ], [ + InlineKeyboardButton('⚡ ʜᴏᴡ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ⚡', url=await get_tutorial(chat_id)) + ], [ + InlineKeyboardButton('✨ ʙᴜʏ ꜱᴜʙꜱᴄʀɪᴘᴛɪᴏɴ : ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ✨', callback_data="seeplans") + ] + ] + ) + ) + await asyncio.sleep(600) + await k.edit("ʏᴏᴜʀ ᴍᴇꜱꜱᴀɢᴇ ɪꜱ ᴅᴇʟᴇᴛᴇᴅ !\nᴋɪɴᴅʟʏ ꜱᴇᴀʀᴄʜ ᴀɢᴀɪɴ.") + return + user = message.from_user.id + files_ = await get_file_details(file_id) + if not files_: + pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1) + try: + if not await check_verification(client, message.from_user.id) and VERIFY == True: + btn = [[ + InlineKeyboardButton("♻️ ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ᴠᴇʀɪꜰʏ ♻️", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=")) + ],[ + InlineKeyboardButton("⁉️ ʜᴏᴡ ᴛᴏ ᴠᴇʀɪꜰʏ ⁉️", url=HOWTOVERIFY) + ]] + await message.reply_text( + text="👋 ʜᴇʏ ᴛʜᴇʀᴇ,\n\n📌 ʏᴏᴜ'ʀᴇ ɴᴏᴛ ᴠᴇʀɪꜰɪᴇᴅ ᴛᴏᴅᴀʏ, ᴘʟᴇᴀꜱᴇ ᴠᴇʀɪꜰʏ ᴀɴᴅ ɢᴇᴛ ᴜɴʟɪᴍɪᴛᴇᴅ ᴀᴄᴄᴇꜱꜱ ᴛɪʟʟ ɴᴇxᴛ ᴠᴇʀɪꜰɪᴄᴀᴛɪᴏɴ.", + protect_content=True, + reply_markup=InlineKeyboardMarkup(btn) + ) + return + msg = await client.send_cached_media( + chat_id=message.from_user.id, + file_id=file_id, + protect_content=True if pre == 'filep' else False, + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ / ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿', callback_data=f'generate_stream_link:{file_id}'), + ], + [ + InlineKeyboardButton('📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌', url=f'https://t.me/HP_MOVIES_WORLD') #Don't change anything without contacting me @LazyDeveloperr + ] + ] + ) + ) + filetype = msg.media + file = getattr(msg, filetype.value) + title = '' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split())) + size=get_size(file.file_size) + f_caption = f"{title}" + if CUSTOM_FILE_CAPTION: + try: + f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='') + except: + return + await msg.edit_caption(f_caption) + btn = [[ + InlineKeyboardButton("❗ ɢᴇᴛ ꜰɪʟᴇ ᴀɢᴀɪɴ ❗", callback_data=f'delfile#{file_id}') + ]] + k = await client.send_message(chat_id = message.from_user.id, text=f"❗️ ɪᴍᴘᴏʀᴛᴀɴᴛ ❗️\n\nᴛʜɪꜱ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ ᴡɪʟʟ ʙᴇ ᴅᴇʟᴇᴛᴇᴅ ɪɴ 10 ᴍɪɴᴜᴛᴇꜱ (ᴅᴜᴇ ᴛᴏ ᴄᴏᴘʏʀɪɢʜᴛ ɪꜱꜱᴜᴇꜱ).\n\n📌 ᴘʟᴇᴀꜱᴇ ꜰᴏʀᴡᴀʀᴅ ᴛʜɪꜱ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ ᴛᴏ ꜱᴏᴍᴇᴡʜᴇʀᴇ ᴇʟꜱᴇ ᴀɴᴅ ꜱᴛᴀʀᴛ ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ ᴛʜᴇʀᴇ.") + await asyncio.sleep(600) + await msg.delete() + await k.edit_text("ʏᴏᴜʀ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ ɪꜱ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ !!\n\nᴄʟɪᴄᴋ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ʏᴏᴜʀ ᴅᴇʟᴇᴛᴇᴅ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ 👇",reply_markup=InlineKeyboardMarkup(btn)) + return + except: + pass + return await message.reply('ɴᴏ ꜱᴜᴄʜ ꜰɪʟᴇ ᴇxɪꜱᴛꜱ !') + files = files_[0] + title = '' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split())) + size=get_size(files.file_size) + f_caption=files.caption + if CUSTOM_FILE_CAPTION: + try: + 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) + except Exception as e: + logger.exception(e) + f_caption=f_caption + if f_caption is None: + f_caption = f" {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}" + + if not await check_verification(client, message.from_user.id) and VERIFY == True: + btn = [[ + InlineKeyboardButton("♻️ ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ᴠᴇʀɪꜰʏ ♻️", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=")) + ],[ + InlineKeyboardButton("⁉️ ʜᴏᴡ ᴛᴏ ᴠᴇʀɪꜰʏ ⁉️", url=HOWTOVERIFY) + ]] + await message.reply_text( + text="👋 ʜᴇʏ ᴛʜᴇʀᴇ,\n\n📌 ʏᴏᴜ'ʀᴇ ɴᴏᴛ ᴠᴇʀɪꜰɪᴇᴅ ᴛᴏᴅᴀʏ, ᴘʟᴇᴀꜱᴇ ᴠᴇʀɪꜰʏ ᴀɴᴅ ɢᴇᴛ ᴜɴʟɪᴍɪᴛᴇᴅ ᴀᴄᴄᴇꜱꜱ ᴛɪʟʟ ɴᴇxᴛ ᴠᴇʀɪꜰɪᴄᴀᴛɪᴏɴ.", + protect_content=True, + reply_markup=InlineKeyboardMarkup(btn) + ) + return + msg = await client.send_cached_media( + chat_id=message.from_user.id, + file_id=file_id, + caption=f_caption, + protect_content=True if pre == 'filep' else False, + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ / ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿', callback_data=f'generate_stream_link:{file_id}'), + ], + [ + InlineKeyboardButton('📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌', url=f'https://t.me/HP_MOVIES_WORLD') #Don't change anything without contacting me @LazyDeveloperr + ] + ] + ) + ) + btn = [[ + InlineKeyboardButton("❗ ɢᴇᴛ ꜰɪʟᴇ ᴀɢᴀɪɴ ❗", callback_data=f'delfile#{file_id}') + ]] + k = await client.send_message(chat_id = message.from_user.id, text=f"❗️ ɪᴍᴘᴏʀᴛᴀɴᴛ ❗️\n\nᴛʜɪꜱ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ ᴡɪʟʟ ʙᴇ ᴅᴇʟᴇᴛᴇᴅ ɪɴ 10 ᴍɪɴᴜᴛᴇꜱ (ᴅᴜᴇ ᴛᴏ ᴄᴏᴘʏʀɪɢʜᴛ ɪꜱꜱᴜᴇꜱ).\n\n📌 ᴘʟᴇᴀꜱᴇ ꜰᴏʀᴡᴀʀᴅ ᴛʜɪꜱ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ ᴛᴏ ꜱᴏᴍᴇᴡʜᴇʀᴇ ᴇʟꜱᴇ ᴀɴᴅ ꜱᴛᴀʀᴛ ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ ᴛʜᴇʀᴇ.") + await asyncio.sleep(600) + await msg.delete() + await k.edit_text("ʏᴏᴜʀ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ ɪꜱ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ !!\n\nᴄʟɪᴄᴋ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ʏᴏᴜʀ ᴅᴇʟᴇᴛᴇᴅ ᴠɪᴅᴇᴏ / ꜰɪʟᴇ 👇",reply_markup=InlineKeyboardMarkup(btn)) + return + +@Client.on_message(filters.command('channel') & filters.user(ADMINS)) +async def channel_info(bot, message): + + """Send basic information of channel""" + if isinstance(CHANNELS, (int, str)): + channels = [CHANNELS] + elif isinstance(CHANNELS, list): + channels = CHANNELS + else: + raise ValueError("ᴜɴᴇxᴘᴇᴄᴛᴇᴅ ᴛʏᴘᴇ ᴏꜰ ᴄʜᴀɴɴᴇʟꜱ.") + + text = '📑 **ɪɴᴅᴇxᴇᴅ ᴄʜᴀɴɴᴇʟꜱ / ɢʀᴏᴜᴘꜱ ʟɪꜱᴛ :**\n' + for channel in channels: + chat = await bot.get_chat(channel) + if chat.username: + text += '\n@' + chat.username + else: + text += '\n' + chat.title or chat.first_name + + text += f'\n\n**ᴛᴏᴛᴀʟ :** {len(CHANNELS)}' + + if len(text) < 4096: + await message.reply(text) + else: + file = 'Indexed channels.txt' + with open(file, 'w') as f: + f.write(text) + await message.reply_document(file) + os.remove(file) + + +@Client.on_message(filters.command('logs') & filters.user(ADMINS)) +async def log_file(bot, message): + """Send log file""" + try: + await message.reply_document('TELEGRAM BOT.LOG') + except Exception as e: + await message.reply(str(e)) + +@Client.on_message(filters.command('delete') & filters.user(ADMINS)) +async def delete(bot, message): + """Delete file from database""" + reply = message.reply_to_message + if reply and reply.media: + msg = await message.reply("ᴘʀᴏᴄᴇꜱꜱɪɴɢ...⏳", quote=True) + else: + await message.reply('ʀᴇᴘʟʏ ᴛᴏ ꜰɪʟᴇ ᴡɪᴛʜ /delete ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ ꜰʀᴏᴍ ᴅʙ.', quote=True) + return + + for file_type in ("document", "video", "audio"): + media = getattr(reply, file_type, None) + if media is not None: + break + else: + await msg.edit('ᴛʜɪꜱ ɪꜱ ɴᴏᴛ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ꜰɪʟᴇ ꜰᴏʀᴍᴀᴛ.') + return + + file_id, file_ref = unpack_new_file_id(media.file_id) + + result = await Media.collection.delete_one({ + '_id': file_id, + }) + if result.deleted_count: + await msg.edit('ꜰɪʟᴇ ɪꜱ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ꜰʀᴏᴍ ᴅʙ ✅') + else: + file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name)) + result = await Media.collection.delete_many({ + 'file_name': file_name, + 'file_size': media.file_size, + 'mime_type': media.mime_type + }) + if result.deleted_count: + await msg.edit('ꜰɪʟᴇ ɪꜱ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ꜰʀᴏᴍ ᴅʙ ✅') + else: + # files indexed before https://github.com/EvamariaTG/EvaMaria/commit/f3d2a1bcb155faf44178e5d7a685a1b533e714bf#diff-86b613edf1748372103e94cacff3b578b36b698ef9c16817bb98fe9ef22fb669R39 + # have original file name. + result = await Media.collection.delete_many({ + 'file_name': media.file_name, + 'file_size': media.file_size, + 'mime_type': media.mime_type + }) + if result.deleted_count: + await msg.edit('ꜰɪʟᴇ ɪꜱ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ꜰʀᴏᴍ ᴅʙ ✅') + else: + await msg.edit('ꜰɪʟᴇ ɪꜱ ɴᴏᴛ ꜰᴏᴜɴᴅ ɪɴ ᴅʙ ❌') + + +@Client.on_message(filters.command('deleteall') & filters.user(ADMINS)) +async def delete_all_index(bot, message): + await message.reply_text( + 'ᴛʜɪꜱ ᴡɪʟʟ ᴅᴇʟᴇᴛᴇ ᴀʟʟ ʏᴏᴜʀ ɪɴᴅᴇxᴇᴅ ꜰɪʟᴇꜱ !\nᴅᴏ ʏᴏᴜ ꜱᴛɪʟʟ ᴡᴀɴᴛ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ ?', + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton( + text="⚠️ ʏᴇꜱ ⚠️", callback_data="autofilter_delete" + ) + ], + [ + InlineKeyboardButton( + text="❌ ɴᴏ ❌", callback_data="close_data" + ) + ], + ] + ), + quote=True, + ) + + +@Client.on_callback_query(filters.regex(r'^autofilter_delete')) +async def delete_all_index_confirm(bot, message): + await Media.collection.drop() + await message.answer('ᴍᴀɪɴᴛᴀɪɴᴇᴅ ʙʏ : ʜᴘ') + await message.message.edit('ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ᴀʟʟ ɪɴᴅᴇxᴇᴅ ꜰɪʟᴇꜱ ✅') + + +@Client.on_message(filters.command('settings')) +async def settings(client, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"ʏᴏᴜ'ʀᴇ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ.\nᴜꜱᴇ /connect {message.chat.id} ɪɴ ᴘᴍ.") + chat_type = message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await message.reply_text("ᴍᴀᴋᴇ ꜱᴜʀᴇ ɪ'ᴍ ᴘʀᴇꜱᴇɴᴛ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ !!", quote=True) + return + else: + await message.reply_text("ɪ'ᴍ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘ !", quote=True) + return + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = message.chat.id + title = message.chat.title + + else: + return + + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + return + + settings = await get_settings(grp_id) + + try: + if settings['max_btn']: + settings = await get_settings(grp_id) + except KeyError: + await save_group_settings(grp_id, 'max_btn', False) + settings = await get_settings(grp_id) + if 'is_shortlink' not in settings.keys(): + await save_group_settings(grp_id, 'is_shortlink', False) + else: + pass + + if settings is not None: + buttons = [ + [ + InlineKeyboardButton( + 'ʀᴇꜱᴜʟᴛ ᴘᴀɢᴇ', + callback_data=f'setgs#button#{settings["button"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ʙᴜᴛᴛᴏɴ' if settings["button"] else 'ᴛᴇxᴛ', + callback_data=f'setgs#button#{settings["button"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ꜰɪʟᴇ ꜱᴇɴᴅ ᴍᴏᴅᴇ', + callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ꜱᴛᴀʀᴛ' if settings["botpm"] else 'ᴀᴜᴛᴏ', + callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ꜰɪʟᴇ ꜱᴇᴄᴜʀᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["file_secure"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ɪᴍᴅʙ ᴘᴏꜱᴛᴇʀ', + callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["imdb"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ꜱᴘᴇʟʟ ᴄʜᴇᴄᴋ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["spell_check"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ᴡᴇʟᴄᴏᴍᴇ ᴍꜱɢ', + callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["welcome"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["auto_delete"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["auto_ffilter"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ᴍᴀx ʙᴜᴛᴛᴏɴꜱ', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}', + ), + InlineKeyboardButton( + '10' if settings["max_btn"] else f'{MAX_B_TN}', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton( + 'ꜱʜᴏʀᴛʟɪɴᴋ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}', + ), + InlineKeyboardButton( + 'ᴇɴᴀʙʟᴇ' if settings["is_shortlink"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}', + ), + ], + [ + InlineKeyboardButton('⇋ ᴄʟᴏꜱᴇ ꜱᴇᴛᴛɪɴɢꜱ ᴍᴇɴᴜ ⇋', + callback_data='close_data' + ) + ] + ] + + + btn = [[ + InlineKeyboardButton("👤 ᴏᴘᴇɴ ɪɴ ᴘʀɪᴠᴀᴛᴇ ᴄʜᴀᴛ 👤", callback_data=f"opnsetpm#{grp_id}") + ],[ + InlineKeyboardButton("👥 ᴏᴘᴇɴ ʜᴇʀᴇ 👥", callback_data=f"opnsetgrp#{grp_id}") + ]] + + reply_markup = InlineKeyboardMarkup(buttons) + if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + await message.reply_text( + text="ᴡʜᴇʀᴇ ᴅᴏ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴏᴘᴇɴ ꜱᴇᴛᴛɪɴɢꜱ ᴍᴇɴᴜ ? ⚙️", + reply_markup=InlineKeyboardMarkup(btn), + disable_web_page_preview=True, + parse_mode=enums.ParseMode.HTML, + reply_to_message_id=message.id + ) + else: + await message.reply_text( + text=f"ᴄʜᴀɴɢᴇ ʏᴏᴜʀ ꜱᴇᴛᴛɪɴɢꜱ ꜰᴏʀ {title} ᴀꜱ ʏᴏᴜ ᴡɪꜱʜ ⚙", + reply_markup=reply_markup, + disable_web_page_preview=True, + parse_mode=enums.ParseMode.HTML, + reply_to_message_id=message.id + ) + + + +@Client.on_message(filters.command('set_template')) +async def save_template(client, message): + sts = await message.reply("ᴄʜᴇᴄᴋɪɴɢ ᴛᴇᴍᴘʟᴀᴛᴇ...") + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"ʏᴏᴜ'ʀᴇ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ.\nᴜꜱᴇ /connect {message.chat.id} ɪɴ ᴘᴍ.") + chat_type = message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await message.reply_text("ᴍᴀᴋᴇ ꜱᴜʀᴇ ɪ'ᴍ ᴘʀᴇꜱᴇɴᴛ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ !!", quote=True) + return + else: + await message.reply_text("ɪ'ᴍ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘ !", quote=True) + return + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = message.chat.id + title = message.chat.title + + else: + return + + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + return + + if len(message.command) < 2: + return await sts.edit("ɴᴏ ɪɴᴘᴜᴛ !") + template = message.text.split(" ", 1)[1] + await save_group_settings(grp_id, 'template', template) + await sts.edit(f"✅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴄʜᴀɴɢᴇᴅ ᴛᴇᴍᴘʟᴀᴛᴇ ꜰᴏʀ {title} ᴛᴏ\n\n{template}") + + +@Client.on_message((filters.command(["request", "Request"]) | filters.regex("#request") | filters.regex("#Request")) & filters.group) +async def requests(bot, message): + if REQST_CHANNEL is None or SUPPORT_CHAT_ID is None: return # Must add REQST_CHANNEL and SUPPORT_CHAT_ID to use this feature + if message.reply_to_message and SUPPORT_CHAT_ID == message.chat.id: + chat_id = message.chat.id + reporter = str(message.from_user.id) + mention = message.from_user.mention + success = True + content = message.reply_to_message.text + try: + if REQST_CHANNEL is not None: + btn = [[ + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{message.reply_to_message.link}"), + InlineKeyboardButton('ꜱʜᴏᴡ ᴏᴘᴛɪᴏɴꜱ', callback_data=f'show_option#{reporter}') + ]] + reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"📝 ʀᴇǫᴜᴇꜱᴛ : {content}\n\n📚 ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ : {mention}\n📖 ʀᴇᴘᴏʀᴛᴇʀ ɪᴅ : {reporter}\n\n©️ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™", reply_markup=InlineKeyboardMarkup(btn)) + success = True + elif len(content) >= 3: + for admin in ADMINS: + btn = [[ + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{message.reply_to_message.link}"), + InlineKeyboardButton('ꜱʜᴏᴡ ᴏᴘᴛɪᴏɴꜱ', callback_data=f'show_option#{reporter}') + ]] + reported_post = await bot.send_message(chat_id=admin, text=f"📝 ʀᴇǫᴜᴇꜱᴛ : {content}\n\n📚 ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ : {mention}\n📖 ʀᴇᴘᴏʀᴛᴇʀ ɪᴅ : {reporter}\n\n©️ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™", reply_markup=InlineKeyboardMarkup(btn)) + success = True + else: + if len(content) < 3: + await message.reply_text("ʏᴏᴜ ᴍᴜꜱᴛ ᴛʏᴘᴇ ᴀʙᴏᴜᴛ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ [ᴍɪɴɪᴍᴜᴍ 3 ᴄʜᴀʀᴀᴄᴛᴇʀꜱ]. ʀᴇǫᴜᴇꜱᴛꜱ ᴄᴀɴ'ᴛ ʙᴇ ᴇᴍᴘᴛʏ.") + if len(content) < 3: + success = False + except Exception as e: + await message.reply_text(f"Error: {e}") + pass + + elif SUPPORT_CHAT_ID == message.chat.id: + chat_id = message.chat.id + reporter = str(message.from_user.id) + mention = message.from_user.mention + success = True + content = message.text + keywords = ["#request", "/request", "#Request", "/Request"] + for keyword in keywords: + if keyword in content: + content = content.replace(keyword, "") + try: + if REQST_CHANNEL is not None and len(content) >= 3: + btn = [[ + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{message.link}"), + InlineKeyboardButton('ꜱʜᴏᴡ ᴏᴘᴛɪᴏɴꜱ', callback_data=f'show_option#{reporter}') + ]] + reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"📝 ʀᴇǫᴜᴇꜱᴛ : {content}\n\n📚 ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ : {mention}\n📖 ʀᴇᴘᴏʀᴛᴇʀ ɪᴅ : {reporter}\n\n©️ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™", reply_markup=InlineKeyboardMarkup(btn)) + success = True + elif len(content) >= 3: + for admin in ADMINS: + btn = [[ + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{message.link}"), + InlineKeyboardButton('ꜱʜᴏᴡ ᴏᴘᴛɪᴏɴꜱ', callback_data=f'show_option#{reporter}') + ]] + reported_post = await bot.send_message(chat_id=admin, text=f"📝 ʀᴇǫᴜᴇꜱᴛ : {content}\n\n📚 ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ : {mention}\n📖 ʀᴇᴘᴏʀᴛᴇʀ ɪᴅ : {reporter}\n\n©️ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™", reply_markup=InlineKeyboardMarkup(btn)) + success = True + else: + if len(content) < 3: + await message.reply_text("ʏᴏᴜ ᴍᴜꜱᴛ ᴛʏᴘᴇ ᴀʙᴏᴜᴛ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ [ᴍɪɴɪᴍᴜᴍ 3 ᴄʜᴀʀᴀᴄᴛᴇʀꜱ]. ʀᴇǫᴜᴇꜱᴛꜱ ᴄᴀɴ'ᴛ ʙᴇ ᴇᴍᴘᴛʏ.") + if len(content) < 3: + success = False + except Exception as e: + await message.reply_text(f"Error: {e}") + pass + + elif SUPPORT_CHAT_ID == message.chat.id: + chat_id = message.chat.id + reporter = str(message.from_user.id) + mention = message.from_user.mention + success = True + content = message.text + keywords = ["#request", "/request", "#Request", "/Request"] + for keyword in keywords: + if keyword in content: + content = content.replace(keyword, "") + try: + if REQST_CHANNEL is not None and len(content) >= 3: + btn = [[ + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{message.link}"), + InlineKeyboardButton('ꜱʜᴏᴡ ᴏᴘᴛɪᴏɴꜱ', callback_data=f'show_option#{reporter}') + ]] + reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"📝 ʀᴇǫᴜᴇꜱᴛ : {content}\n\n📚 ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ : {mention}\n📖 ʀᴇᴘᴏʀᴛᴇʀ ɪᴅ : {reporter}\n\n©️ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™", reply_markup=InlineKeyboardMarkup(btn)) + success = True + elif len(content) >= 3: + for admin in ADMINS: + btn = [[ + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{message.link}"), + InlineKeyboardButton('ꜱʜᴏᴡ ᴏᴘᴛɪᴏɴꜱ', callback_data=f'show_option#{reporter}') + ]] + reported_post = await bot.send_message(chat_id=admin, text=f"📝 ʀᴇǫᴜᴇꜱᴛ : {content}\n\n📚 ʀᴇᴘᴏʀᴛᴇᴅ ʙʏ : {mention}\n📖 ʀᴇᴘᴏʀᴛᴇʀ ɪᴅ : {reporter}\n\n©️ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™", reply_markup=InlineKeyboardMarkup(btn)) + success = True + else: + if len(content) < 3: + await message.reply_text("ʏᴏᴜ ᴍᴜꜱᴛ ᴛʏᴘᴇ ᴀʙᴏᴜᴛ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ [ᴍɪɴɪᴍᴜᴍ 3 ᴄʜᴀʀᴀᴄᴛᴇʀꜱ]. ʀᴇǫᴜᴇꜱᴛꜱ ᴄᴀɴ'ᴛ ʙᴇ ᴇᴍᴘᴛʏ.") + if len(content) < 3: + success = False + except Exception as e: + await message.reply_text(f"Error: {e}") + pass + + else: + success = False + + if success: + '''if isinstance(REQST_CHANNEL, (int, str)): + channels = [REQST_CHANNEL] + elif isinstance(REQST_CHANNEL, list): + channels = REQST_CHANNEL + for channel in channels: + chat = await bot.get_chat(channel) + #chat = int(chat)''' + link = await bot.create_chat_invite_link(int(REQST_CHANNEL)) + btn = [[ + InlineKeyboardButton('ᴊᴏɪɴ ᴄʜᴀɴɴᴇʟ', url=link.invite_link), + InlineKeyboardButton('ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ', url=f"{reported_post.link}") + ]] + await message.reply_text("ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ ʜᴀꜱ ʙᴇᴇɴ ᴀᴅᴅᴇᴅ! ᴘʟᴇᴀꜱᴇ ᴡᴀɪᴛ ꜰᴏʀ ꜱᴏᴍᴇ ᴛɪᴍᴇ.\n\nᴊᴏɪɴ ᴄʜᴀɴɴᴇʟ ꜰɪʀꜱᴛ & ᴠɪᴇᴡ ʀᴇǫᴜᴇꜱᴛ.", reply_markup=InlineKeyboardMarkup(btn)) + +@Client.on_message(filters.command("send") & filters.user(ADMINS)) +async def send_msg(bot, message): + if message.reply_to_message: + target_id = message.text.split(" ", 1)[1] + out = "Users Saved In DB Are:\n\n" + success = False + try: + user = await bot.get_users(target_id) + users = await db.get_all_users() + async for usr in users: + out += f"{usr['id']}" + out += '\n' + if str(user.id) in str(out): + await message.reply_to_message.copy(int(user.id)) + success = True + else: + success = False + if success: + await message.reply_text(f"ʏᴏᴜʀ ᴍᴇꜱꜱᴀɢᴇ ʜᴀꜱ ʙᴇᴇɴ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ꜱᴇɴᴛ ᴛᴏ {user.mention}.") + else: + await message.reply_text("ᴛʜɪꜱ ᴜꜱᴇʀ ᴅɪᴅɴ'ᴛ ꜱᴛᴀʀᴛᴇᴅ ᴛʜɪꜱ ʙᴏᴛ ʏᴇᴛ !") + except Exception as e: + await message.reply_text(f"Error: {e}") + else: + await message.reply_text("ᴜꜱᴇ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴀꜱ ᴀ ʀᴇᴘʟʏ ᴛᴏ ᴀɴʏ ᴍᴇꜱꜱᴀɢᴇ ᴜꜱɪɴɢ ᴛʜᴇ ᴛᴀʀɢᴇᴛ ᴄʜᴀᴛ ɪᴅ. ꜰᴏʀ ᴇɢ: /send ᴜꜱᴇʀɪᴅ") + +@Client.on_message(filters.command("deletefiles") & filters.user(ADMINS)) + +async def deletemultiplefiles(bot, message): + + chat_type = message.chat.type + + if chat_type != enums.ChatType.PRIVATE: + + return await message.reply_text(f"ʜᴇʏ {message.from_user.mention},\nᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴡᴏɴ'ᴛ ᴡᴏʀᴋ ɪɴ ɢʀᴏᴜᴘꜱ !\nɪᴛ ᴏɴʟʏ ᴡᴏʀᴋꜱ ɪɴ ᴍʏ ᴘᴍ.") + + else: + + pass + + try: + + keyword = message.text.split(" ", 1)[1] + + except: + + return await message.reply_text(f"ʜᴇʏ {message.from_user.mention},\nɢɪᴠᴇ ᴍᴇ ᴀ ᴋᴇʏᴡᴏʀᴅ ᴀʟᴏɴɢ ᴡɪᴛʜ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ᴅᴇʟᴇᴛᴇ ꜰɪʟᴇꜱ.") + + btn = [[ + + InlineKeyboardButton("⚠️ ʏᴇꜱ, ᴄᴏɴᴛɪɴᴜᴇ ⚠️", callback_data=f"killfilesdq#{keyword}") + + ],[ + + InlineKeyboardButton("❌ ɴᴏ, ᴀʙᴏʀᴛ ᴏᴘᴇʀᴀᴛɪᴏɴ ❌", callback_data="close_data") + + ]] + + await message.reply_text( + + text="ᴀʀᴇ ʏᴏᴜ ꜱᴜʀᴇ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ ?\nɴᴏᴛᴇ : ᴛʜɪꜱ ᴄᴏᴜʟᴅ ʙᴇ ᴀ ᴅᴇꜱᴛʀᴜᴄᴛɪᴠᴇ ᴅᴇꜱɪᴄɪᴏɴ.", + + reply_markup=InlineKeyboardMarkup(btn), + + parse_mode=enums.ParseMode.HTML + + ) + +@Client.on_message(filters.command("shortlink")) +async def shortlink(bot, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"ʏᴏᴜ'ʀᴇ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ, ᴛᴜʀɴ ᴏꜰꜰ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ ᴀɴᴅ ᴛʀʏ ᴛʜɪꜱ ᴀɢᴀɪɴ ᴄᴏᴍᴍᴀɴᴅ.") + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + return await message.reply_text(f"ʜᴇʏ {message.from_user.mention}, ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴏɴʟʏ ᴡᴏʀᴋꜱ ɪɴ ɢʀᴏᴜᴘꜱ !") + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grpid = message.chat.id + title = message.chat.title + else: + return + data = message.text + userid = message.from_user.id + user = await bot.get_chat_member(grpid, userid) + if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS: + return await message.reply_text("ʏᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ ᴀᴄᴄᴇꜱꜱ ᴛᴏ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ !\nᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴏɴʟʏ ᴡᴏʀᴋꜱ ꜰᴏʀ ɢʀᴏᴜᴘ ᴀᴅᴍɪɴꜱ.") + else: + pass + try: + command, shortlink_url, api = data.split(" ") + except: + return await message.reply_text("ᴄᴏᴍᴍᴀɴᴅ ɪɴᴄᴏᴍᴘʟᴇᴛᴇ !\nɢɪᴠᴇ ᴍᴇ ᴄᴏᴍᴍᴀɴᴅ ᴀʟᴏɴɢ ᴡɪᴛʜ ꜱʜᴏʀᴛɴᴇʀ ᴡᴇʙꜱɪᴛᴇ ᴀɴᴅ ᴀᴘɪ.\n\nꜰᴏʀᴍᴀᴛ : /shortlink krishnalink.com c8dacdff6e91a8e4b4f093fdb4d8ae31bc273c1a") + reply = await message.reply_text("ᴘʟᴇᴀꜱᴇ ᴡᴀɪᴛ...") + shortlink_url = re.sub(r"https?://?", "", shortlink_url) + shortlink_url = re.sub(r"[:/]", "", shortlink_url) + await save_group_settings(grpid, 'shortlink', shortlink_url) + await save_group_settings(grpid, 'shortlink_api', api) + await save_group_settings(grpid, 'is_shortlink', True) + await reply.edit_text(f"✅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴀᴅᴅᴇᴅ ꜱʜᴏʀᴛʟɪɴᴋ ꜰᴏʀ {title}.\n\nꜱʜᴏʀᴛʟɪɴᴋ ᴡᴇʙꜱɪᴛᴇ : {shortlink_url}\nꜱʜᴏʀᴛʟɪɴᴋ ᴀᴘɪ : {api}") + +@Client.on_message(filters.command("setshortlinkoff") & filters.user(ADMINS)) +async def offshortlink(bot, message): + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + return await message.reply_text("ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴡᴏʀᴋꜱ ᴏɴʟʏ ɪɴ ɢʀᴏᴜᴘꜱ !") + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grpid = message.chat.id + title = message.chat.title + else: + return + await save_group_settings(grpid, 'is_shortlink', False) + ENABLE_SHORTLINK = False + return await message.reply_text("ꜱʜᴏʀᴛʟɪɴᴋ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅɪꜱᴀʙʟᴇᴅ.") + +@Client.on_message(filters.command("setshortlinkon") & filters.user(ADMINS)) +async def onshortlink(bot, message): + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + return await message.reply_text("ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴡᴏʀᴋꜱ ᴏɴʟʏ ɪɴ ɢʀᴏᴜᴘꜱ !") + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grpid = message.chat.id + title = message.chat.title + else: + return + await save_group_settings(grpid, 'is_shortlink', True) + ENABLE_SHORTLINK = True + return await message.reply_text("ꜱʜᴏʀᴛʟɪɴᴋ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴇɴᴀʙʟᴇᴅ.") + + +@Client.on_message(filters.command("shortlink_info")) +async def ginfo(bot, message): + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + return await message.reply_text(f"{message.from_user.mention},\n\nᴜꜱᴇ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ.") + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grpid = message.chat.id + title = message.chat.title + else: + return + chat_id=message.chat.id + userid = message.from_user.id + user = await bot.get_chat_member(grpid, userid) +# if 'shortlink' in settings.keys(): +# su = settings['shortlink'] +# sa = settings['shortlink_api'] +# else: +# return await message.reply_text("Shortener Url Not Connected\n\nYou can Connect Using /shortlink command") +# if 'tutorial' in settings.keys(): +# st = settings['tutorial'] +# else: +# return await message.reply_text("Tutorial Link Not Connected\n\nYou can Connect Using /set_tutorial command") + if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS: + return await message.reply_text("ᴏɴʟʏ ɢʀᴏᴜᴘ ᴏᴡɴᴇʀ ᴏʀ ᴀᴅᴍɪɴ ᴄᴀɴ ᴜꜱᴇ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ !") + else: + settings = await get_settings(chat_id) #fetching settings for group + if 'shortlink' in settings.keys() and 'tutorial' in settings.keys(): + su = settings['shortlink'] + sa = settings['shortlink_api'] + st = settings['tutorial'] + return await message.reply_text(f"ᴄᴜʀʀᴇɴᴛ ꜱᴛᴀᴛᴜꜱ 📊\n\nᴡᴇʙꜱɪᴛᴇ : {su}\n\nᴀᴘɪ : {sa}\n\nᴛᴜᴛᴏʀɪᴀʟ : {st}", disable_web_page_preview=True) + elif 'shortlink' in settings.keys() and 'tutorial' not in settings.keys(): + su = settings['shortlink'] + sa = settings['shortlink_api'] + return await message.reply_text(f"ᴄᴜʀʀᴇɴᴛ ꜱᴛᴀᴛᴜꜱ 📊\n\nᴡᴇʙꜱɪᴛᴇ : {su}\n\nᴀᴘɪ : {sa}\n\nᴜꜱᴇ /set_tutorial ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ꜱᴇᴛ ʏᴏᴜʀ ᴛᴜᴛᴏʀɪᴀʟ.") + elif 'shortlink' not in settings.keys() and 'tutorial' in settings.keys(): + st = settings['tutorial'] + return await message.reply_text(f"ᴛᴜᴛᴏʀɪᴀʟ : {st}\n\nᴜꜱᴇ /shortlink ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ꜱʜᴏʀᴛɴᴇʀ") + else: + return await message.reply_text("ꜱʜᴏʀᴛɴᴇʀ ᴀɴᴅ ᴛᴜᴛᴏʀɪᴀʟ ᴀʀᴇ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ.\n\nᴄʜᴇᴄᴋ /set_tutorial ᴀɴᴅ /shortlink ᴄᴏᴍᴍᴀɴᴅ.") + +@Client.on_message(filters.command("set_tutorial")) +async def settutorial(bot, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"ʏᴏᴜ'ʀᴇ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ, ᴛᴜʀɴ ᴏꜰꜰ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ ᴀɴᴅ ᴛʀʏ ᴀɢᴀɪɴ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ.") + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + return await message.reply_text("ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴡᴏʀᴋꜱ ᴏɴʟʏ ɪɴ ɢʀᴏᴜᴘꜱ !") + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grpid = message.chat.id + title = message.chat.title + else: + return + userid = message.from_user.id + user = await bot.get_chat_member(grpid, userid) + if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS: + return + else: + pass + if len(message.command) == 1: + return await message.reply("ɢɪᴠᴇ ᴍᴇ ᴀ ᴛᴜᴛᴏʀɪᴀʟ ʟɪɴᴋ ᴀʟᴏɴɢ ᴡɪᴛʜ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ.\n\nᴜꜱᴀɢᴇ : /set_tutorial https://t.me/HowToOpenHP") + elif len(message.command) == 2: + reply = await message.reply_text("ᴘʟᴇᴀꜱᴇ ᴡᴀɪᴛ...") + tutorial = message.command[1] + await save_group_settings(grpid, 'tutorial', tutorial) + await save_group_settings(grpid, 'is_tutorial', True) + await reply.edit_text(f"✅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴀᴅᴅᴇᴅ ᴛᴜᴛᴏʀɪᴀʟ\n\nʏᴏᴜʀ ɢʀᴏᴜᴘ : {title}\n\nʏᴏᴜʀ ᴛᴜᴛᴏʀɪᴀʟ : {tutorial}") + else: + return await message.reply("ʏᴏᴜ ᴇɴᴛᴇʀᴇᴅ ɪɴᴄᴏʀʀᴇᴄᴛ ꜰᴏʀᴍᴀᴛ !\nᴄᴏʀʀᴇᴄᴛ ꜰᴏʀᴍᴀᴛ : /set_tutorial https://t.me/HowToOpenHP") + +@Client.on_message(filters.command("remove_tutorial")) +async def removetutorial(bot, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"ʏᴏᴜ'ʀᴇ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ, ᴛᴜʀɴ ᴏꜰꜰ ᴀɴᴏɴʏᴍᴏᴜꜱ ᴀᴅᴍɪɴ ᴀɴᴅ ᴛʀʏ ᴀɢᴀɪɴ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ.") + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + return await message.reply_text("ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ᴏɴʟʏ ᴡᴏʀᴋꜱ ɪɴ ɢʀᴏᴜᴘꜱ !") + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grpid = message.chat.id + title = message.chat.title + else: + return + userid = message.from_user.id + user = await bot.get_chat_member(grpid, userid) + if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS: + return + else: + pass + reply = await message.reply_text("ᴘʟᴇᴀꜱᴇ ᴡᴀɪᴛ...") + await save_group_settings(grpid, 'is_tutorial', False) + await reply.edit_text(f"ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ʀᴇᴍᴏᴠᴇᴅ ᴛᴜᴛᴏʀɪᴀʟ ʟɪɴᴋ ✅") + +@Client.on_message(filters.command("restart") & filters.user(ADMINS)) +async def stop_button(bot, message): + msg = await bot.send_message(text="ʙᴏᴛ ɪꜱ ʀᴇꜱᴛᴀʀᴛɪɴɢ", chat_id=message.chat.id) + await asyncio.sleep(3) + await msg.edit("ʙᴏᴛ ɪꜱ ʀᴇꜱᴛᴀʀᴛᴇᴅ") + os.execl(sys.executable, sys.executable, *sys.argv) diff --git a/plugins/connection.py b/plugins/connection.py new file mode 100644 index 0000000000000000000000000000000000000000..6011dd1390a0d93e76bb241733d6d0a286a96f85 --- /dev/null +++ b/plugins/connection.py @@ -0,0 +1,147 @@ +from pyrogram import filters, Client, enums +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from database.connections_mdb import add_connection, all_connections, if_active, delete_connection +from info import ADMINS +import logging + +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) + + +@Client.on_message((filters.private | filters.group) & filters.command('connect')) +async def addconnection(client, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") + chat_type = message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + try: + cmd, group_id = message.text.split(" ", 1) + except: + await message.reply_text( + "Enter in correct format!\n\n" + "/connect groupid\n\n" + "Get your Group id by adding this bot to your group and use /id", + quote=True + ) + return + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + group_id = message.chat.id + + try: + st = await client.get_chat_member(group_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and userid not in ADMINS + ): + await message.reply_text("You should be an admin in Given group!", quote=True) + return + except Exception as e: + logger.exception(e) + await message.reply_text( + "Invalid Group ID!\n\nIf correct, Make sure I'm present in your group!!", + quote=True, + ) + + return + try: + st = await client.get_chat_member(group_id, "me") + if st.status == enums.ChatMemberStatus.ADMINISTRATOR: + ttl = await client.get_chat(group_id) + title = ttl.title + + addcon = await add_connection(str(group_id), str(userid)) + if addcon: + await message.reply_text( + f"Successfully connected to **{title}**\nNow manage your group from my pm !", + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + await client.send_message( + userid, + f"Connected to **{title}** !", + parse_mode=enums.ParseMode.MARKDOWN + ) + else: + await message.reply_text( + "You're already connected to this chat!", + quote=True + ) + else: + await message.reply_text("Add me as an admin in group", quote=True) + except Exception as e: + logger.exception(e) + await message.reply_text('Some error occurred! Try again later.', quote=True) + return + + +@Client.on_message((filters.private | filters.group) & filters.command('disconnect')) +async def deleteconnection(client, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") + chat_type = message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + await message.reply_text("Run /connections to view or disconnect from groups!", quote=True) + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + group_id = message.chat.id + + st = await client.get_chat_member(group_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + return + + delcon = await delete_connection(str(userid), str(group_id)) + if delcon: + await message.reply_text("Successfully disconnected from this chat", quote=True) + else: + await message.reply_text("This chat isn't connected to me!\nDo /connect to connect.", quote=True) + + +@Client.on_message(filters.private & filters.command(["connections"])) +async def connections(client, message): + userid = message.from_user.id + + groupids = await all_connections(str(userid)) + if groupids is None: + await message.reply_text( + "There are no active connections!! Connect to some groups first.", + quote=True + ) + return + buttons = [] + for groupid in groupids: + try: + ttl = await client.get_chat(int(groupid)) + title = ttl.title + active = await if_active(str(userid), str(groupid)) + act = " - ACTIVE" if active else "" + buttons.append( + [ + InlineKeyboardButton( + text=f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}" + ) + ] + ) + except: + pass + if buttons: + await message.reply_text( + "Your connected group details ;\n\n", + reply_markup=InlineKeyboardMarkup(buttons), + quote=True + ) + else: + await message.reply_text( + "There are no active connections!! Connect to some groups first.", + quote=True + ) diff --git a/plugins/files_delete.py b/plugins/files_delete.py new file mode 100644 index 0000000000000000000000000000000000000000..714223d4155d9b1d78562d75a09b37109691ea20 --- /dev/null +++ b/plugins/files_delete.py @@ -0,0 +1,48 @@ +import re +import logging +from pyrogram import Client, filters +from info import DELETE_CHANNELS +from database.ia_filterdb import Media, unpack_new_file_id + +logger = logging.getLogger(__name__) + +media_filter = filters.document | filters.video | filters.audio + + +@Client.on_message(filters.chat(DELETE_CHANNELS) & media_filter) +async def deletemultiplemedia(bot, message): + """Delete Multiple files from database""" + + for file_type in ("document", "video", "audio"): + media = getattr(message, file_type, None) + if media is not None: + break + else: + return + + file_id, file_ref = unpack_new_file_id(media.file_id) + + result = await Media.collection.delete_one({ + '_id': file_id, + }) + if result.deleted_count: + logger.info('File is successfully deleted from database.') + else: + file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name)) + result = await Media.collection.delete_many({ + 'file_name': file_name, + 'file_size': media.file_size, + 'mime_type': media.mime_type + }) + if result.deleted_count: + logger.info('File is successfully deleted from database.') + else: + result = await Media.collection.delete_many({ + 'file_name': media.file_name, + 'file_size': media.file_size, + 'mime_type': media.mime_type + }) + if result.deleted_count: + logger.info('File is successfully deleted from database.') + else: + logger.info('File not found in database.') diff --git a/plugins/filters.py b/plugins/filters.py new file mode 100644 index 0000000000000000000000000000000000000000..b76af6bbfccf57d1685d980e6bc5ffcbb1854717 --- /dev/null +++ b/plugins/filters.py @@ -0,0 +1,271 @@ +import io +from pyrogram import filters, Client, enums +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from database.filters_mdb import( + add_filter, + get_filters, + delete_filter, + count_filters +) + +from database.connections_mdb import active_connection +from utils import get_file_id, parser, split_quotes +from info import ADMINS + + +@Client.on_message(filters.command(['filter', 'add']) & filters.incoming) +async def addfilter(client, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") + chat_type = message.chat.type + args = message.text.html.split(None, 1) + + if chat_type == enums.ChatType.PRIVATE: + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await message.reply_text("Make sure I'm present in your group!!", quote=True) + return + else: + await message.reply_text("I'm not connected to any groups!", quote=True) + return + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = message.chat.id + title = message.chat.title + + else: + return + + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + return + + + if len(args) < 2: + await message.reply_text("Command Incomplete :(", quote=True) + return + + extracted = split_quotes(args[1]) + text = extracted[0].lower() + + if not message.reply_to_message and len(extracted) < 2: + await message.reply_text("Add some content to save your filter!", quote=True) + return + + if (len(extracted) >= 2) and not message.reply_to_message: + reply_text, btn, alert = parser(extracted[1], text) + fileid = None + if not reply_text: + await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True) + return + + elif message.reply_to_message and message.reply_to_message.reply_markup: + try: + rm = message.reply_to_message.reply_markup + btn = rm.inline_keyboard + msg = get_file_id(message.reply_to_message) + if msg: + fileid = msg.file_id + reply_text = message.reply_to_message.caption.html + else: + reply_text = message.reply_to_message.text.html + fileid = None + alert = None + except: + reply_text = "" + btn = "[]" + fileid = None + alert = None + + elif message.reply_to_message and message.reply_to_message.media: + try: + msg = get_file_id(message.reply_to_message) + fileid = msg.file_id if msg else None + reply_text, btn, alert = parser(extracted[1], text) if message.reply_to_message.sticker else parser(message.reply_to_message.caption.html, text) + except: + reply_text = "" + btn = "[]" + alert = None + elif message.reply_to_message and message.reply_to_message.text: + try: + fileid = None + reply_text, btn, alert = parser(message.reply_to_message.text.html, text) + except: + reply_text = "" + btn = "[]" + alert = None + else: + return + + await add_filter(grp_id, text, reply_text, btn, fileid, alert) + + await message.reply_text( + f"Filter for `{text}` added in **{title}**", + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + + +@Client.on_message(filters.command(['viewfilters', 'filters']) & filters.incoming) +async def get_all(client, message): + + chat_type = message.chat.type + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") + if chat_type == enums.ChatType.PRIVATE: + userid = message.from_user.id + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await message.reply_text("Make sure I'm present in your group!!", quote=True) + return + else: + await message.reply_text("I'm not connected to any groups!", quote=True) + return + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = message.chat.id + title = message.chat.title + + else: + return + + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + return + + texts = await get_filters(grp_id) + count = await count_filters(grp_id) + if count: + filterlist = f"Total number of filters in **{title}** : {count}\n\n" + + for text in texts: + keywords = " × `{}`\n".format(text) + + filterlist += keywords + + if len(filterlist) > 4096: + with io.BytesIO(str.encode(filterlist.replace("`", ""))) as keyword_file: + keyword_file.name = "keywords.txt" + await message.reply_document( + document=keyword_file, + quote=True + ) + return + else: + filterlist = f"There are no active filters in **{title}**" + + await message.reply_text( + text=filterlist, + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + +@Client.on_message(filters.command('del') & filters.incoming) +async def deletefilter(client, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") + chat_type = message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await message.reply_text("Make sure I'm present in your group!!", quote=True) + return + else: + await message.reply_text("I'm not connected to any groups!", quote=True) + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = message.chat.id + title = message.chat.title + + else: + return + + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + return + + try: + cmd, text = message.text.split(" ", 1) + except: + await message.reply_text( + "Mention the filtername which you wanna delete!\n\n" + "/del filtername\n\n" + "Use /viewfilters to view all available filters", + quote=True + ) + return + + query = text.lower() + + await delete_filter(message, query, grp_id) + + +@Client.on_message(filters.command('delall') & filters.incoming) +async def delallconfirm(client, message): + userid = message.from_user.id if message.from_user else None + if not userid: + return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") + chat_type = message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await message.reply_text("Make sure I'm present in your group!!", quote=True) + return + else: + await message.reply_text("I'm not connected to any groups!", quote=True) + return + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = message.chat.id + title = message.chat.title + + else: + return + + st = await client.get_chat_member(grp_id, userid) + if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): + await message.reply_text( + f"This will delete all filters from '{title}'.\nDo you want to continue??", + reply_markup=InlineKeyboardMarkup([ + [InlineKeyboardButton(text="YES",callback_data="delallconfirm")], + [InlineKeyboardButton(text="CANCEL",callback_data="delallcancel")] + ]), + quote=True + ) diff --git a/plugins/genlink.py b/plugins/genlink.py new file mode 100644 index 0000000000000000000000000000000000000000..1139d108eba43e5d488df5d3ebab485bc1e08654 --- /dev/null +++ b/plugins/genlink.py @@ -0,0 +1,125 @@ +import re +from pyrogram import filters, Client, enums +from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified +from info import ADMINS, LOG_CHANNEL, FILE_STORE_CHANNEL, PUBLIC_FILE_STORE +from database.ia_filterdb import unpack_new_file_id +from utils import temp +import re +import os +import json +import base64 +import logging + +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) + +async def allowed(_, __, message): + if PUBLIC_FILE_STORE: + return True + if message.from_user and message.from_user.id in ADMINS: + return True + return False + +@Client.on_message(filters.command(['link', 'plink']) & filters.create(allowed)) +async def gen_link_s(bot, message): + replied = message.reply_to_message + if not replied: + return await message.reply('Reply to a message to get a shareable link.') + file_type = replied.media + if file_type not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: + return await message.reply("Reply to a supported media") + if message.has_protected_content and message.chat.id not in ADMINS: + return await message.reply("okDa") + file_id, ref = unpack_new_file_id((getattr(replied, file_type.value)).file_id) + string = 'filep_' if message.text.lower().strip() == "/plink" else 'file_' + string += file_id + outstr = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") + await message.reply(f"Here is your Link:\nhttps://t.me/{temp.U_NAME}?start={outstr}") + + +@Client.on_message(filters.command(['batch', 'pbatch']) & filters.create(allowed)) +async def gen_link_batch(bot, message): + if " " not in message.text: + return await message.reply("Use correct format.\nExample /batch https://t.me/HP_MOVIES_WORLD/10 https://t.me/HP_MOVIES_WORLD/20.") + links = message.text.strip().split(" ") + if len(links) != 3: + return await message.reply("Use correct format.\nExample /batch https://t.me/HP_MOVIES_WORLD/10 https://t.me/HP_MOVIES_WORLD/20.") + cmd, first, last = links + regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") + match = regex.match(first) + if not match: + return await message.reply('Invalid link') + f_chat_id = match.group(4) + f_msg_id = int(match.group(5)) + if f_chat_id.isnumeric(): + f_chat_id = int(("-100" + f_chat_id)) + + match = regex.match(last) + if not match: + return await message.reply('Invalid link') + l_chat_id = match.group(4) + l_msg_id = int(match.group(5)) + if l_chat_id.isnumeric(): + l_chat_id = int(("-100" + l_chat_id)) + + if f_chat_id != l_chat_id: + return await message.reply("Chat ids not matched.") + try: + chat_id = (await bot.get_chat(f_chat_id)).id + except ChannelInvalid: + return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') + except (UsernameInvalid, UsernameNotModified): + return await message.reply('Invalid Link specified.') + except Exception as e: + return await message.reply(f'Errors - {e}') + + sts = await message.reply("Generating link for your message.\nThis may take time depending upon number of messages") + if chat_id in FILE_STORE_CHANNEL: + string = f"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}" + b_64 = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") + return await sts.edit(f"Here is your link https://t.me/{temp.U_NAME}?start=DSTORE-{b_64}") + + FRMT = "Generating Link...\nTotal Messages: `{total}`\nDone: `{current}`\nRemaining: `{rem}`\nStatus: `{sts}`" + + outlist = [] + + # file store without db channel + og_msg = 0 + tot = 0 + async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id): + tot += 1 + if msg.empty or msg.service: + continue + if not msg.media: + # only media messages supported. + continue + try: + file_type = msg.media + file = getattr(msg, file_type.value) + caption = getattr(msg, 'caption', '') + if caption: + caption = caption.html + if file: + file = { + "file_id": file.file_id, + "caption": caption, + "title": getattr(file, "file_name", ""), + "size": file.file_size, + "protect": cmd.lower().strip() == "/pbatch", + } + + og_msg +=1 + outlist.append(file) + except: + pass + if not og_msg % 20: + try: + 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")) + except: + pass + with open(f"batchmode_{message.from_user.id}.json", "w+") as out: + json.dump(outlist, out) + post = await bot.send_document(LOG_CHANNEL, f"batchmode_{message.from_user.id}.json", file_name="Batch.json", caption="⚠️Generated for filestore.") + os.remove(f"batchmode_{message.from_user.id}.json") + file_id, ref = unpack_new_file_id(post.document.file_id) + await sts.edit(f"Here is your link\nContains `{og_msg}` files.\n https://t.me/{temp.U_NAME}?start=BATCH-{file_id}") diff --git a/plugins/gfilters.py b/plugins/gfilters.py new file mode 100644 index 0000000000000000000000000000000000000000..f1de56312f3c3f6f3ca64e5a733a85f2ac2ab025 --- /dev/null +++ b/plugins/gfilters.py @@ -0,0 +1,140 @@ +import io +from pyrogram import filters, Client, enums +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from database.gfilters_mdb import( + add_gfilter, + get_gfilters, + delete_gfilter, + count_gfilters +) + +from database.connections_mdb import active_connection +from utils import get_file_id, gfilterparser, split_quotes +from info import ADMINS + + +@Client.on_message(filters.command(['gfilter', 'addg']) & filters.incoming & filters.user(ADMINS)) +async def addgfilter(client, message): + args = message.text.html.split(None, 1) + + if len(args) < 2: + await message.reply_text("Command Incomplete :(", quote=True) + return + + extracted = split_quotes(args[1]) + text = extracted[0].lower() + + if not message.reply_to_message and len(extracted) < 2: + await message.reply_text("Add some content to save your filter!", quote=True) + return + + if (len(extracted) >= 2) and not message.reply_to_message: + reply_text, btn, alert = gfilterparser(extracted[1], text) + fileid = None + if not reply_text: + await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True) + return + + elif message.reply_to_message and message.reply_to_message.reply_markup: + try: + rm = message.reply_to_message.reply_markup + btn = rm.inline_keyboard + msg = get_file_id(message.reply_to_message) + if msg: + fileid = msg.file_id + reply_text = message.reply_to_message.caption.html + else: + reply_text = message.reply_to_message.text.html + fileid = None + alert = None + except: + reply_text = "" + btn = "[]" + fileid = None + alert = None + + elif message.reply_to_message and message.reply_to_message.media: + try: + msg = get_file_id(message.reply_to_message) + fileid = msg.file_id if msg else None + reply_text, btn, alert = gfilterparser(extracted[1], text) if message.reply_to_message.sticker else gfilterparser(message.reply_to_message.caption.html, text) + except: + reply_text = "" + btn = "[]" + alert = None + elif message.reply_to_message and message.reply_to_message.text: + try: + fileid = None + reply_text, btn, alert = gfilterparser(message.reply_to_message.text.html, text) + except: + reply_text = "" + btn = "[]" + alert = None + else: + return + + await add_gfilter('gfilters', text, reply_text, btn, fileid, alert) + + await message.reply_text( + f"GFilter for `{text}` added", + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + + +@Client.on_message(filters.command(['viewgfilters', 'gfilters']) & filters.incoming & filters.user(ADMINS)) +async def get_all_gfilters(client, message): + texts = await get_gfilters('gfilters') + count = await count_gfilters('gfilters') + if count: + gfilterlist = f"Total number of gfilters : {count}\n\n" + + for text in texts: + keywords = " × `{}`\n".format(text) + + gfilterlist += keywords + + if len(gfilterlist) > 4096: + with io.BytesIO(str.encode(gfilterlist.replace("`", ""))) as keyword_file: + keyword_file.name = "keywords.txt" + await message.reply_document( + document=keyword_file, + quote=True + ) + return + else: + gfilterlist = f"There are no active gfilters." + + await message.reply_text( + text=gfilterlist, + quote=True, + parse_mode=enums.ParseMode.MARKDOWN + ) + +@Client.on_message(filters.command('delg') & filters.incoming & filters.user(ADMINS)) +async def deletegfilter(client, message): + try: + cmd, text = message.text.split(" ", 1) + except: + await message.reply_text( + "Mention the gfiltername which you wanna delete!\n\n" + "/delg gfiltername\n\n" + "Use /viewgfilters to view all available gfilters", + quote=True + ) + return + + query = text.lower() + + await delete_gfilter(message, query, 'gfilters') + +@Client.on_message(filters.command('delallg') & filters.user(ADMINS)) +async def delallgfilters(client, message): + await message.reply_text( + f"Do you want to continue??", + reply_markup=InlineKeyboardMarkup([ + [InlineKeyboardButton(text="YES",callback_data="gfiltersdeleteallconfirm")], + [InlineKeyboardButton(text="CANCEL",callback_data="gfiltersdeleteallcancel")] + ]), + quote=True + ) diff --git a/plugins/index.py b/plugins/index.py new file mode 100644 index 0000000000000000000000000000000000000000..df5cf10047b9b06926b94c5f692d9898abde6f08 --- /dev/null +++ b/plugins/index.py @@ -0,0 +1,185 @@ +import logging +import asyncio +from pyrogram import Client, filters, enums +from pyrogram.errors import FloodWait +from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, ChatAdminRequired, UsernameInvalid, UsernameNotModified +from info import ADMINS +from info import INDEX_REQ_CHANNEL as LOG_CHANNEL +from database.ia_filterdb import save_file +from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton +from utils import temp +import re +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) +lock = asyncio.Lock() + + +@Client.on_callback_query(filters.regex(r'^index')) +async def index_files(bot, query): + if query.data.startswith('index_cancel'): + temp.CANCEL = True + return await query.answer("Cancelling Indexing") + _, raju, chat, lst_msg_id, from_user = query.data.split("#") + if raju == 'reject': + await query.message.delete() + await bot.send_message(int(from_user), + f'Your Submission for indexing {chat} has been decliened by our moderators.', + reply_to_message_id=int(lst_msg_id)) + return + + if lock.locked(): + return await query.answer('Wait until previous process complete.', show_alert=True) + msg = query.message + + await query.answer('Processing...⏳', show_alert=True) + if int(from_user) not in ADMINS: + await bot.send_message(int(from_user), + f'Your Submission for indexing {chat} has been accepted by our moderators and will be added soon.', + reply_to_message_id=int(lst_msg_id)) + await msg.edit( + "Starting Indexing", + reply_markup=InlineKeyboardMarkup( + [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]] + ) + ) + try: + chat = int(chat) + except: + chat = chat + await index_files_to_db(int(lst_msg_id), chat, msg, bot) + + +@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) +async def send_for_index(bot, message): + if message.text: + regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") + match = regex.match(message.text) + if not match: + return await message.reply('Invalid link') + chat_id = match.group(4) + last_msg_id = int(match.group(5)) + if chat_id.isnumeric(): + chat_id = int(("-100" + chat_id)) + elif message.forward_from_chat.type == enums.ChatType.CHANNEL: + last_msg_id = message.forward_from_message_id + chat_id = message.forward_from_chat.username or message.forward_from_chat.id + else: + return + try: + await bot.get_chat(chat_id) + except ChannelInvalid: + return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') + except (UsernameInvalid, UsernameNotModified): + return await message.reply('Invalid Link specified.') + except Exception as e: + logger.exception(e) + return await message.reply(f'Errors - {e}') + try: + k = await bot.get_messages(chat_id, last_msg_id) + except: + return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') + if k.empty: + return await message.reply('This may be group and iam not a admin of the group.') + + if message.from_user.id in ADMINS: + buttons = [ + [ + InlineKeyboardButton('Yes', + callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}') + ], + [ + InlineKeyboardButton('close', callback_data='close_data'), + ] + ] + reply_markup = InlineKeyboardMarkup(buttons) + return await message.reply( + f'Do you Want To Index This Channel/ Group ?\n\nChat ID/ Username: {chat_id}\nLast Message ID: {last_msg_id}', + reply_markup=reply_markup) + + if type(chat_id) is int: + try: + link = (await bot.create_chat_invite_link(chat_id)).invite_link + except ChatAdminRequired: + return await message.reply('Make sure iam an admin in the chat and have permission to invite users.') + else: + link = f"@{message.forward_from_chat.username}" + buttons = [ + [ + InlineKeyboardButton('Accept Index', + callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}') + ], + [ + InlineKeyboardButton('Reject Index', + callback_data=f'index#reject#{chat_id}#{message.id}#{message.from_user.id}'), + ] + ] + reply_markup = InlineKeyboardMarkup(buttons) + await bot.send_message(LOG_CHANNEL, + f'#IndexRequest\n\nBy : {message.from_user.mention} ({message.from_user.id})\nChat ID/ Username - {chat_id}\nLast Message ID - {last_msg_id}\nInviteLink - {link}', + reply_markup=reply_markup) + await message.reply('ThankYou For the Contribution, Wait For My Moderators to verify the files.') + + +@Client.on_message(filters.command('setskip') & filters.user(ADMINS)) +async def set_skip_number(bot, message): + if ' ' in message.text: + _, skip = message.text.split(" ") + try: + skip = int(skip) + except: + return await message.reply("Skip number should be an integer.") + await message.reply(f"Successfully set SKIP number as {skip}") + temp.CURRENT = int(skip) + else: + await message.reply("Give me a skip number") + + +async def index_files_to_db(lst_msg_id, chat, msg, bot): + total_files = 0 + duplicate = 0 + errors = 0 + deleted = 0 + no_media = 0 + unsupported = 0 + async with lock: + try: + current = temp.CURRENT + temp.CANCEL = False + async for message in bot.iter_messages(chat, lst_msg_id, temp.CURRENT): + if temp.CANCEL: + await msg.edit(f"Successfully Cancelled!!\n\nSaved {total_files} files to dataBase!\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media + unsupported}(Unsupported Media - `{unsupported}` )\nErrors Occurred: {errors}") + break + current += 1 + if current % 20 == 0: + can = [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]] + reply = InlineKeyboardMarkup(can) + await msg.edit_text( + text=f"Total messages fetched: {current}\nTotal messages saved: {total_files}\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media + unsupported}(Unsupported Media - `{unsupported}` )\nErrors Occurred: {errors}", + reply_markup=reply) + if message.empty: + deleted += 1 + continue + elif not message.media: + no_media += 1 + continue + elif message.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: + unsupported += 1 + continue + media = getattr(message, message.media.value, None) + if not media: + unsupported += 1 + continue + media.file_type = message.media.value + media.caption = message.caption + aynav, vnay = await save_file(media) + if aynav: + total_files += 1 + elif vnay == 0: + duplicate += 1 + elif vnay == 2: + errors += 1 + except Exception as e: + logger.exception(e) + await msg.edit(f'Error: {e}') + else: + await msg.edit(f'Succesfully saved {total_files} to dataBase!\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media + unsupported}(Unsupported Media - `{unsupported}` )\nErrors Occurred: {errors}') diff --git a/plugins/inline.py b/plugins/inline.py new file mode 100644 index 0000000000000000000000000000000000000000..7b5abcf9c0410c2108f48a85fe17ca06167b982c --- /dev/null +++ b/plugins/inline.py @@ -0,0 +1,115 @@ +import logging +from pyrogram import Client, emoji, filters +from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultCachedDocument, InlineQuery +from database.ia_filterdb import get_search_results +from utils import is_req_subscribed, get_size, temp +from info import CACHE_TIME, AUTH_USERS, AUTH_CHANNEL, CUSTOM_FILE_CAPTION +from database.connections_mdb import active_connection + +logger = logging.getLogger(__name__) +cache_time = 0 if AUTH_USERS or AUTH_CHANNEL else CACHE_TIME + +async def inline_users(query: InlineQuery): + if AUTH_USERS: + if query.from_user and query.from_user.id in AUTH_USERS: + return True + else: + return False + if query.from_user and query.from_user.id not in temp.BANNED_USERS: + return True + return False + +@Client.on_inline_query() +async def answer(bot, query): + """Show search results for given inline query""" + chat_id = await active_connection(str(query.from_user.id)) + + if not await inline_users(query): + await query.answer(results=[], + cache_time=0, + switch_pm_text='okDa', + switch_pm_parameter="hehe") + return + + if AUTH_CHANNEL and not await is_req_subscribed(bot, query): + await query.answer(results=[], + cache_time=0, + switch_pm_text='You have to subscribe my channel to use the bot', + switch_pm_parameter="subscribe") + return + + results = [] + if '|' in query.query: + string, file_type = query.query.split('|', maxsplit=1) + string = string.strip() + file_type = file_type.strip().lower() + else: + string = query.query.strip() + file_type = None + + offset = int(query.offset or 0) + reply_markup = get_reply_markup(query=string) + files, next_offset, total = await get_search_results( + chat_id, + string, + file_type=file_type, + max_results=10, + offset=offset) + + for file in files: + title=file.file_name + size=get_size(file.file_size) + f_caption=file.caption + if CUSTOM_FILE_CAPTION: + try: + 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) + except Exception as e: + logger.exception(e) + f_caption=f_caption + if f_caption is None: + f_caption = f"{file.file_name}" + results.append( + InlineQueryResultCachedDocument( + title=file.file_name, + document_file_id=file.file_id, + caption=f_caption, + description=f'Size: {get_size(file.file_size)}\nType: {file.file_type}', + reply_markup=reply_markup)) + + if results: + switch_pm_text = f"{emoji.FILE_FOLDER} Results - {total}" + if string: + switch_pm_text += f" for {string}" + try: + await query.answer(results=results, + is_personal = True, + cache_time=cache_time, + switch_pm_text=switch_pm_text, + switch_pm_parameter="start", + next_offset=str(next_offset)) + except QueryIdInvalid: + pass + except Exception as e: + logging.exception(str(e)) + else: + switch_pm_text = f'{emoji.CROSS_MARK} No results' + if string: + switch_pm_text += f' for "{string}"' + + await query.answer(results=[], + is_personal = True, + cache_time=cache_time, + switch_pm_text=switch_pm_text, + switch_pm_parameter="okay") + + +def get_reply_markup(query): + buttons = [ + [ + InlineKeyboardButton('Search again', switch_inline_query_current_chat=query) + ] + ] + return InlineKeyboardMarkup(buttons) + + diff --git a/plugins/join_req.py b/plugins/join_req.py new file mode 100644 index 0000000000000000000000000000000000000000..36a184f27b2ba88da5914e797e9f47a804710cb8 --- /dev/null +++ b/plugins/join_req.py @@ -0,0 +1,14 @@ +from pyrogram import Client, filters, enums +from pyrogram.types import ChatJoinRequest +from database.users_chats_db import db +from info import ADMINS, AUTH_CHANNEL + +@Client.on_chat_join_request(filters.chat(AUTH_CHANNEL)) +async def join_reqs(client, message: ChatJoinRequest): + if not await db.find_join_req(message.from_user.id): + await db.add_join_req(message.from_user.id) + +@Client.on_message(filters.command("delreq") & filters.private & filters.user(ADMINS)) +async def del_requests(client, message): + await db.del_join_req() + await message.reply("⚙ ꜱᴜᴄᴄᴇꜱꜱғᴜʟʟʏ ᴄʜᴀɴɴᴇʟ ʟᴇғᴛ ᴜꜱᴇʀꜱ ᴅᴇʟᴇᴛᴇᴅ") diff --git a/plugins/misc.py b/plugins/misc.py new file mode 100644 index 0000000000000000000000000000000000000000..40954a8739031ccac87c5e9088c8febac71ae51b --- /dev/null +++ b/plugins/misc.py @@ -0,0 +1,214 @@ +import os +from pyrogram import Client, filters, enums +from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty +from info import IMDB_TEMPLATE +from utils import extract_user, get_file_id, get_poster, last_online +import time +from datetime import datetime +from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery +import logging +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) + +@Client.on_message(filters.command('id')) +async def showid(client, message): + chat_type = message.chat.type + if chat_type == enums.ChatType.PRIVATE: + user_id = message.chat.id + first = message.from_user.first_name + last = message.from_user.last_name or "" + username = message.from_user.username + dc_id = message.from_user.dc_id or "" + await message.reply_text( + f"➲ First Name: {first}\n➲ Last Name: {last}\n➲ Username: {username}\n➲ Telegram ID: {user_id}\n➲ Data Centre: {dc_id}", + quote=True + ) + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + _id = "" + _id += ( + "➲ Chat ID: " + f"{message.chat.id}\n" + ) + if message.reply_to_message: + _id += ( + "➲ User ID: " + f"{message.from_user.id if message.from_user else 'Anonymous'}\n" + "➲ Replied User ID: " + f"{message.reply_to_message.from_user.id if message.reply_to_message.from_user else 'Anonymous'}\n" + ) + file_info = get_file_id(message.reply_to_message) + else: + _id += ( + "➲ User ID: " + f"{message.from_user.id if message.from_user else 'Anonymous'}\n" + ) + file_info = get_file_id(message) + if file_info: + _id += ( + f"{file_info.message_type}: " + f"{file_info.file_id}\n" + ) + await message.reply_text( + _id, + quote=True + ) + +@Client.on_message(filters.command(["info"])) +async def who_is(client, message): + # https://github.com/SpEcHiDe/PyroGramBot/blob/master/pyrobot/plugins/admemes/whois.py#L19 + status_message = await message.reply_text( + "`Fetching user info...`" + ) + await status_message.edit( + "`Processing user info...`" + ) + from_user = None + from_user_id, _ = extract_user(message) + try: + from_user = await client.get_users(from_user_id) + except Exception as error: + await status_message.edit(str(error)) + return + if from_user is None: + return await status_message.edit("no valid user_id / message specified") + message_out_str = "" + message_out_str += f"➲First Name: {from_user.first_name}\n" + last_name = from_user.last_name or "None" + message_out_str += f"➲Last Name: {last_name}\n" + message_out_str += f"➲Telegram ID: {from_user.id}\n" + username = from_user.username or "None" + dc_id = from_user.dc_id or "[User Doesn't Have A Valid DP]" + message_out_str += f"➲Data Centre: {dc_id}\n" + message_out_str += f"➲User Name: @{username}\n" + message_out_str += f"➲User 𝖫𝗂𝗇𝗄: Click Here\n" + if message.chat.type in ((enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)): + try: + chat_member_p = await message.chat.get_member(from_user.id) + joined_date = ( + chat_member_p.joined_date or datetime.now() + ).strftime("%Y.%m.%d %H:%M:%S") + message_out_str += ( + "➲Joined this Chat on: " + f"{joined_date}" + "\n" + ) + except UserNotParticipant: + pass + chat_photo = from_user.photo + if chat_photo: + local_user_photo = await client.download_media( + message=chat_photo.big_file_id + ) + buttons = [[ + InlineKeyboardButton('🔐 Close', callback_data='close_data') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await message.reply_photo( + photo=local_user_photo, + quote=True, + reply_markup=reply_markup, + caption=message_out_str, + parse_mode=enums.ParseMode.HTML, + disable_notification=True + ) + os.remove(local_user_photo) + else: + buttons = [[ + InlineKeyboardButton('🔐 Close', callback_data='close_data') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await message.reply_text( + text=message_out_str, + reply_markup=reply_markup, + quote=True, + parse_mode=enums.ParseMode.HTML, + disable_notification=True + ) + await status_message.delete() + +@Client.on_message(filters.command(["imdb", 'search'])) +async def imdb_search(client, message): + if ' ' in message.text: + k = await message.reply('Searching ImDB') + r, title = message.text.split(None, 1) + movies = await get_poster(title, bulk=True) + if not movies: + return await message.reply("No results Found") + btn = [ + [ + InlineKeyboardButton( + text=f"{movie.get('title')} - {movie.get('year')}", + callback_data=f"imdb#{movie.movieID}", + ) + ] + for movie in movies + ] + await k.edit('Here is what i found on IMDb', reply_markup=InlineKeyboardMarkup(btn)) + else: + await message.reply('Give me a movie / series Name') + +@Client.on_callback_query(filters.regex('^imdb')) +async def imdb_callback(bot: Client, quer_y: CallbackQuery): + i, movie = quer_y.data.split('#') + imdb = await get_poster(query=movie, id=True) + btn = [ + [ + InlineKeyboardButton( + text=f"{imdb.get('title')}", + url=imdb['url'], + ) + ] + ] + message = quer_y.message.reply_to_message or quer_y.message + if imdb: + caption = IMDB_TEMPLATE.format( + query = imdb['title'], + title = imdb['title'], + votes = imdb['votes'], + aka = imdb["aka"], + seasons = imdb["seasons"], + box_office = imdb['box_office'], + localized_title = imdb['localized_title'], + kind = imdb['kind'], + imdb_id = imdb["imdb_id"], + cast = imdb["cast"], + runtime = imdb["runtime"], + countries = imdb["countries"], + certificates = imdb["certificates"], + languages = imdb["languages"], + director = imdb["director"], + writer = imdb["writer"], + producer = imdb["producer"], + composer = imdb["composer"], + cinematographer = imdb["cinematographer"], + music_team = imdb["music_team"], + distributors = imdb["distributors"], + release_date = imdb['release_date'], + year = imdb['year'], + genres = imdb['genres'], + poster = imdb['poster'], + plot = imdb['plot'], + rating = imdb['rating'], + url = imdb['url'], + **locals() + ) + else: + caption = "No Results" + if imdb.get('poster'): + try: + await quer_y.message.reply_photo(photo=imdb['poster'], caption=caption, reply_markup=InlineKeyboardMarkup(btn)) + except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty): + pic = imdb.get('poster') + poster = pic.replace('.jpg', "._V1_UX360.jpg") + await quer_y.message.reply_photo(photo=poster, caption=caption, reply_markup=InlineKeyboardMarkup(btn)) + except Exception as e: + logger.exception(e) + await quer_y.message.reply(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False) + await quer_y.message.delete() + else: + await quer_y.message.edit(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False) + await quer_y.answer() + + + diff --git a/plugins/p_ttishow.py b/plugins/p_ttishow.py new file mode 100644 index 0000000000000000000000000000000000000000..36cacebe4342b398f2d48f535876103fabd7e643 --- /dev/null +++ b/plugins/p_ttishow.py @@ -0,0 +1,286 @@ +from pyrogram import Client, filters, enums +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery +from pyrogram.errors.exceptions.bad_request_400 import MessageTooLong, PeerIdInvalid +from info import ADMINS, LOG_CHANNEL, SUPPORT_CHAT, MELCOW_NEW_USERS, MELCOW_VID, CHNL_LNK, GRP_LNK +from database.users_chats_db import db +from database.ia_filterdb import Media +from utils import get_size, temp, get_settings +from Script import script +from pyrogram.errors import ChatAdminRequired +import asyncio + +"""-----------------------------------------https://t.me/TheMovieProviderBot--------------------------------------""" + +@Client.on_message(filters.new_chat_members & filters.group) +async def save_group(bot, message): + r_j_check = [u.id for u in message.new_chat_members] + if temp.ME in r_j_check: + if not await db.get_chat(message.chat.id): + total=await bot.get_chat_members_count(message.chat.id) + r_j = message.from_user.mention if message.from_user else "Anonymous" + await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, r_j)) + await db.add_chat(message.chat.id, message.chat.title) + if message.chat.id in temp.BANNED_CHATS: + # Inspired from a boat of a banana tree + buttons = [[ + InlineKeyboardButton('📌 ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ 📌', url=f'https://t.me/HpRequestBot') + ]] + reply_markup=InlineKeyboardMarkup(buttons) + k = await message.reply( + text='ᴄʜᴀᴛ ɴᴏᴛ ᴀʟʟᴏᴡᴇᴅ 🐞\n\nᴍʏ ᴀᴅᴍɪɴꜱ ʜᴀꜱ ʀᴇꜱᴛʀɪᴄᴛᴇᴅ ᴍᴇ ꜰʀᴏᴍ ᴡᴏʀᴋɪɴɢ ʜᴇʀᴇ ! ɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴋɴᴏᴡ ᴍᴏʀᴇ ᴀʙᴏᴜᴛ ɪᴛ ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ.', + reply_markup=reply_markup, + ) + + try: + await k.pin() + except: + pass + await bot.leave_chat(message.chat.id) + return + buttons = [[ + InlineKeyboardButton("🍁 ʜᴏᴡ ᴛᴏ ᴜꜱᴇ 🍁", url="https://t.me/TheMovieProviderBot?start=help") + ]] + reply_markup=InlineKeyboardMarkup(buttons) + await message.reply_text( + text=f"›› ᴛʜᴀɴᴋꜱ ꜰᴏʀ ᴀᴅᴅɪɴɢ ᴍᴇ ɪɴ {message.chat.title} \n›› ᴅᴏɴ'ᴛ ꜰᴏʀɢᴇᴛ ᴛᴏ ᴍᴀᴋᴇ ᴍᴇ ᴀᴅᴍɪɴ.\n›› ɪꜰ ᴀɴʏ ᴅᴏᴜʙᴛꜱ ᴀʙᴏᴜᴛ ᴜꜱɪɴɢ ᴍᴇ ᴄʟɪᴄᴋ ᴏɴ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ 👇", + reply_markup=reply_markup) + else: + settings = await get_settings(message.chat.id) + if settings["welcome"]: + for u in message.new_chat_members: + if (temp.MELCOW).get('welcome') is not None: + try: + await (temp.MELCOW['welcome']).delete() + except: + pass + temp.MELCOW['welcome'] = await message.reply_video( + video=(MELCOW_VID), + caption=(script.MELCOW_ENG.format(u.mention, message.chat.title)), + reply_markup=InlineKeyboardMarkup( + [[ + InlineKeyboardButton("📌 ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ 📌", url=f'https://t.me/HpRequestBot') + ]] + ), + parse_mode=enums.ParseMode.HTML + ) + + if settings["auto_delete"]: + await asyncio.sleep(600) + await (temp.MELCOW['welcome']).delete() + + + + + +@Client.on_message(filters.command('leave') & filters.user(ADMINS)) +async def leave_a_chat(bot, message): + if len(message.command) == 1: + return await message.reply('Give me a chat id') + chat = message.command[1] + try: + chat = int(chat) + except: + chat = chat + try: + buttons = [[ + InlineKeyboardButton("📌 ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ 📌", url="https://t.me/HpRequestBot") + ]] + reply_markup=InlineKeyboardMarkup(buttons) + await bot.send_message( + chat_id=chat, + text='ʜᴇʟʟᴏ ꜰʀɪᴇɴᴅꜱ, \nᴍʏ ᴀᴅᴍɪɴ ʜᴀꜱ ᴛᴏʟᴅ ᴍᴇ ᴛᴏ ʟᴇᴀᴠᴇ ꜰʀᴏᴍ ɢʀᴏᴜᴘ, ꜱᴏ ɪ ʜᴀᴠᴇ ᴛᴏ ɢᴏ !/nɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴀᴅᴅ ᴍᴇ ᴀɢᴀɪɴ ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ.', + reply_markup=reply_markup, + ) + + await bot.leave_chat(chat) + await message.reply(f"left the chat `{chat}`") + except Exception as e: + await message.reply(f'Error - {e}') + +@Client.on_message(filters.command('disable') & filters.user(ADMINS)) +async def disable_chat(bot, message): + if len(message.command) == 1: + return await message.reply('Give me a chat id') + r = message.text.split(None) + if len(r) > 2: + reason = message.text.split(None, 2)[2] + chat = message.text.split(None, 2)[1] + else: + chat = message.command[1] + reason = "No reason Provided" + try: + chat_ = int(chat) + except: + return await message.reply('Give Me A Valid Chat ID') + cha_t = await db.get_chat(int(chat_)) + if not cha_t: + return await message.reply("Chat Not Found In DB") + if cha_t['is_disabled']: + return await message.reply(f"This chat is already disabled:\nReason- {cha_t['reason']} ") + await db.disable_chat(int(chat_), reason) + temp.BANNED_CHATS.append(int(chat_)) + await message.reply('Chat Successfully Disabled') + try: + buttons = [[ + InlineKeyboardButton('📌 ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ 📌', url=f'https://t.me/HpRequestBot') + ]] + reply_markup=InlineKeyboardMarkup(buttons) + await bot.send_message( + chat_id=chat_, + text=f'ʜᴇʟʟᴏ ꜰʀɪᴇɴᴅꜱ, \nᴍʏ ᴀᴅᴍɪɴ ʜᴀꜱ ᴛᴏʟᴅ ᴍᴇ ᴛᴏ ʟᴇᴀᴠᴇ ꜰʀᴏᴍ ɢʀᴏᴜᴘ, ꜱᴏ ɪ ʜᴀᴠᴇ ᴛᴏ ɢᴏ ! \nɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴀᴅᴅ ᴍᴇ ᴀɢᴀɪɴ ᴄᴏɴᴛᴀᴄᴛ ꜱᴜᴘᴘᴏʀᴛ.. \nReason : {reason}', + reply_markup=reply_markup) + await bot.leave_chat(chat_) + except Exception as e: + await message.reply(f"Error - {e}") + + +@Client.on_message(filters.command('enable') & filters.user(ADMINS)) +async def re_enable_chat(bot, message): + if len(message.command) == 1: + return await message.reply('Give me a chat id') + chat = message.command[1] + try: + chat_ = int(chat) + except: + return await message.reply('Give Me A Valid Chat ID') + sts = await db.get_chat(int(chat)) + if not sts: + return await message.reply("Chat Not Found In DB !") + if not sts.get('is_disabled'): + return await message.reply('This chat is not yet disabled.') + await db.re_enable_chat(int(chat_)) + temp.BANNED_CHATS.remove(int(chat_)) + await message.reply("Chat Successfully re-enabled") + + +@Client.on_message(filters.command('stats') & filters.incoming) +async def get_ststs(bot, message): + rju = await message.reply('Fetching stats..') + total_users = await db.total_users_count() + totl_chats = await db.total_chat_count() + files = await Media.count_documents() + size = await db.get_db_size() + free = 536870912 - size + size = get_size(size) + free = get_size(free) + await rju.edit(script.STATUS_TXT.format(files, total_users, totl_chats, size, free)) + + +@Client.on_message(filters.command('invite') & filters.user(ADMINS)) +async def gen_invite(bot, message): + if len(message.command) == 1: + return await message.reply('Give me a chat id') + chat = message.command[1] + try: + chat = int(chat) + except: + return await message.reply('Give Me A Valid Chat ID') + try: + link = await bot.create_chat_invite_link(chat) + except ChatAdminRequired: + return await message.reply("Invite Link Generation Failed, Iam Not Having Sufficient Rights") + except Exception as e: + return await message.reply(f'Error {e}') + await message.reply(f'Here is your Invite Link {link.invite_link}') + +@Client.on_message(filters.command('ban') & filters.user(ADMINS)) +async def ban_a_user(bot, message): + # https://t.me/GetTGLink/4185 + if len(message.command) == 1: + return await message.reply('Give me a user id / username') + r = message.text.split(None) + if len(r) > 2: + reason = message.text.split(None, 2)[2] + chat = message.text.split(None, 2)[1] + else: + chat = message.command[1] + reason = "No reason Provided" + try: + chat = int(chat) + except: + pass + try: + k = await bot.get_users(chat) + except PeerIdInvalid: + return await message.reply("This is an invalid user, make sure I have met him before.") + except IndexError: + return await message.reply("This might be a channel, make sure its a user.") + except Exception as e: + return await message.reply(f'Error - {e}') + else: + jar = await db.get_ban_status(k.id) + if jar['is_banned']: + return await message.reply(f"{k.mention} is already banned\nReason: {jar['ban_reason']}") + await db.ban_user(k.id, reason) + temp.BANNED_USERS.append(k.id) + await message.reply(f"Successfully banned {k.mention}") + + + +@Client.on_message(filters.command('unban') & filters.user(ADMINS)) +async def unban_a_user(bot, message): + if len(message.command) == 1: + return await message.reply('Give me a user id / username') + r = message.text.split(None) + if len(r) > 2: + reason = message.text.split(None, 2)[2] + chat = message.text.split(None, 2)[1] + else: + chat = message.command[1] + reason = "No reason Provided" + try: + chat = int(chat) + except: + pass + try: + k = await bot.get_users(chat) + except PeerIdInvalid: + return await message.reply("This is an invalid user, make sure ia have met him before.") + except IndexError: + return await message.reply("Thismight be a channel, make sure its a user.") + except Exception as e: + return await message.reply(f'Error - {e}') + else: + jar = await db.get_ban_status(k.id) + if not jar['is_banned']: + return await message.reply(f"{k.mention} is not yet banned.") + await db.remove_ban(k.id) + temp.BANNED_USERS.remove(k.id) + await message.reply(f"Successfully unbanned {k.mention}") + + + +@Client.on_message(filters.command('users') & filters.user(ADMINS)) +async def list_users(bot, message): + # https://t.me/GetTGLink/4184 + raju = await message.reply('Getting List Of Users') + users = await db.get_all_users() + out = "Users Saved In DB Are:\n\n" + async for user in users: + out += f"{user['name']}" + if user['ban_status']['is_banned']: + out += '( Banned User )' + out += '\n' + try: + await raju.edit_text(out) + except MessageTooLong: + with open('users.txt', 'w+') as outfile: + outfile.write(out) + await message.reply_document('users.txt', caption="List Of Users") + +@Client.on_message(filters.command('chats') & filters.user(ADMINS)) +async def list_chats(bot, message): + raju = await message.reply('Getting List Of chats') + chats = await db.get_all_chats() + out = "Chats Saved In DB Are:\n\n" + async for chat in chats: + out += f"**Title:** `{chat['title']}`\n**- ID:** `{chat['id']}`" + if chat['chat_status']['is_disabled']: + out += '( Disabled Chat )' + out += '\n' + try: + await raju.edit_text(out) + except MessageTooLong: + with open('chats.txt', 'w+') as outfile: + outfile.write(out) + await message.reply_document('chats.txt', caption="List Of Chats") diff --git a/plugins/pmfilter.py b/plugins/pmfilter.py new file mode 100644 index 0000000000000000000000000000000000000000..9007bec38592090da5abcc416ee8b3ee6985d78a --- /dev/null +++ b/plugins/pmfilter.py @@ -0,0 +1,2847 @@ +# Kanged From @TroJanZheX +# Thanks @DeletedFromEarth +import asyncio +import re +import ast +import math +import random +import pytz +from datetime import datetime, timedelta, date, time +lock = asyncio.Lock() +from database.users_chats_db import db +from pyrogram.errors.exceptions.bad_request_400 import MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty +from Script import script +import pyrogram +from database.connections_mdb import active_connection, all_connections, delete_connection, if_active, make_active, \ + make_inactive +from info import * +from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto +from pyrogram import Client, filters, enums +from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid +from utils import get_size, is_req_subscribed, get_poster, search_gagala, temp, get_settings, save_group_settings, get_shortlink, get_tutorial, send_all, get_cap +from database.users_chats_db import db +from database.ia_filterdb import Media, get_file_details, get_search_results, get_bad_files +from database.filters_mdb import ( + del_all, + find_filter, + get_filters, +) +from database.gfilters_mdb import ( + find_gfilter, + get_gfilters, + del_allg +) +import logging +from urllib.parse import quote_plus +from util.file_properties import get_name, get_hash, get_media_file_size + +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) + +import requests +import string +import tracemalloc +# Enable tracemalloc +tracemalloc.start() + +TIMEZONE = "Asia/Kolkata" +BUTTON = {} +BUTTONS = {} +FRESH = {} +BUTTONS0 = {} +BUTTONS1 = {} +BUTTONS2 = {} +SPELL_CHECK = {} +# ENABLE_SHORTLINK = "" + +def generate_random_alphanumeric(): + """Generate a random 8-letter alphanumeric string.""" + characters = string.ascii_letters + string.digits + random_chars = ''.join(random.choice(characters) for _ in range(8)) + return random_chars + +def get_shortlink_sync(url): + try: + rget = requests.get(f"https://{STREAM_SITE}/api?api={STREAM_API}&url={url}&alias={generate_random_alphanumeric()}") + rjson = rget.json() + if rjson["status"] == "success" or rget.status_code == 200: + return rjson["shortenedUrl"] + else: + return url + except Exception as e: + print(f"Error in get_shortlink_sync: {e}") + return url + +async def get_shortlink(url): + loop = asyncio.get_event_loop() + return await loop.run_in_executor(None, get_shortlink_sync, url) + +@Client.on_message(filters.group | filters.private & filters.text & filters.incoming) +async def give_filter(client, message): + if message.chat.id != SUPPORT_CHAT_ID: + manual = await manual_filters(client, message) + if manual == False: + settings = await get_settings(message.chat.id) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + else: #a better logic to avoid repeated lines of code in auto_filter function + search = message.text + temp_files, temp_offset, total_results = await get_search_results(chat_id=message.chat.id, query=search.lower(), offset=0, filter=True) + if total_results == 0: + return + else: + return await message.reply_text(f"Hᴇʏ {message.from_user.mention},\n\nʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ ɪꜱ ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ✅\n\n📂 ꜰɪʟᴇꜱ ꜰᴏᴜɴᴅ : {str(total_results)}\n🔍 ꜱᴇᴀʀᴄʜ : {search}\n\n‼️ ᴛʜɪs ɪs ᴀ sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ'ᴛ ɢᴇᴛ ғɪʟᴇs ғʀᴏᴍ ʜᴇʀᴇ...\n\n📝 ꜱᴇᴀʀᴄʜ ʜᴇʀᴇ : 👇", + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("🔍 ᴊᴏɪɴ ᴀɴᴅ ꜱᴇᴀʀᴄʜ ʜᴇʀᴇ 🔎", url=f"https://t.me/MoviesLinkSearchBot2")]])) + +@Client.on_message(filters.private & filters.text & filters.incoming) +async def pm_text(bot, message): + content = message.text + user = message.from_user.first_name + user_id = message.from_user.id + if content.startswith("/") or content.startswith("#"): return # ignore commands and hashtags + if user_id in ADMINS: return # ignore admins + await message.reply_text( + text=f"ʜᴇʏ {user} 😍 ,\n\nʏᴏᴜ ᴄᴀɴ'ᴛ ɢᴇᴛ ᴍᴏᴠɪᴇs ꜰʀᴏᴍ ʜᴇʀᴇ. ʀᴇǫᴜᴇsᴛ ɪᴛ ɪɴ ᴏᴜʀ ᴍᴏᴠɪᴇ ɢʀᴏᴜᴘ ʙʏ ᴄʟɪᴄᴋɪɴɢ ᴏɴ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ 👇", + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("📝 ʀᴇǫᴜᴇsᴛ ʜᴇʀᴇ ", url=f"https://t.me/MoviesLinkSearchBot2")]]) + ) + await bot.send_message( + chat_id=LOG_CHANNEL, + text=f"#𝐏𝐌_𝐌𝐒𝐆\n\nNᴀᴍᴇ : {user}\n\nID : {user_id}\n\nMᴇssᴀɢᴇ : {content}" + ) + +@Client.on_callback_query(filters.regex(r"^next")) +async def next_page(bot, query): + ident, req, key, offset = query.data.split("_") + curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + if int(req) not in [query.from_user.id, 0]: + return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) + try: + offset = int(offset) + except: + offset = 0 + if BUTTONS.get(key)!=None: + search = BUTTONS.get(key) + else: + search = FRESH.get(key) + if not search: + await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name),show_alert=True) + return + + files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=offset, filter=True) + try: + n_offset = int(n_offset) + except: + n_offset = 0 + + if not files: + return + temp.GETALL[key] = files + temp.SHORT[query.from_user.id] = query.message.chat.id + settings = await get_settings(query.message.chat.id) + pre = 'filep' if settings['file_secure'] else 'file' + if settings['button']: + btn = [ + [ + InlineKeyboardButton( + text=f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}' + ), + ] + for file in files + ] + + + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + else: + btn = [] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + try: + if settings['max_btn']: + if 0 < offset <= 10: + off_set = 0 + elif offset == 0: + off_set = None + else: + off_set = offset - 10 + if n_offset == 0: + btn.append( + [InlineKeyboardButton("⋞ ʙᴀᴄᴋ", callback_data=f"next_{req}_{key}_{off_set}"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages")] + ) + elif off_set is None: + btn.append([InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data=f"next_{req}_{key}_{n_offset}")]) + else: + btn.append( + [ + InlineKeyboardButton("⋞ ʙᴀᴄᴋ", callback_data=f"next_{req}_{key}_{off_set}"), + InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), + InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data=f"next_{req}_{key}_{n_offset}") + ], + ) + else: + if 0 < offset <= int(MAX_B_TN): + off_set = 0 + elif offset == 0: + off_set = None + else: + off_set = offset - int(MAX_B_TN) + if n_offset == 0: + btn.append( + [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")] + ) + elif off_set is None: + 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("ɴᴇxᴛ ⋟", callback_data=f"next_{req}_{key}_{n_offset}")]) + else: + btn.append( + [ + 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"), + InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data=f"next_{req}_{key}_{n_offset}") + ], + ) + except KeyError: + await save_group_settings(query.message.chat.id, 'max_btn', True) + if 0 < offset <= 10: + off_set = 0 + elif offset == 0: + off_set = None + else: + off_set = offset - 10 + if n_offset == 0: + btn.append( + [InlineKeyboardButton("⋞ ʙᴀᴄᴋ", callback_data=f"next_{req}_{key}_{off_set}"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages")] + ) + elif off_set is None: + btn.append([InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data=f"next_{req}_{key}_{n_offset}")]) + else: + btn.append( + [ + InlineKeyboardButton("⋞ ʙᴀᴄᴋ", callback_data=f"next_{req}_{key}_{off_set}"), + InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), + InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data=f"next_{req}_{key}_{n_offset}") + ], + ) + if not settings["button"]: + cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000))) + remaining_seconds = "{:.2f}".format(time_difference.total_seconds()) + cap = await get_cap(settings, remaining_seconds, files, query, total, search) + try: + await query.message.edit_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True) + except MessageNotModified: + pass + else: + try: + await query.edit_message_reply_markup( + reply_markup=InlineKeyboardMarkup(btn) + ) + except MessageNotModified: + pass + await query.answer() + +@Client.on_callback_query(filters.regex(r"^spol")) +async def advantage_spoll_choker(bot, query): + _, user, movie_ = query.data.split('#') + movies = SPELL_CHECK.get(query.message.reply_to_message.id) + if not movies: + return await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name), show_alert=True) + if int(user) != 0 and query.from_user.id != int(user): + return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) + if movie_ == "close_spellcheck": + return await query.message.delete() + movie = movies[(int(movie_))] + movie = re.sub(r"[:\-]", " ", movie) + movie = re.sub(r"\s+", " ", movie).strip() + await query.answer(script.TOP_ALRT_MSG) + gl = await global_filters(bot, query.message, text=movie) + if gl == False: + k = await manual_filters(bot, query.message, text=movie) + if k == False: + files, offset, total_results = await get_search_results(query.message.chat.id, movie, offset=0, filter=True) + if files: + k = (movie, files, offset, total_results) + await auto_filter(bot, query, k) + else: + reqstr1 = query.from_user.id if query.from_user else 0 + reqstr = await bot.get_users(reqstr1) + if NO_RESULTS_MSG: + await bot.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, movie))) + k = await query.message.edit(script.MVE_NT_FND) + await asyncio.sleep(10) + await k.delete() +#Qualities +@Client.on_callback_query(filters.regex(r"^qualities#")) +async def qualities_cb_handler(client: Client, query: CallbackQuery): + + try: + if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]: + return await query.answer( + f"⚠️ ʜᴇʟʟᴏ {query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ,\nʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...", + show_alert=True, + ) + except: + pass + _, key = query.data.split("#") + # if BUTTONS.get(key+"1")!=None: + # search = BUTTONS.get(key+"1") + # else: + # search = BUTTONS.get(key) + # BUTTONS[key+"1"] = search + search = FRESH.get(key) + search = search.replace(' ', '_') + btn = [] + for i in range(0, len(QUALITIES)-1, 2): + btn.append([ + InlineKeyboardButton( + text=QUALITIES[i].title(), + callback_data=f"fq#{QUALITIES[i].lower()}#{key}" + ), + InlineKeyboardButton( + text=QUALITIES[i+1].title(), + callback_data=f"fq#{QUALITIES[i+1].lower()}#{key}" + ), + ]) + + btn.insert( + 0, + [ + InlineKeyboardButton( + text="⇊ ꜱᴇʟᴇᴄᴛ ǫᴜᴀʟɪᴛʏ ⇊", callback_data="ident" + ) + ], + ) + req = query.from_user.id + offset = 0 + btn.append([InlineKeyboardButton(text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ↭", callback_data=f"fq#homepage#{key}")]) + + await query.edit_message_reply_markup(InlineKeyboardMarkup(btn)) + + +@Client.on_callback_query(filters.regex(r"^fq#")) +async def filter_qualities_cb_handler(client: Client, query: CallbackQuery): + _, qual, key = query.data.split("#") + curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + search = FRESH.get(key) + search = search.replace("_", " ") + baal = qual in search + if baal: + search = search.replace(qual, "") + else: + search = search + req = query.from_user.id + chat_id = query.message.chat.id + message = query.message + try: + if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]: + return await query.answer( + f"⚠️ ʜᴇʟʟᴏ {query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ,\nʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...", + show_alert=True, + ) + except: + pass + if qual != "homepage": + search = f"{search} {qual}" + BUTTONS[key] = search + + files, offset, total_results = await get_search_results(chat_id, search, offset=0, filter=True) + if not files: + await query.answer("🚫 ɴᴏ ꜰɪʟᴇꜱ ᴡᴇʀᴇ ꜰᴏᴜɴᴅ 🚫", show_alert=1) + return + temp.GETALL[key] = files + settings = await get_settings(message.chat.id) + pre = 'filep' if settings['file_secure'] else 'file' + if settings["button"]: + btn = [ + [ + InlineKeyboardButton( + text=f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}' + ), + ] + for file in files + ] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + else: + btn = [] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + if offset != "": + try: + if settings['max_btn']: + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + + else: + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/int(MAX_B_TN))}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + except KeyError: + await save_group_settings(query.message.chat.id, 'max_btn', True) + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + else: + btn.append( + [InlineKeyboardButton(text="↭ ɴᴏ ᴍᴏʀᴇ ᴘᴀɢᴇꜱ ᴀᴠᴀɪʟᴀʙʟᴇ ↭",callback_data="pages")] + ) + + if not settings["button"]: + cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000))) + remaining_seconds = "{:.2f}".format(time_difference.total_seconds()) + cap = await get_cap(settings, remaining_seconds, files, query, total_results, search) + try: + await query.message.edit_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True) + except MessageNotModified: + pass + else: + try: + await query.edit_message_reply_markup( + reply_markup=InlineKeyboardMarkup(btn) + ) + except MessageNotModified: + pass + await query.answer() + +#languages + +@Client.on_callback_query(filters.regex(r"^languages#")) +async def languages_cb_handler(client: Client, query: CallbackQuery): + try: + if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]: + return await query.answer( + f"⚠️ ʜᴇʟʟᴏ {query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ,\nʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...", + show_alert=True, + ) + except: + pass + _, key = query.data.split("#") + # if BUTTONS.get(key+"1")!=None: + # search = BUTTONS.get(key+"1") + # else: + # search = BUTTONS.get(key) + # BUTTONS[key+"1"] = search + search = FRESH.get(key) + search = search.replace(' ', '_') + btn = [] + for i in range(0, len(LANGUAGES)-1, 2): + btn.append([ + InlineKeyboardButton( + text=LANGUAGES[i].title(), + callback_data=f"fl#{LANGUAGES[i].lower()}#{key}" + ), + InlineKeyboardButton( + text=LANGUAGES[i+1].title(), + callback_data=f"fl#{LANGUAGES[i+1].lower()}#{key}" + ), + ]) + + btn.insert( + 0, + [ + InlineKeyboardButton( + text="⇊ ꜱᴇʟᴇᴄᴛ ʟᴀɴɢᴜᴀɢᴇ ⇊", callback_data="ident" + ) + ], + ) + req = query.from_user.id + offset = 0 + btn.append([InlineKeyboardButton(text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭", callback_data=f"fl#homepage#{key}")]) + + await query.edit_message_reply_markup(InlineKeyboardMarkup(btn)) + + +@Client.on_callback_query(filters.regex(r"^fl#")) +async def filter_languages_cb_handler(client: Client, query: CallbackQuery): + _, lang, key = query.data.split("#") + curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + search = FRESH.get(key) + search = search.replace("_", " ") + baal = lang in search + if baal: + search = search.replace(lang, "") + else: + search = search + req = query.from_user.id + chat_id = query.message.chat.id + message = query.message + try: + if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]: + return await query.answer( + f"⚠️ ʜᴇʟʟᴏ {query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ,\nʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...", + show_alert=True, + ) + except: + pass + if lang != "homepage": + search = f"{search} {lang}" + BUTTONS[key] = search + + files, offset, total_results = await get_search_results(chat_id, search, offset=0, filter=True) + if not files: + await query.answer("🚫 ɴᴏ ꜰɪʟᴇꜱ ᴡᴇʀᴇ ꜰᴏᴜɴᴅ 🚫", show_alert=1) + return + temp.GETALL[key] = files + settings = await get_settings(message.chat.id) + pre = 'filep' if settings['file_secure'] else 'file' + if settings["button"]: + btn = [ + [ + InlineKeyboardButton( + text=f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}' + ), + ] + for file in files + ] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + else: + btn = [] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + if offset != "": + try: + if settings['max_btn']: + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + + else: + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/int(MAX_B_TN))}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + except KeyError: + await save_group_settings(query.message.chat.id, 'max_btn', True) + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + else: + btn.append( + [InlineKeyboardButton(text="↭ ɴᴏ ᴍᴏʀᴇ ᴘᴀɢᴇꜱ ᴀᴠᴀɪʟᴀʙʟᴇ ↭",callback_data="pages")] + ) + + if not settings["button"]: + cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000))) + remaining_seconds = "{:.2f}".format(time_difference.total_seconds()) + cap = await get_cap(settings, remaining_seconds, files, query, total_results, search) + try: + await query.message.edit_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True) + except MessageNotModified: + pass + else: + try: + await query.edit_message_reply_markup( + reply_markup=InlineKeyboardMarkup(btn) + ) + except MessageNotModified: + pass + await query.answer() + + + +@Client.on_callback_query(filters.regex(r"^seasons#")) +async def seasons_cb_handler(client: Client, query: CallbackQuery): + try: + if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]: + return await query.answer( + f"⚠️ ʜᴇʟʟᴏ {query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ,\nʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...", + show_alert=True, + ) + except: + pass + _, key = query.data.split("#") + # if BUTTONS.get(key+"2")!=None: + # search = BUTTONS.get(key+"2") + # else: + # search = BUTTONS.get(key) + # BUTTONS[key+"2"] = search + search = FRESH.get(key) + BUTTONS[key] = None + search = search.replace(' ', '_') + btn = [] + for i in range(0, len(SEASONS)-1, 2): + btn.append([ + InlineKeyboardButton( + text=SEASONS[i].title(), + callback_data=f"fs#{SEASONS[i].lower()}#{key}" + ), + InlineKeyboardButton( + text=SEASONS[i+1].title(), + callback_data=f"fs#{SEASONS[i+1].lower()}#{key}" + ), + ]) + + btn.insert( + 0, + [ + InlineKeyboardButton( + text="⇊ ꜱᴇʟᴇᴄᴛ ꜱᴇᴀꜱᴏɴ ⇊", callback_data="ident" + ) + ], + ) + req = query.from_user.id + offset = 0 + btn.append([InlineKeyboardButton(text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭", callback_data=f"next_{req}_{key}_{offset}")]) + + await query.edit_message_reply_markup(InlineKeyboardMarkup(btn)) + + +@Client.on_callback_query(filters.regex(r"^fs#")) +async def filter_seasons_cb_handler(client: Client, query: CallbackQuery): + _, seas, key = query.data.split("#") + curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + search = FRESH.get(key) + search = search.replace("_", " ") + sea = "" + season_search = ["s01","s02", "s03", "s04", "s05", "s06", "s07", "s08", "s09", "s10", "season 01","season 02","season 03","season 04","season 05","season 06","season 07","season 08","season 09","season 10", "season 1","season 2","season 3","season 4","season 5","season 6","season 7","season 8","season 9"] + for x in range (len(season_search)): + if season_search[x] in search: + sea = season_search[x] + break + if sea: + search = search.replace(sea, "") + else: + search = search + + req = query.from_user.id + chat_id = query.message.chat.id + message = query.message + try: + if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]: + return await query.answer( + f"⚠️ ʜᴇʟʟᴏ {query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ,\nʀᴇǫᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...", + show_alert=True, + ) + except: + pass + + searchagn = search + search1 = search + search2 = search + search = f"{search} {seas}" + BUTTONS0[key] = search + + files, _, _ = await get_search_results(chat_id, search, max_results=10) + files = [file for file in files if re.search(seas, file.file_name, re.IGNORECASE)] + + seas1 = "s01" if seas == "season 1" else "s02" if seas == "season 2" else "s03" if seas == "season 3" else "s04" if seas == "season 4" else "s05" if seas == "season 5" else "s06" if seas == "season 6" else "s07" if seas == "season 7" else "s08" if seas == "season 8" else "s09" if seas == "season 9" else "s10" if seas == "season 10" else "" + search1 = f"{search1} {seas1}" + BUTTONS1[key] = search1 + files1, _, _ = await get_search_results(chat_id, search1, max_results=10) + files1 = [file for file in files1 if re.search(seas1, file.file_name, re.IGNORECASE)] + + if files1: + files.extend(files1) + + seas2 = "season 01" if seas == "season 1" else "season 02" if seas == "season 2" else "season 03" if seas == "season 3" else "season 04" if seas == "season 4" else "season 05" if seas == "season 5" else "season 06" if seas == "season 6" else "season 07" if seas == "season 7" else "season 08" if seas == "season 8" else "season 09" if seas == "season 9" else "s010" + search2 = f"{search2} {seas2}" + BUTTONS2[key] = search2 + files2, _, _ = await get_search_results(chat_id, search2, max_results=10) + files2 = [file for file in files2 if re.search(seas2, file.file_name, re.IGNORECASE)] + + if files2: + files.extend(files2) + + if not files: + await query.answer("🚫 ɴᴏ ꜰɪʟᴇꜱ ᴡᴇʀᴇ ꜰᴏᴜɴᴅ 🚫", show_alert=1) + return + temp.GETALL[key] = files + settings = await get_settings(message.chat.id) + pre = 'filep' if settings['file_secure'] else 'file' + if settings["button"]: + btn = [ + [ + InlineKeyboardButton( + text=f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}' + ), + ] + for file in files + ] + btn.insert(0, [ + InlineKeyboardButton("ꜱᴇɴᴅ ᴀʟʟ", callback_data=f"sendfiles#{key}"), + InlineKeyboardButton("ꜱᴇʟᴇᴄᴛ ᴀɢᴀɪɴ", callback_data=f"seasons#{key}") + ]) + else: + btn = [] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + offset = 0 + + btn.append([ + InlineKeyboardButton( + text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭", + callback_data=f"next_{req}_{key}_{offset}" + ), + ]) + + if not settings["button"]: + cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000))) + remaining_seconds = "{:.2f}".format(time_difference.total_seconds()) + total_results = len(files) + cap = await get_cap(settings, remaining_seconds, files, query, total_results, search) + try: + await query.message.edit_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True) + except MessageNotModified: + pass + else: + try: + await query.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(btn)) + except MessageNotModified: + pass + await query.answer() + + +@Client.on_callback_query() +async def cb_handler(client: Client, query: CallbackQuery): + lazyData = query.data + try: + link = await client.create_chat_invite_link(int(REQST_CHANNEL)) + except: + pass + if query.data == "close_data": + await query.message.delete() + elif query.data == "gfiltersdeleteallconfirm": + await del_allg(query.message, 'gfilters') + await query.answer("ᴅᴏɴᴇ !") + return + elif query.data == "gfiltersdeleteallcancel": + await query.message.reply_to_message.delete() + await query.message.delete() + await query.answer("ᴘʀᴏᴄᴇꜱꜱ ᴄᴀɴᴄᴇʟʟᴇᴅ !") + return + elif query.data == "delallconfirm": + userid = query.from_user.id + chat_type = query.message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + grpid = await active_connection(str(userid)) + if grpid is not None: + grp_id = grpid + try: + chat = await client.get_chat(grpid) + title = chat.title + except: + await query.message.edit_text("Mᴀᴋᴇ sᴜʀᴇ I'ᴍ ᴘʀᴇsᴇɴᴛ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ!!", quote=True) + return await query.answer(MSG_ALRT) + else: + await query.message.edit_text( + "I'ᴍ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘs !\nCʜᴇᴄᴋ /connections ᴏʀ ᴄᴏɴɴᴇᴄᴛ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘs.", + quote=True + ) + return await query.answer(MSG_ALRT) + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = query.message.chat.id + title = query.message.chat.title + + else: + return await query.answer(MSG_ALRT) + + st = await client.get_chat_member(grp_id, userid) + if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): + await del_all(query.message, grp_id, title) + else: + await query.answer("Yᴏᴜ ɴᴇᴇᴅ ᴛᴏ ʙᴇ Gʀᴏᴜᴘ Oᴡɴᴇʀ ᴏʀ ᴀɴ Aᴜᴛʜ Usᴇʀ ᴛᴏ ᴅᴏ ᴛʜᴀᴛ !", show_alert=True) + elif query.data == "delallcancel": + userid = query.from_user.id + chat_type = query.message.chat.type + + if chat_type == enums.ChatType.PRIVATE: + await query.message.reply_to_message.delete() + await query.message.delete() + + elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: + grp_id = query.message.chat.id + st = await client.get_chat_member(grp_id, userid) + if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): + await query.message.delete() + try: + await query.message.reply_to_message.delete() + except: + pass + else: + await query.answer("Tʜᴀᴛ's ɴᴏᴛ ғᴏʀ ʏᴏᴜ!!", show_alert=True) + elif "groupcb" in query.data: + await query.answer() + + group_id = query.data.split(":")[1] + + act = query.data.split(":")[2] + hr = await client.get_chat(int(group_id)) + title = hr.title + user_id = query.from_user.id + + if act == "": + stat = "ᴄᴏɴɴᴇᴄᴛ" + cb = "connectcb" + else: + stat = "ᴅɪꜱᴄᴏɴɴᴇᴄᴛ" + cb = "disconnect" + + keyboard = InlineKeyboardMarkup([ + [InlineKeyboardButton(f"{stat}", callback_data=f"{cb}:{group_id}"), + InlineKeyboardButton("ᴅᴇʟᴇᴛᴇ", callback_data=f"deletecb:{group_id}")], + [InlineKeyboardButton("ʙᴀᴄᴋ", callback_data="backcb")] + ]) + + await query.message.edit_text( + f"Gʀᴏᴜᴘ Nᴀᴍᴇ : **{title}**\nGʀᴏᴜᴘ ID : `{group_id}`", + reply_markup=keyboard, + parse_mode=enums.ParseMode.MARKDOWN + ) + return await query.answer(MSG_ALRT) + elif "connectcb" in query.data: + await query.answer() + + group_id = query.data.split(":")[1] + + hr = await client.get_chat(int(group_id)) + + title = hr.title + + user_id = query.from_user.id + + mkact = await make_active(str(user_id), str(group_id)) + + if mkact: + await query.message.edit_text( + f"Cᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ **{title}**", + parse_mode=enums.ParseMode.MARKDOWN + ) + else: + await query.message.edit_text('Sᴏᴍᴇ ᴇʀʀᴏʀ ᴏᴄᴄᴜʀʀᴇᴅ!!', parse_mode=enums.ParseMode.MARKDOWN) + return await query.answer(MSG_ALRT) + elif "disconnect" in query.data: + await query.answer() + + group_id = query.data.split(":")[1] + + hr = await client.get_chat(int(group_id)) + + title = hr.title + user_id = query.from_user.id + + mkinact = await make_inactive(str(user_id)) + + if mkinact: + await query.message.edit_text( + f"Dɪsᴄᴏɴɴᴇᴄᴛᴇᴅ ғʀᴏᴍ **{title}**", + parse_mode=enums.ParseMode.MARKDOWN + ) + else: + await query.message.edit_text( + f"Sᴏᴍᴇ ᴇʀʀᴏʀ ᴏᴄᴄᴜʀʀᴇᴅ!!", + parse_mode=enums.ParseMode.MARKDOWN + ) + return await query.answer(MSG_ALRT) + elif "deletecb" in query.data: + await query.answer() + + user_id = query.from_user.id + group_id = query.data.split(":")[1] + + delcon = await delete_connection(str(user_id), str(group_id)) + + if delcon: + await query.message.edit_text( + "Sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ᴄᴏɴɴᴇᴄᴛɪᴏɴ !" + ) + else: + await query.message.edit_text( + f"Sᴏᴍᴇ ᴇʀʀᴏʀ ᴏᴄᴄᴜʀʀᴇᴅ!!", + parse_mode=enums.ParseMode.MARKDOWN + ) + return await query.answer(MSG_ALRT) + elif query.data == "backcb": + await query.answer() + + userid = query.from_user.id + + groupids = await all_connections(str(userid)) + if groupids is None: + await query.message.edit_text( + "Tʜᴇʀᴇ ᴀʀᴇ ɴᴏ ᴀᴄᴛɪᴠᴇ ᴄᴏɴɴᴇᴄᴛɪᴏɴs!! Cᴏɴɴᴇᴄᴛ ᴛᴏ sᴏᴍᴇ ɢʀᴏᴜᴘs ғɪʀsᴛ.", + ) + return await query.answer(MSG_ALRT) + buttons = [] + for groupid in groupids: + try: + ttl = await client.get_chat(int(groupid)) + title = ttl.title + active = await if_active(str(userid), str(groupid)) + act = " - ACTIVE" if active else "" + buttons.append( + [ + InlineKeyboardButton( + text=f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}" + ) + ] + ) + except: + pass + if buttons: + await query.message.edit_text( + "Yᴏᴜʀ ᴄᴏɴɴᴇᴄᴛᴇᴅ ɢʀᴏᴜᴘ ᴅᴇᴛᴀɪʟs ;\n\n", + reply_markup=InlineKeyboardMarkup(buttons) + ) + elif "gfilteralert" in query.data: + grp_id = query.message.chat.id + i = query.data.split(":")[1] + keyword = query.data.split(":")[2] + reply_text, btn, alerts, fileid = await find_gfilter('gfilters', keyword) + if alerts is not None: + alerts = ast.literal_eval(alerts) + alert = alerts[int(i)] + alert = alert.replace("\\n", "\n").replace("\\t", "\t") + await query.answer(alert, show_alert=True) + elif "alertmessage" in query.data: + grp_id = query.message.chat.id + i = query.data.split(":")[1] + keyword = query.data.split(":")[2] + reply_text, btn, alerts, fileid = await find_filter(grp_id, keyword) + if alerts is not None: + alerts = ast.literal_eval(alerts) + alert = alerts[int(i)] + alert = alert.replace("\\n", "\n").replace("\\t", "\t") + await query.answer(alert, show_alert=True) + + if query.data.startswith("file"): + clicked = query.from_user.id + try: + typed = query.from_user.id + except: + typed = query.from_user.id + ident, file_id = query.data.split("#") + files_ = await get_file_details(file_id) + if not files_: + return await query.answer('Nᴏ sᴜᴄʜ ғɪʟᴇ ᴇxɪsᴛ.') + files = files_[0] + title = files.file_name + size = get_size(files.file_size) + f_caption = files.caption + settings = await get_settings(query.message.chat.id) + if CUSTOM_FILE_CAPTION: + try: + 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) + except Exception as e: + logger.exception(e) + f_caption = f_caption + if f_caption is None: + f_caption = f"{files.file_name}" + + try: + if not await db.has_premium_access(clicked) and settings['is_shortlink']: #Don't change Anything without my permission @CodeluffyTG + if clicked == query.from_user.id: + temp.SHORT[clicked] = query.message.chat.id + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=short_{file_id}") + return + else: + await query.answer(f"Hᴇʏ {query.from_user.first_name},\nTʜɪs Is Nᴏᴛ Yᴏᴜʀ Mᴏᴠɪᴇ Rᴇǫᴜᴇsᴛ.\nRᴇǫᴜᴇsᴛ Yᴏᴜʀ's !", show_alert=True) + else: + if clicked == query.from_user.id: + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start={ident}_{file_id}") + return + else: + await query.answer(f"Hᴇʏ {query.from_user.first_name},\nTʜɪs Is Nᴏᴛ Yᴏᴜʀ Mᴏᴠɪᴇ Rᴇǫᴜᴇsᴛ.\nRᴇǫᴜᴇsᴛ Yᴏᴜʀ's !", show_alert=True) + except UserIsBlocked: + await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True) + except PeerIdInvalid: + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start={ident}_{file_id}") + except Exception as e: + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start={ident}_{file_id}") + + elif query.data.startswith("sendfiles"): + clicked = query.from_user.id + ident, key = query.data.split("#") + settings = await get_settings(query.message.chat.id) + try: + if not await db.has_premium_access(clicked) and settings['is_shortlink']: # Don't Change anything without my permission @CoderluffyTG + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles1_{key}") + return + else: + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=allfiles_{key}") + return + except UserIsBlocked: + await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True) + except PeerIdInvalid: + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles3_{key}") + except Exception as e: + logger.exception(e) + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles4_{key}") + + elif query.data.startswith("del"): + ident, file_id = query.data.split("#") + files_ = await get_file_details(file_id) + if not files_: + return await query.answer('Nᴏ sᴜᴄʜ ғɪʟᴇ ᴇxɪsᴛ.') + files = files_[0] + title = files.file_name + size = get_size(files.file_size) + f_caption = files.caption + settings = await get_settings(query.message.chat.id) + if CUSTOM_FILE_CAPTION: + try: + 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) + except Exception as e: + logger.exception(e) + f_caption = f_caption + if f_caption is None: + f_caption = f"{files.file_name}" + await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}") + + elif query.data.startswith("checksub"): + if AUTH_CHANNEL and not await is_req_subscribed(client, query): + await query.answer("Jᴏɪɴ ᴏᴜʀ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ ᴍᴀʜɴ! 😒", show_alert=True) + return + ident, kk, file_id = query.data.split("#") + await query.answer(url=f"https://t.me/{temp.U_NAME}?start={kk}_{file_id}") + + elif query.data == "pages": + await query.answer() + + elif query.data.startswith("send_fsall"): + temp_var, ident, key, offset = query.data.split("#") + search = BUTTON0.get(key) + if not search: + await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name),show_alert=True) + return + files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=int(offset), filter=True) + await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query) + search = BUTTONS1.get(key) + files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=int(offset), filter=True) + await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query) + search = BUTTONS2.get(key) + files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=int(offset), filter=True) + await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query) + await query.answer(f"ʜᴇʏ {query.from_user.first_name}, ᴀʟʟ ꜰɪʟᴇꜱ ᴏɴ ᴛʜɪꜱ ᴘᴀɢᴇ ʜᴀꜱ ʙᴇᴇɴ ꜱᴇɴᴛ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴛᴏ ʏᴏᴜ ʙʏ ᴅᴍ !", show_alert=True) + + elif query.data.startswith("send_fall"): + temp_var, ident, key, offset = query.data.split("#") + if BUTTONS.get(key)!=None: + search = BUTTONS.get(key) + else: + search = FRESH.get(key) + if not search: + await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name),show_alert=True) + return + files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=int(offset), filter=True) + await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query) + await query.answer(f"ʜᴇʏ {query.from_user.first_name}, ᴀʟʟ ꜰɪʟᴇꜱ ᴏɴ ᴛʜɪꜱ ᴘᴀɢᴇ ʜᴀꜱ ʙᴇᴇɴ ꜱᴇɴᴛ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴛᴏ ʏᴏᴜ ʙʏ ᴅᴍ !", show_alert=True) + + elif query.data.startswith("killfilesdq"): + ident, keyword = query.data.split("#") + #await query.message.edit_text(f"Fetching Files for your query {keyword} on DB... Please wait...") + files, total = await get_bad_files(keyword) + await query.message.edit_text("ꜰɪʟᴇ ᴅᴇʟᴇᴛɪᴏɴ ᴘʀᴏᴄᴇꜱꜱ ᴡɪʟʟ ꜱᴛᴀʀᴛ ɪɴ 5 ꜱᴇᴄᴏɴᴅꜱ !") + await asyncio.sleep(5) + deleted = 0 + async with lock: + try: + for file in files: + file_ids = file.file_id + file_name = file.file_name + result = await Media.collection.delete_one({ + '_id': file_ids, + }) + if result.deleted_count: + logger.info(f'ꜰɪʟᴇ ꜰᴏᴜɴᴅ ꜰᴏʀ ʏᴏᴜʀ ǫᴜᴇʀʏ {keyword}! ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ {file_name} ꜰʀᴏᴍ ᴅᴀᴛᴀʙᴀꜱᴇ.') + deleted += 1 + if deleted % 20 == 0: + await query.message.edit_text(f"ᴘʀᴏᴄᴇꜱꜱ ꜱᴛᴀʀᴛᴇᴅ ꜰᴏʀ ᴅᴇʟᴇᴛɪɴɢ ꜰɪʟᴇꜱ ꜰʀᴏᴍ ᴅʙ. ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ {str(deleted)} ꜰɪʟᴇꜱ ꜰʀᴏᴍ ᴅʙ ꜰᴏʀ ʏᴏᴜʀ ǫᴜᴇʀʏ {keyword} !\n\nᴘʟᴇᴀꜱᴇ ᴡᴀɪᴛ...") + except Exception as e: + logger.exception(e) + await query.message.edit_text(f'Error: {e}') + else: + await query.message.edit_text(f"ᴘʀᴏᴄᴇꜱꜱ ᴄᴏᴍᴘʟᴇᴛᴇᴅ ꜰᴏʀ ꜰɪʟᴇ ᴅᴇʟᴇᴛᴀᴛɪᴏɴ !\n\nꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ {str(deleted)} ꜰɪʟᴇꜱ ꜰʀᴏᴍ ᴅʙ ꜰᴏʀ ʏᴏᴜʀ ǫᴜᴇʀʏ {keyword}.") + + elif query.data.startswith("opnsetgrp"): + ident, grp_id = query.data.split("#") + userid = query.from_user.id if query.from_user else None + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + await query.answer("ʏᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ ʀɪɢʜᴛꜱ ᴛᴏ ᴅᴏ ᴛʜɪꜱ !", show_alert=True) + return + title = query.message.chat.title + settings = await get_settings(grp_id) + if settings is not None: + buttons = [ + [ + InlineKeyboardButton('ʀᴇꜱᴜʟᴛ ᴘᴀɢᴇ', + callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'), + InlineKeyboardButton('ʙᴜᴛᴛᴏɴ' if settings["button"] else 'ᴛᴇxᴛ', + callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜰɪʟᴇ ꜱᴇɴᴅ ᴍᴏᴅᴇ', callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}'), + InlineKeyboardButton('ꜱᴛᴀʀᴛ' if settings["botpm"] else 'ᴀᴜᴛᴏ', + callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜰɪʟᴇ ꜱᴇᴄᴜʀᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["file_secure"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ɪᴍᴅʙ ᴘᴏꜱᴛᴇʀ', callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["imdb"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜱᴘᴇʟʟ ᴄʜᴇᴄᴋ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["spell_check"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴡᴇʟᴄᴏᴍᴇ ᴍꜱɢ', callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["welcome"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["auto_delete"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["auto_ffilter"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴍᴀx ʙᴜᴛᴛᴏɴꜱ', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}'), + InlineKeyboardButton('10' if settings["max_btn"] else f'{MAX_B_TN}', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜱʜᴏʀᴛʟɪɴᴋ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["is_shortlink"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('⇋ ᴄʟᴏꜱᴇ ꜱᴇᴛᴛɪɴɢꜱ ᴍᴇɴᴜ ⇋', + callback_data='close_data' + ) + ] + ] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=f"ᴄʜᴀɴɢᴇ ʏᴏᴜʀ ꜱᴇᴛᴛɪɴɢꜱ ꜰᴏʀ {title} ᴀꜱ ʏᴏᴜ ᴡɪꜱʜ ⚙", + disable_web_page_preview=True, + parse_mode=enums.ParseMode.HTML + ) + await query.message.edit_reply_markup(reply_markup) + + elif query.data.startswith("opnsetpm"): + ident, grp_id = query.data.split("#") + userid = query.from_user.id if query.from_user else None + st = await client.get_chat_member(grp_id, userid) + if ( + st.status != enums.ChatMemberStatus.ADMINISTRATOR + and st.status != enums.ChatMemberStatus.OWNER + and str(userid) not in ADMINS + ): + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + return + title = query.message.chat.title + settings = await get_settings(grp_id) + btn2 = [[ + InlineKeyboardButton("ᴄʜᴇᴄᴋ ᴍʏ ᴅᴍ 🗳️", url=f"telegram.me/{temp.U_NAME}") + ]] + reply_markup = InlineKeyboardMarkup(btn2) + await query.message.edit_text(f"ʏᴏᴜʀ sᴇᴛᴛɪɴɢs ᴍᴇɴᴜ ғᴏʀ {title} ʜᴀs ʙᴇᴇɴ sᴇɴᴛ ᴛᴏ ʏᴏᴜ ʙʏ ᴅᴍ.") + await query.message.edit_reply_markup(reply_markup) + if settings is not None: + buttons = [ + [ + InlineKeyboardButton('ʀᴇꜱᴜʟᴛ ᴘᴀɢᴇ', + callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'), + InlineKeyboardButton('ʙᴜᴛᴛᴏɴ' if settings["button"] else 'ᴛᴇxᴛ', + callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜰɪʟᴇ ꜱᴇɴᴅ ᴍᴏᴅᴇ', callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}'), + InlineKeyboardButton('ꜱᴛᴀʀᴛ' if settings["botpm"] else 'ᴀᴜᴛᴏ', + callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜰɪʟᴇ ꜱᴇᴄᴜʀᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["file_secure"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ɪᴍᴅʙ ᴘᴏꜱᴛᴇʀ', callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["imdb"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜱᴘᴇʟʟ ᴄʜᴇᴄᴋ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["spell_check"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴡᴇʟᴄᴏᴍᴇ ᴍꜱɢ', callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["welcome"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["auto_delete"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["auto_ffilter"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴍᴀx ʙᴜᴛᴛᴏɴꜱ', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}'), + InlineKeyboardButton('10' if settings["max_btn"] else f'{MAX_B_TN}', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜱʜᴏʀᴛʟɪɴᴋ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["is_shortlink"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('⇋ ᴄʟᴏꜱᴇ ꜱᴇᴛᴛɪɴɢꜱ ᴍᴇɴᴜ ⇋', + callback_data='close_data' + ) + ] + ] + reply_markup = InlineKeyboardMarkup(buttons) + await client.send_message( + chat_id=userid, + text=f"ᴄʜᴀɴɢᴇ ʏᴏᴜʀ ꜱᴇᴛᴛɪɴɢꜱ ꜰᴏʀ {title} ᴀꜱ ʏᴏᴜ ᴡɪꜱʜ ⚙", + reply_markup=reply_markup, + disable_web_page_preview=True, + parse_mode=enums.ParseMode.HTML, + reply_to_message_id=query.message.id + ) + + elif query.data.startswith("show_option"): + ident, from_user = query.data.split("#") + btn = [[ + InlineKeyboardButton("⚠️ ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ ⚠️", callback_data=f"unavailable#{from_user}"), + InlineKeyboardButton("🟢 ᴜᴘʟᴏᴀᴅᴇᴅ 🟢", callback_data=f"uploaded#{from_user}") + ],[ + InlineKeyboardButton("♻️ ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ♻️", callback_data=f"already_available#{from_user}") + ]] + btn2 = [[ + InlineKeyboardButton("ᴠɪᴇᴡ ꜱᴛᴀᴛᴜꜱ", url=f"{query.message.link}") + ]] + if query.from_user.id in ADMINS: + user = await client.get_users(from_user) + reply_markup = InlineKeyboardMarkup(btn) + await query.message.edit_reply_markup(reply_markup) + await query.answer("Hᴇʀᴇ ᴀʀᴇ ᴛʜᴇ ᴏᴘᴛɪᴏɴs !") + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif query.data.startswith("unavailable"): + ident, from_user = query.data.split("#") + btn = [[ + InlineKeyboardButton("⚠️ ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ ⚠️", callback_data=f"unalert#{from_user}") + ]] + btn2 = [[ + InlineKeyboardButton('ᴊᴏɪɴ ᴄʜᴀɴɴᴇʟ', url=link.invite_link), + InlineKeyboardButton("ᴠɪᴇᴡ ꜱᴛᴀᴛᴜꜱ", url=f"{query.message.link}") + ]] + if query.from_user.id in ADMINS: + user = await client.get_users(from_user) + reply_markup = InlineKeyboardMarkup(btn) + content = query.message.text + await query.message.edit_text(f"{content}") + await query.message.edit_reply_markup(reply_markup) + await query.answer("Sᴇᴛ ᴛᴏ Uɴᴀᴠᴀɪʟᴀʙʟᴇ !") + try: + await client.send_message(chat_id=int(from_user), text=f"Hᴇʏ {user.mention}, Sᴏʀʀʏ Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ. Sᴏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs ᴄᴀɴ'ᴛ ᴜᴘʟᴏᴀᴅ ɪᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) + except UserIsBlocked: + await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"Hᴇʏ {user.mention}, Sᴏʀʀʏ Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ. Sᴏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs ᴄᴀɴ'ᴛ ᴜᴘʟᴏᴀᴅ ɪᴛ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif query.data.startswith("uploaded"): + ident, from_user = query.data.split("#") + btn = [[ + InlineKeyboardButton("🟢 ᴜᴘʟᴏᴀᴅᴇᴅ 🟢", callback_data=f"upalert#{from_user}") + ]] + btn2 = [[ + InlineKeyboardButton('ᴊᴏɪɴ ᴄʜᴀɴɴᴇʟ', url=link.invite_link), + InlineKeyboardButton("ᴠɪᴇᴡ ꜱᴛᴀᴛᴜꜱ", url=f"{query.message.link}") + ],[ + InlineKeyboardButton("🔍 ꜱᴇᴀʀᴄʜ ʜᴇʀᴇ 🔎", url="https://t.me/MoviesLinkSearchBot2") + ]] + if query.from_user.id in ADMINS: + user = await client.get_users(from_user) + reply_markup = InlineKeyboardMarkup(btn) + content = query.message.text + await query.message.edit_text(f"{content}") + await query.message.edit_reply_markup(reply_markup) + await query.answer("Sᴇᴛ ᴛᴏ Uᴘʟᴏᴀᴅᴇᴅ !") + try: + await client.send_message(chat_id=int(from_user), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴜᴘʟᴏᴀᴅᴇᴅ ʙʏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.", reply_markup=InlineKeyboardMarkup(btn2)) + except UserIsBlocked: + await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴜᴘʟᴏᴀᴅᴇᴅ ʙʏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif query.data.startswith("already_available"): + ident, from_user = query.data.split("#") + btn = [[ + InlineKeyboardButton("♻️ ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ♻️", callback_data=f"alalert#{from_user}") + ]] + btn2 = [[ + InlineKeyboardButton('ᴊᴏɪɴ ᴄʜᴀɴɴᴇʟ', url=link.invite_link), + InlineKeyboardButton("ᴠɪᴇᴡ ꜱᴛᴀᴛᴜꜱ", url=f"{query.message.link}") + ],[ + InlineKeyboardButton("🔍 ꜱᴇᴀʀᴄʜ ʜᴇʀᴇ 🔎", url="https://t.me/MoviesLinkSearchBot2") + ]] + if query.from_user.id in ADMINS: + user = await client.get_users(from_user) + reply_markup = InlineKeyboardMarkup(btn) + content = query.message.text + await query.message.edit_text(f"{content}") + await query.message.edit_reply_markup(reply_markup) + await query.answer("Sᴇᴛ ᴛᴏ Aʟʀᴇᴀᴅʏ Aᴠᴀɪʟᴀʙʟᴇ !") + try: + await client.send_message(chat_id=int(from_user), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴏᴜʀ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.", reply_markup=InlineKeyboardMarkup(btn2)) + except UserIsBlocked: + await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴏᴜʀ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif query.data.startswith("alalert"): + ident, from_user = query.data.split("#") + if int(query.from_user.id) == int(from_user): + user = await client.get_users(from_user) + await query.answer(f"Hᴇʏ {user.first_name}, Yᴏᴜʀ Rᴇᴏ̨ᴜᴇsᴛ ɪs Aʟʀᴇᴀᴅʏ Aᴠᴀɪʟᴀʙʟᴇ !", show_alert=True) + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif query.data.startswith("upalert"): + ident, from_user = query.data.split("#") + if int(query.from_user.id) == int(from_user): + user = await client.get_users(from_user) + await query.answer(f"Hᴇʏ {user.first_name}, Yᴏᴜʀ Rᴇᴏ̨ᴜᴇsᴛ ɪs Uᴘʟᴏᴀᴅᴇᴅ !", show_alert=True) + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif query.data.startswith("unalert"): + ident, from_user = query.data.split("#") + if int(query.from_user.id) == int(from_user): + user = await client.get_users(from_user) + await query.answer(f"Hᴇʏ {user.first_name}, Yᴏᴜʀ Rᴇᴏ̨ᴜᴇsᴛ ɪs Uɴᴀᴠᴀɪʟᴀʙʟᴇ !", show_alert=True) + else: + await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) + + elif lazyData.startswith("generate_stream_link"): + _, file_id = lazyData.split(":") + try: + user_id = query.from_user.id + username = query.from_user.mention + log_msg = await client.send_cached_media( + chat_id=LOG_CHANNEL, + file_id=file_id, + ) + fileName = {quote_plus(get_name(log_msg))} + lazy_stream = f"{URL}watch/{str(log_msg.id)}/{quote_plus(get_name(log_msg))}?hash={get_hash(log_msg)}" + lazy_download = f"{URL}{str(log_msg.id)}/{quote_plus(get_name(log_msg))}?hash={get_hash(log_msg)}" + hp_link = await get_shortlink(lazy_download) + ph_link = await get_shortlink(lazy_stream) + buttons = [] + if await db.has_premium_access(user_id): + buttons = [[ + InlineKeyboardButton("🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ", url=lazy_download), + InlineKeyboardButton("ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿", url=lazy_stream) + ],[ + InlineKeyboardButton('📌 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ 📌', url='https://t.me/HP_MOVIES_WORLD') + ]] + else: + await query.answer("🚸 ɴᴏᴛᴇ :\nᴀᴅ-ꜰʀᴇᴇ ꜱᴇʀᴠɪᴄᴇ ɪꜱ ᴏɴʟʏ ꜰᴏʀ ᴘʀᴇᴍɪᴜᴍ ᴜꜱᴇʀꜱ.\n\nᴛᴏ ᴋɴᴏᴡ ᴍᴏʀᴇ ᴄʜᴇᴄᴋ ᴘʟᴀɴꜱ.", show_alert=True) + await query.message.reply_text( + text="‼️ ᴡᴀɴᴛ ᴛᴏ ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ?\n\n✅ ᴘᴜʀᴄʜᴀꜱᴇ ᴘʀᴇᴍɪᴜᴍ ᴀɴᴅ ᴇɴᴊᴏʏ ᴀᴅ-ꜰʀᴇᴇ ᴇxᴘᴇʀɪᴇɴᴄᴇ.", + quote=True, + disable_web_page_preview=True, + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("💸 ᴄʜᴇᴄᴋᴏᴜᴛ ᴘʀᴇᴍɪᴜᴍ ᴘʟᴀɴꜱ 💸", callback_data='seeplans')]])) + buttons = [[ + InlineKeyboardButton("🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ", url=hp_link), + InlineKeyboardButton("ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿", url=ph_link) + ],[ + InlineKeyboardButton('❗ʜᴏᴡ ᴛᴏ ᴏᴘᴇɴ ʟɪɴᴋ❗', url=STREAMHTO) + ]] + + query.message.reply_markup = query.message.reply_markup or [] + query.message.reply_markup.inline_keyboard.pop(0) + query.message.reply_markup.inline_keyboard.insert(0, buttons) + await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons)) + await log_msg.reply_text( + text=f"#LinkGenrated\n\nIᴅ : {user_id}\nUꜱᴇʀɴᴀᴍᴇ : {username}\n\nNᴀᴍᴇ : {fileName}", + quote=True, + disable_web_page_preview=True, + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("🚀 ꜰᴀꜱᴛ ᴅᴏᴡɴʟᴏᴀᴅ", url=hp_link), + InlineKeyboardButton('ᴡᴀᴛᴄʜ ᴏɴʟɪɴᴇ 🧿', url=ph_link)]])) + except Exception as e: + print(e) # print the error message + await query.answer(f"⚠️ SOMETHING WENT WRONG \n\n{e}", show_alert=True) + return + + # don't change anything without contacting me @creatorrio + + elif query.data == "pagesn1": + await query.answer(text=script.PAGE_TXT, show_alert=True) + + elif query.data == "reqinfo": + await query.answer(text=script.REQINFO, show_alert=True) + + elif query.data == "select": + await query.answer(text=script.SELECT, show_alert=True) + + elif query.data == "sinfo": + await query.answer(text=script.SINFO, show_alert=True) + + elif query.data == "start": + buttons = [[ + InlineKeyboardButton('☆ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ☆', url=f'http://telegram.me/{temp.U_NAME}?startgroup=true') + ],[ + InlineKeyboardButton('💸 ᴇᴀʀɴ ᴍᴏɴᴇʏ 💸', callback_data="shortlink_info"), + InlineKeyboardButton('• ᴜᴘᴅᴀᴛᴇꜱ •', callback_data='channels') + ],[ + InlineKeyboardButton('• ᴄᴏᴍᴍᴀɴᴅꜱ •', callback_data='help'), + InlineKeyboardButton('• ᴀʙᴏᴜᴛ •', callback_data='about') + ],[ + InlineKeyboardButton('✨ ʙᴜʏ ꜱᴜʙꜱᴄʀɪᴘᴛɪᴏɴ : ʀᴇᴍᴏᴠᴇ ᴀᴅꜱ ✨', callback_data="premium_info") + ]] + + reply_markup = InlineKeyboardMarkup(buttons) + current_time = datetime.now(pytz.timezone(TIMEZONE)) + curr_time = current_time.hour + if curr_time < 12: + gtxt = "ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ 👋" + elif curr_time < 17: + gtxt = "ɢᴏᴏᴅ ᴀғᴛᴇʀɴᴏᴏɴ 👋" + elif curr_time < 21: + gtxt = "ɢᴏᴏᴅ ᴇᴠᴇɴɪɴɢ 👋" + else: + gtxt = "ɢᴏᴏᴅ ɴɪɢʜᴛ 👋" + await query.message.edit_text( + text=script.START_TXT.format(query.from_user.mention, gtxt, temp.U_NAME, temp.B_NAME), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + await query.answer(MSG_ALRT) + + elif query.data == "purchase": + buttons = [[ + InlineKeyboardButton('💵 ᴘᴀʏ ᴠɪᴀ ᴜᴘɪ ɪᴅ 💵', callback_data='upi_info') + ],[ + InlineKeyboardButton('📸 ꜱᴄᴀɴ ǫʀ ᴄᴏᴅᴇ 📸', callback_data='qr_info') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.PURCHASE_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "upi_info": + buttons = [[ + InlineKeyboardButton('📲 ꜱᴇɴᴅ ᴘᴀʏᴍᴇɴᴛ ꜱᴄʀᴇᴇɴꜱʜᴏᴛ ʜᴇʀᴇ', user_id=int(767250672)) + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='purchase') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.UPI_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "qr_info": + buttons = [[ + InlineKeyboardButton('📲 ꜱᴇɴᴅ ᴘᴀʏᴍᴇɴᴛ ꜱᴄʀᴇᴇɴꜱʜᴏᴛ ʜᴇʀᴇ', user_id=int(767250672)) + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='purchase') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.QR_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "seeplans": + btn = [[ + InlineKeyboardButton('📲 ꜱᴇɴᴅ ᴘᴀʏᴍᴇɴᴛ ꜱᴄʀᴇᴇɴꜱʜᴏᴛ', user_id=int(767250672)) + ],[ + InlineKeyboardButton('❌ ᴄʟᴏꜱᴇ ❌', callback_data='close_data') + ]] + reply_markup = InlineKeyboardMarkup(btn) + await query.message.reply_photo( + photo=(SUBSCRIPTION), + caption=script.PREPLANS_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + # Thanks to @CoderluffyTG for fixing this + elif query.data == "give_trial": + user_id = query.from_user.id + has_free_trial = await db.check_trial_status(user_id) + if has_free_trial: + await query.answer("🚸 ʏᴏᴜ'ᴠᴇ ᴀʟʀᴇᴀᴅʏ ᴄʟᴀɪᴍᴇᴅ ʏᴏᴜʀ ꜰʀᴇᴇ ᴛʀɪᴀʟ ᴏɴᴄᴇ !\n\n📌 ᴄʜᴇᴄᴋᴏᴜᴛ ᴏᴜʀ ᴘʟᴀɴꜱ ʙʏ : /plan", show_alert=True) + return + else: + await db.give_free_trial(user_id) + await query.message.reply_text( + text="🥳 ᴄᴏɴɢʀᴀᴛᴜʟᴀᴛɪᴏɴꜱ\n\n🎉 ʏᴏᴜ ᴄᴀɴ ᴜsᴇ ꜰʀᴇᴇ ᴛʀᴀɪʟ ꜰᴏʀ 5 ᴍɪɴᴜᴛᴇs ꜰʀᴏᴍ ɴᴏᴡ !", + quote=False, + disable_web_page_preview=True, + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("💸 ᴄʜᴇᴄᴋᴏᴜᴛ ᴘʀᴇᴍɪᴜᴍ ᴘʟᴀɴꜱ 💸", callback_data='seeplans')]])) + return + + elif query.data == "premium_info": + buttons = [[ + InlineKeyboardButton('• ꜰʀᴇᴇ ᴛʀɪᴀʟ •', callback_data='free') + ],[ + InlineKeyboardButton('• ʙʀᴏɴᴢᴇ •', callback_data='broze'), + InlineKeyboardButton('• ꜱɪʟᴠᴇʀ •', callback_data='silver') + ],[ + InlineKeyboardButton('• ɢᴏʟᴅ •', callback_data='gold'), + InlineKeyboardButton('• ᴘʟᴀᴛɪɴᴜᴍ •', callback_data='platinum') + ],[ + InlineKeyboardButton('• ᴅɪᴀᴍᴏɴᴅ •', callback_data='diamond'), + InlineKeyboardButton('• ᴏᴛʜᴇʀ •', callback_data='other') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ᴛᴏ ʜᴏᴍᴇ ⇋', callback_data='start') + ]] + + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.PLAN_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "free": + buttons = [[ + InlineKeyboardButton('⚜️ ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ɢᴇᴛ ꜰʀᴇᴇ ᴛʀɪᴀʟ', callback_data="give_trial") + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='other'), + InlineKeyboardButton('1 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='broze') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.FREE_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "broze": + buttons = [[ + InlineKeyboardButton('🔐 ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ʙᴜʏ ᴘʀᴇᴍɪᴜᴍ', callback_data='purchase') + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='free'), + InlineKeyboardButton('2 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='silver') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.BRONZE_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "silver": + buttons = [[ + InlineKeyboardButton('🔐 ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ʙᴜʏ ᴘʀᴇᴍɪᴜᴍ', callback_data='purchase') + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='broze'), + InlineKeyboardButton('3 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='gold') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.SILVER_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "gold": + buttons = [[ + InlineKeyboardButton('🔐 ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ʙᴜʏ ᴘʀᴇᴍɪᴜᴍ', callback_data='purchase') + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='silver'), + InlineKeyboardButton('4 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='platinum') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.GOLD_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "platinum": + buttons = [[ + InlineKeyboardButton('🔐 ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ʙᴜʏ ᴘʀᴇᴍɪᴜᴍ', callback_data='purchase') + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='gold'), + InlineKeyboardButton('5 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='diamond') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.PLATINUM_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + + elif query.data == "diamond": + buttons = [[ + InlineKeyboardButton('🔐 ᴄʟɪᴄᴋ ʜᴇʀᴇ ᴛᴏ ʙᴜʏ ᴘʀᴇᴍɪᴜᴍ', callback_data='purchase') + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='platinum'), + InlineKeyboardButton('6 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='other') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.DIAMOND_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "other": + buttons = [[ + InlineKeyboardButton('☎️ ᴄᴏɴᴛᴀᴄᴛ ᴏᴡɴᴇʀ ᴛᴏ ᴋɴᴏᴡ ᴍᴏʀᴇ', user_id=int(767250672)) + ],[ + InlineKeyboardButton('⋞ ʙᴀᴄᴋ', callback_data='diamond'), + InlineKeyboardButton('7 / 7', callback_data='pagesn1'), + InlineKeyboardButton('ɴᴇxᴛ ⋟', callback_data='free') + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='premium_info') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.OTHER_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + + elif query.data == "channels": + buttons = [[ + InlineKeyboardButton('⚜️ ᴜᴘᴅᴀᴛᴇꜱ ᴄʜᴀɴɴᴇʟ ⚜️', url='https://t.me/HP_MOVIES_WORLD') + ],[ + InlineKeyboardButton('🔍 ɢʀᴏᴜᴘ¹', url='https://t.me/MoviesLinkSearchBot2'), + InlineKeyboardButton('ɢʀᴏᴜᴘ² 🔎', url='https://t.me/MoviesLinkSearchBot3') + ],[ + InlineKeyboardButton('✉️ ʀᴇǫᴜᴇꜱᴛ ɢʀᴏᴜᴘ ✉️', url='https://t.me/HpMovieRequest') + ],[ + InlineKeyboardButton('⇇ ʙᴀᴄᴋ', callback_data='start'), + InlineKeyboardButton('ꜱᴜᴘᴘᴏʀᴛ 👮', url='https://t.me/HpRequestBot') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.CHANNELS.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "users": + buttons = [[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='help') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.USERS_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "group": + buttons = [[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='help') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.GROUP_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "admic": + if query.from_user.id not in ADMINS: + return await query.answer("⚠️ ʏᴏᴜ'ʀᴇ ɴᴏᴛ ᴀ ʙᴏᴛ ᴀᴅᴍɪɴ !", show_alert=True) + buttons = [[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='help') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.ADMIC_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + + elif query.data == "help": + buttons = [[ + InlineKeyboardButton('• ʙᴏᴛ ᴀᴅᴍɪɴ ᴄᴏᴍᴍᴀɴᴅꜱ •', callback_data='admic') + ], [ + InlineKeyboardButton('• ᴜꜱᴇʀ •', callback_data='users'), + InlineKeyboardButton('• ɢʀᴏᴜᴘ •', callback_data='group') + ], [ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ᴛᴏ ʜᴏᴍᴇ ⇋', callback_data='start') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.HELP_TXT.format(query.from_user.mention), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "about": + buttons = [[ + InlineKeyboardButton('‼️ ᴅɪꜱᴄʟᴀɪᴍᴇʀ ‼️', callback_data='disclaimer'), + ], [ + InlineKeyboardButton ('• ᴄʀᴇᴅɪᴛꜱ ᴛᴏ ᴛʜᴇ ᴅᴇᴠᴇʟᴏᴘᴇʀꜱ •', callback_data='credits'), + ], [ + InlineKeyboardButton('• ᴏᴡɴᴇʀ •', user_id=int(767250672)), + InlineKeyboardButton('• ꜱᴛᴀᴛꜱ •', callback_data='stats') + ], [ + InlineKeyboardButton('🛰️ ʀᴇɴᴅᴇʀɪɴɢ ꜱᴛᴀᴛᴜꜱ ☁️',callback_data='rendr') + ], [ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ᴛᴏ ʜᴏᴍᴇ ⇋', callback_data='start') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.ABOUT_TXT.format(temp.B_NAME), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "rendr": + await query.answer("⚡️ ʟɪᴠᴇ sʏsᴛᴇᴍ sᴛᴀᴛᴜs ⚡️\n\n❂ ʀᴀᴍ ●●●●●●●◌◌◌\n✇ ᴄᴘᴜ ●●●●●●●◌◌◌\n✪ ᴅᴀᴛᴀ ᴛʀᴀꜰɪᴄs ●●●●◌◌◌◌◌◌ 🛰\n\nᴠ4.2 [sᴛᴀʙʟᴇ] """, show_alert=True) + + elif query.data == "credits": + buttons = [[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ⇋', callback_data='about') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_text( + text=script.CREDITS_TXT, + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "stats": + buttons = [[ + InlineKeyboardButton('⇇ ʙᴀᴄᴋ', callback_data='about'), + InlineKeyboardButton('⟲ ʀᴇғʀᴇsʜ', callback_data='rfrsh') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + total = await Media.count_documents() + users = await db.total_users_count() + chats = await db.total_chat_count() + monsize = await db.get_db_size() + free = 536870912 - monsize + monsize = get_size(monsize) + free = get_size(free) + await query.message.edit_text( + text=script.STATUS_TXT.format(total, users, chats, monsize, free), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "rfrsh": + await query.answer("ꜰᴇᴛᴄʜɪɴɢ ᴍᴏɴɢᴏ-ᴅʙ ᴅᴀᴛᴀʙᴀꜱᴇ...") + buttons = [[ + InlineKeyboardButton('⇇ ʙᴀᴄᴋ', callback_data='about'), + InlineKeyboardButton('⟲ ʀᴇғʀᴇsʜ', callback_data='rfrsh') + ]] + reply_markup = InlineKeyboardMarkup(buttons) + total = await Media.count_documents() + users = await db.total_users_count() + chats = await db.total_chat_count() + monsize = await db.get_db_size() + free = 536870912 - monsize + monsize = get_size(monsize) + free = get_size(free) + await query.message.edit_text( + text=script.STATUS_TXT.format(total, users, chats, monsize, free), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "shortlink_info": + btn = [[ + InlineKeyboardButton("1 / 3", callback_data="pagesn1"), + InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data="shortlink_info2") + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ᴛᴏ ʜᴏᴍᴇ ⇋', callback_data='start') + ]] + reply_markup = InlineKeyboardMarkup(btn) + await query.message.edit_text( + text=(script.SHORTLINK_INFO), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "shortlink_info2": + btn = [[ + InlineKeyboardButton("⋞ ʙᴀᴄᴋ", callback_data="shortlink_info"), + InlineKeyboardButton("2 / 3", callback_data="pagesn1"), + InlineKeyboardButton("ɴᴇxᴛ ⋟", callback_data="shortlink_info3") + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ᴛᴏ ʜᴏᴍᴇ ⇋', callback_data='start') + ]] + reply_markup = InlineKeyboardMarkup(btn) + await query.message.edit_text( + text=(script.SHORTLINK_INFO2), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data == "shortlink_info3": + btn = [[ + InlineKeyboardButton("⋞ ʙᴀᴄᴋ", callback_data="shortlink_info2"), + InlineKeyboardButton("3 / 3", callback_data="pagesn1") + ],[ + InlineKeyboardButton('⇋ ʙᴀᴄᴋ ᴛᴏ ʜᴏᴍᴇ ⇋', callback_data='start') + ]] + reply_markup = InlineKeyboardMarkup(btn) + await query.message.edit_text( + text=(script.SHORTLINK_INFO3), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + + elif query.data == "disclaimer": + btn = [[ + InlineKeyboardButton("⇋ ʙᴀᴄᴋ ⇋", callback_data="about") + ]] + reply_markup = InlineKeyboardMarkup(btn) + await query.message.edit_text( + text=(script.DISCLAIMER_TXT), + reply_markup=reply_markup, + parse_mode=enums.ParseMode.HTML + ) + elif query.data.startswith("setgs"): + ident, set_type, status, grp_id = query.data.split("#") + grpid = await active_connection(str(query.from_user.id)) + + if str(grp_id) != str(grpid): + await query.message.edit("Yᴏᴜʀ Aᴄᴛɪᴠᴇ Cᴏɴɴᴇᴄᴛɪᴏɴ Hᴀs Bᴇᴇɴ Cʜᴀɴɢᴇᴅ. Gᴏ Tᴏ /connections ᴀɴᴅ ᴄʜᴀɴɢᴇ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴄᴏɴɴᴇᴄᴛɪᴏɴ.") + return await query.answer(MSG_ALRT) + + if set_type == 'is_shortlink' and query.from_user.id not in ADMINS: + return await query.answer(text=f"Hey {query.from_user.first_name}, You can't change shortlink settings for your group !\n\nIt's an admin only setting !", show_alert=True) + + if status == "True": + await save_group_settings(grpid, set_type, False) + else: + await save_group_settings(grpid, set_type, True) + + settings = await get_settings(grpid) + + if settings is not None: + buttons = [ + [ + InlineKeyboardButton('ʀᴇꜱᴜʟᴛ ᴘᴀɢᴇ', + callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'), + InlineKeyboardButton('ʙᴜᴛᴛᴏɴ' if settings["button"] else 'ᴛᴇxᴛ', + callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜰɪʟᴇ ꜱᴇɴᴅ ᴍᴏᴅᴇ', callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}'), + InlineKeyboardButton('ꜱᴛᴀʀᴛ' if settings["botpm"] else 'ᴀᴜᴛᴏ', + callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜰɪʟᴇ ꜱᴇᴄᴜʀᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["file_secure"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ɪᴍᴅʙ ᴘᴏꜱᴛᴇʀ', callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["imdb"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜱᴘᴇʟʟ ᴄʜᴇᴄᴋ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["spell_check"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴡᴇʟᴄᴏᴍᴇ ᴍꜱɢ', callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["welcome"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["auto_delete"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["auto_ffilter"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ᴍᴀx ʙᴜᴛᴛᴏɴꜱ', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}'), + InlineKeyboardButton('10' if settings["max_btn"] else f'{MAX_B_TN}', + callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('ꜱʜᴏʀᴛʟɪɴᴋ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}'), + InlineKeyboardButton('ᴇɴᴀʙʟᴇ' if settings["is_shortlink"] else 'ᴅɪꜱᴀʙʟᴇ', + callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}') + ], + [ + InlineKeyboardButton('⇋ ᴄʟᴏꜱᴇ ꜱᴇᴛᴛɪɴɢꜱ ᴍᴇɴᴜ ⇋', + callback_data='close_data' + ) + ] + ] + reply_markup = InlineKeyboardMarkup(buttons) + await query.message.edit_reply_markup(reply_markup) + await query.answer(MSG_ALRT) + + +async def auto_filter(client, msg, spoll=False): + curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + # reqstr1 = msg.from_user.id if msg.from_user else 0 + # reqstr = await client.get_users(reqstr1) + + if not spoll: + message = msg + if message.text.startswith("/"): return # ignore commands + if re.findall("((^\/|^,|^!|^\.|^[\U0001F600-\U000E007F]).*)", message.text): + return + if len(message.text) < 100: + search = message.text + m=await message.reply_sticker("CAACAgQAAxkBAAEKSxplArIUActk4ORQuFn3DHFvBqQCOgACBQMAAnJxFyVYcSIunXgGjjAE", + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(f'Seaching for {search} 🔎', url=f"https://t.me/HP_MOVIES_WORLD")]]) + ) + search = search.lower() + find = search.split(" ") + search = "" + removes = ["in","upload", "series", "full", "horror", "thriller", "mystery", "print", "file"] + for x in find: + if x in removes: + continue + else: + search = search + x + " " + search = re.sub(r"\b(pl(i|e)*?(s|z+|ease|se|ese|(e+)s(e)?)|((send|snd|giv(e)?|gib)(\sme)?)|movie(s)?|new|latest|bro|bruh|broh|helo|that|find|dubbed|link|venum|iruka|pannunga|pannungga|anuppunga|anupunga|anuppungga|anupungga|film|undo|kitti|kitty|tharu|kittumo|kittum|movie|any(one)|with\ssubtitle(s)?)", "", search, flags=re.IGNORECASE) + search = re.sub(r"\s+", " ", search).strip() + search = search.replace("-", " ") + search = search.replace(":","") + files, offset, total_results = await get_search_results(message.chat.id ,search, offset=0, filter=True) + settings = await get_settings(message.chat.id) + if not files: + await m.delete() + if settings["spell_check"]: + return await advantage_spell_chok(client, msg) + else: + # if NO_RESULTS_MSG: + # await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, search))) + return + else: + return + else: + message = msg.message.reply_to_message # msg will be callback query + search, files, offset, total_results = spoll + m=await message.reply_sticker("CAACAgQAAxkBAAEKSxplArIUActk4ORQuFn3DHFvBqQCOgACBQMAAnJxFyVYcSIunXgGjjAE", + reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(f'Seaching for {search} 🔎', url=f"https://t.me/HP_MOVIES_WORLD")]]) + ) + settings = await get_settings(message.chat.id) + await msg.message.delete() + pre = 'filep' if settings['file_secure'] else 'file' + key = f"{message.chat.id}-{message.id}" + FRESH[key] = search + temp.GETALL[key] = files + temp.SHORT[message.from_user.id] = message.chat.id + if settings["button"]: + btn = [ + [ + InlineKeyboardButton( + text=f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}' + ), + ] + for file in files + ] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + else: + btn = [] + btn.insert(0, + [ + InlineKeyboardButton("⇈ ꜱᴇʟᴇᴄᴛ ᴏᴘᴛɪᴏɴꜱ ʜᴇʀᴇ ⇈", 'reqinfo') + ] + ) + btn.insert(0, + [ + InlineKeyboardButton(f'ǫᴜᴀʟɪᴛʏ', callback_data=f"qualities#{key}"), + InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇ", callback_data=f"languages#{key}"), + InlineKeyboardButton("ꜱᴇᴀsᴏɴ", callback_data=f"seasons#{key}") + ] + ) + btn.insert(0, [ + InlineKeyboardButton("♨️ ꜱᴇɴᴅ ᴀʟʟ ꜰɪʟᴇꜱ ♨️", callback_data=f"sendfiles#{key}") + ]) + + if offset != "": + req = message.from_user.id if message.from_user else 0 + try: + if settings['max_btn']: + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + else: + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/int(MAX_B_TN))}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + except KeyError: + await save_group_settings(message.chat.id, 'max_btn', True) + btn.append( + [InlineKeyboardButton("ᴘᴀɢᴇ", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="ɴᴇxᴛ ⋟",callback_data=f"next_{req}_{key}_{offset}")] + ) + else: + btn.append( + [InlineKeyboardButton(text="↭ ɴᴏ ᴍᴏʀᴇ ᴘᴀɢᴇꜱ ᴀᴠᴀɪʟᴀʙʟᴇ ↭",callback_data="pages")] + ) + imdb = await get_poster(search, file=(files[0]).file_name) if settings["imdb"] else None + cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time() + time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000))) + remaining_seconds = "{:.2f}".format(time_difference.total_seconds()) + TEMPLATE = script.IMDB_TEMPLATE_TXT + if imdb: + cap = TEMPLATE.format( + qurey=search, + title=imdb['title'], + votes=imdb['votes'], + aka=imdb["aka"], + seasons=imdb["seasons"], + box_office=imdb['box_office'], + localized_title=imdb['localized_title'], + kind=imdb['kind'], + imdb_id=imdb["imdb_id"], + cast=imdb["cast"], + runtime=imdb["runtime"], + countries=imdb["countries"], + certificates=imdb["certificates"], + languages=imdb["languages"], + director=imdb["director"], + writer=imdb["writer"], + producer=imdb["producer"], + composer=imdb["composer"], + cinematographer=imdb["cinematographer"], + music_team=imdb["music_team"], + distributors=imdb["distributors"], + release_date=imdb['release_date'], + year=imdb['year'], + genres=imdb['genres'], + poster=imdb['poster'], + plot=imdb['plot'], + rating=imdb['rating'], + url=imdb['url'], + **locals() + ) + temp.IMDB_CAP[message.from_user.id] = cap + if not settings["button"]: + cap+="\n\n📚 Your Requested Files 👇\n\n" + for file in files: + cap += f"\n 📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n" + else: + if settings["button"]: + cap = f"🧿 ᴛɪᴛʟᴇ : {search}\n📂 ᴛᴏᴛᴀʟ ꜰɪʟᴇꜱ : {total_results}\n📝 ʀᴇǫᴜᴇsᴛᴇᴅ ʙʏ : {message.from_user.mention}\n⏰ ʀᴇsᴜʟᴛ ɪɴ : {remaining_seconds} Sᴇᴄᴏɴᴅs\n⚜️ ᴘᴏᴡᴇʀᴇᴅ ʙʏ : 👇\n⚡ {message.chat.title} \n\n" + else: + cap = f"🧿 ᴛɪᴛʟᴇ : {search}\n📂 ᴛᴏᴛᴀʟ ꜰɪʟᴇꜱ : {total_results}\n📝 ʀᴇǫᴜᴇsᴛᴇᴅ ʙʏ : {message.from_user.mention}\n⏰ ʀᴇsᴜʟᴛ ɪɴ : {remaining_seconds} Sᴇᴄᴏɴᴅs\n⚜️ ᴘᴏᴡᴇʀᴇᴅ ʙʏ : 👇\n⚡ {message.chat.title} \n\n" + # cap+="Hᴇʏ {message.from_user.mention}, Hᴇʀᴇ ɪs ᴛʜᴇ ʀᴇsᴜʟᴛ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {search} \n\n" + for file in files: + cap += f" 📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n" + + if imdb and imdb.get('poster'): + try: + hehe = await message.reply_photo(photo=imdb.get('poster'), caption=cap, reply_markup=InlineKeyboardMarkup(btn)) + await m.delete() + try: + if settings['auto_delete']: + await asyncio.sleep(300) + await hehe.delete() + await message.delete() + except KeyError: + await save_group_settings(message.chat.id, 'auto_delete', True) + await asyncio.sleep(300) + await hehe.delete() + await message.delete() + except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty): + pic = imdb.get('poster') + poster = pic.replace('.jpg', "._V1_UX360.jpg") + hmm = await message.reply_photo(photo=poster, caption=cap, reply_markup=InlineKeyboardMarkup(btn)) + await m.delete() + try: + if settings['auto_delete']: + await asyncio.sleep(300) + m=await message.reply_text("🔎") + await hmm.delete() + await message.delete() + except KeyError: + await save_group_settings(message.chat.id, 'auto_delete', True) + await asyncio.sleep(300) + await hmm.delete() + await message.delete() + except Exception as e: + logger.exception(e) + m=await message.reply_text("🔎") + fek = await message.reply_text(text=cap, reply_markup=InlineKeyboardMarkup(btn)) + await m.delete() + try: + if settings['auto_delete']: + await asyncio.sleep(300) + await fek.delete() + await message.delete() + except KeyError: + await save_group_settings(message.chat.id, 'auto_delete', True) + await asyncio.sleep(300) + await fek.delete() + await message.delete() + else: + fuk = await message.reply_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True) + await m.delete() + try: + if settings['auto_delete']: + await asyncio.sleep(300) + await fuk.delete() + await message.delete() + except KeyError: + await save_group_settings(message.chat.id, 'auto_delete', True) + await asyncio.sleep(300) + await fuk.delete() + await message.delete() + +async def advantage_spell_chok(client, msg): + mv_id = msg.id + mv_rqst = msg.text + reqstr1 = msg.from_user.id if msg.from_user else 0 + reqstr = await client.get_users(reqstr1) + settings = await get_settings(msg.chat.id) + find = mv_rqst.split(" ") + query = "" + removes = ["in","upload", "series", "full", "horror", "thriller", "mystery", "print", "file"] + for x in find: + if x in removes: + continue + else: + query = query + x + " " + query = re.sub(r"\b(pl(i|e)*?(s|z+|ease|se|ese|(e+)s(e)?)|((send|snd|giv(e)?|gib)(\sme)?)|movie(s)?|new|latest|bro|bruh|broh|helo|that|find|dubbed|link|venum|iruka|pannunga|pannungga|anuppunga|anupunga|anuppungga|anupungga|film|undo|kitti|kitty|tharu|kittumo|kittum|movie|any(one)|with\ssubtitle(s)?)", "", query, flags=re.IGNORECASE) + query = re.sub(r"\s+", " ", query).strip() + "movie" + try: + g_s = await search_gagala(query) + g_s += await search_gagala(msg.text) + gs_parsed = [] + if not g_s: + reqst_gle = query.replace(" ", "+") + button = [[ + InlineKeyboardButton("📝 ʀᴇǫᴜᴇꜱᴛ ʜᴇʀᴇ", url=f"https://t.me/HpMovieRequest") + ]] + if NO_RESULTS_MSG: + await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst))) + k = await msg.reply_text( + text=script.I_CUDNT.format(mv_rqst), + reply_markup=InlineKeyboardMarkup(button) + ) + await asyncio.sleep(30) + await k.delete() + return + regex = re.compile(r".*(imdb|wikipedia).*", re.IGNORECASE) # look for imdb / wiki results + gs = list(filter(regex.match, g_s)) + gs_parsed = [re.sub( + r'\b(\-([a-zA-Z-\s])\-\simdb|(\-\s)?imdb|(\-\s)?wikipedia|\(|\)|\-|reviews|full|all|episode(s)?|film|movie|series)', + '', i, flags=re.IGNORECASE) for i in gs] + if not gs_parsed: + reg = re.compile(r"watch(\s[a-zA-Z0-9_\s\-\(\)]*)*\|.*", + re.IGNORECASE) # match something like Watch Niram | Amazon Prime + for mv in g_s: + match = reg.match(mv) + if match: + gs_parsed.append(match.group(1)) + movielist = [] + gs_parsed = list(dict.fromkeys(gs_parsed)) # removing duplicates https://stackoverflow.com/a/7961425 + if len(gs_parsed) > 3: + gs_parsed = gs_parsed[:3] + if gs_parsed: + for mov in gs_parsed: + imdb_s = await get_poster(mov.strip(), bulk=True) # searching each keyword in imdb + if imdb_s: + movielist += [movie.get('title') for movie in imdb_s] + movielist += [(re.sub(r'(\-|\(|\)|_)', '', i, flags=re.IGNORECASE)).strip() for i in gs_parsed] + movielist = list(dict.fromkeys(movielist)) # removing duplicates + if not movielist: + reqst_gle = query.replace(" ", "+") + button = [[ + InlineKeyboardButton("📝 ʀᴇǫᴜᴇꜱᴛ ʜᴇʀᴇ", url=f"https://t.me/HpMovieRequest") + ]] + if NO_RESULTS_MSG: + await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst))) + k = await msg.reply_text( + text=script.I_CUDNT.format(mv_rqst), + reply_markup=InlineKeyboardMarkup(button) + ) + await asyncio.sleep(30) + await k.delete() + return + SPELL_CHECK[mv_id] = movielist + btn = [[ + InlineKeyboardButton( + text=movie.strip(), + callback_data=f"spolling#{reqstr1}#{k}", + ) + ] for k, movie in enumerate(movielist)] + btn.append([InlineKeyboardButton(text="↭ ᴄʟᴏꜱᴇ ↭", callback_data=f'spol#{reqstr1}#close_spellcheck')]) + spell_check_del = await msg.reply_text( + text=script.CUDNT_FND.format(mv_rqst), + reply_markup=InlineKeyboardMarkup(btn) + ) + try: + if settings['auto_delete']: + await asyncio.sleep(60) + await spell_check_del.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(60) + await spell_check_del.delete() + except: + try: + movies = await get_poster(mv_rqst, bulk=True) + except Exception as e: + logger.exception(e) + reqst_gle = mv_rqst.replace(" ", "+") + button = [[ + InlineKeyboardButton("📝 ʀᴇǫᴜᴇꜱᴛ ʜᴇʀᴇ", url=f"https://t.me/HpMovieRequest") + ]] + if NO_RESULTS_MSG: + await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst))) + k = await msg.reply_text( + text=script.I_CUDNT.format(mv_rqst), + reply_markup=InlineKeyboardMarkup(button) + ) + await asyncio.sleep(30) + await k.delete() + return + movielist = [] + if not movies: + reqst_gle = mv_rqst.replace(" ", "+") + button = [[ + InlineKeyboardButton("📝 ʀᴇǫᴜᴇꜱᴛ ʜᴇʀᴇ", url=f"https://t.me/HpMovieRequest") + ]] + if NO_RESULTS_MSG: + await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst))) + k = await msg.reply_text( + text=script.I_CUDNT.format(mv_rqst), + reply_markup=InlineKeyboardMarkup(button) + ) + await asyncio.sleep(30) + await k.delete() + return + movielist += [movie.get('title') for movie in movies] + movielist += [f"{movie.get('title')} {movie.get('year')}" for movie in movies] + SPELL_CHECK[mv_id] = movielist + btn = [ + [ + InlineKeyboardButton( + text=movie_name.strip(), + callback_data=f"spol#{reqstr1}#{k}", + ) + ] + for k, movie_name in enumerate(movielist) + ] + btn.append([InlineKeyboardButton(text="↭ ᴄʟᴏꜱᴇ ↭", callback_data=f'spol#{reqstr1}#close_spellcheck')]) + spell_check_del = await msg.reply_text( + text=script.CUDNT_FND.format(mv_rqst), + reply_markup=InlineKeyboardMarkup(btn) + ) + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await spell_check_del.delete() + except KeyError: + grpid = await active_connection(str(msg.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(msg.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await spell_check_del.delete() + + +async def manual_filters(client, message, text=False): + settings = await get_settings(message.chat.id) + group_id = message.chat.id + name = text or message.text + reply_id = message.reply_to_message.id if message.reply_to_message else message.id + keywords = await get_filters(group_id) + for keyword in reversed(sorted(keywords, key=len)): + pattern = r"( |^|[^\w])" + re.escape(keyword) + r"( |$|[^\w])" + if re.search(pattern, name, flags=re.IGNORECASE): + reply_text, btn, alert, fileid = await find_filter(group_id, keyword) + + if reply_text: + reply_text = reply_text.replace("\\n", "\n").replace("\\t", "\t") + + if btn is not None: + try: + if fileid == "None": + if btn == "[]": + joelkb = await client.send_message( + group_id, + reply_text, + disable_web_page_preview=True, + protect_content=True if settings["file_secure"] else False, + reply_to_message_id=reply_id + ) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + + else: + button = eval(btn) + joelkb = await client.send_message( + group_id, + reply_text, + disable_web_page_preview=True, + reply_markup=InlineKeyboardMarkup(button), + protect_content=True if settings["file_secure"] else False, + reply_to_message_id=reply_id + ) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + + elif btn == "[]": + joelkb = await client.send_cached_media( + group_id, + fileid, + caption=reply_text or "", + protect_content=True if settings["file_secure"] else False, + reply_to_message_id=reply_id + ) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + + else: + button = eval(btn) + joelkb = await message.reply_cached_media( + fileid, + caption=reply_text or "", + reply_markup=InlineKeyboardMarkup(button), + reply_to_message_id=reply_id + ) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + + except Exception as e: + logger.exception(e) + break + else: + return False + +async def global_filters(client, message, text=False): + settings = await get_settings(message.chat.id) + group_id = message.chat.id + name = text or message.text + reply_id = message.reply_to_message.id if message.reply_to_message else message.id + keywords = await get_gfilters('gfilters') + for keyword in reversed(sorted(keywords, key=len)): + pattern = r"( |^|[^\w])" + re.escape(keyword) + r"( |$|[^\w])" + if re.search(pattern, name, flags=re.IGNORECASE): + reply_text, btn, alert, fileid = await find_gfilter('gfilters', keyword) + + if reply_text: + reply_text = reply_text.replace("\\n", "\n").replace("\\t", "\t") + + if btn is not None: + try: + if fileid == "None": + if btn == "[]": + joelkb = await client.send_message( + group_id, + reply_text, + disable_web_page_preview=True, + reply_to_message_id=reply_id + ) + manual = await manual_filters(client, message) + if manual == False: + settings = await get_settings(message.chat.id) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + else: + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + + else: + button = eval(btn) + joelkb = await client.send_message( + group_id, + reply_text, + disable_web_page_preview=True, + reply_markup=InlineKeyboardMarkup(button), + reply_to_message_id=reply_id + ) + manual = await manual_filters(client, message) + if manual == False: + settings = await get_settings(message.chat.id) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + else: + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + + elif btn == "[]": + joelkb = await client.send_cached_media( + group_id, + fileid, + caption=reply_text or "", + reply_to_message_id=reply_id + ) + manual = await manual_filters(client, message) + if manual == False: + settings = await get_settings(message.chat.id) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + else: + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + + else: + button = eval(btn) + joelkb = await message.reply_cached_media( + fileid, + caption=reply_text or "", + reply_markup=InlineKeyboardMarkup(button), + reply_to_message_id=reply_id + ) + manual = await manual_filters(client, message) + if manual == False: + settings = await get_settings(message.chat.id) + try: + if settings['auto_ffilter']: + await auto_filter(client, message) + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + else: + try: + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await asyncio.sleep(600) + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_ffilter', True) + settings = await get_settings(message.chat.id) + if settings['auto_ffilter']: + await auto_filter(client, message) + else: + try: + if settings['auto_delete']: + await joelkb.delete() + except KeyError: + grpid = await active_connection(str(message.from_user.id)) + await save_group_settings(grpid, 'auto_delete', True) + settings = await get_settings(message.chat.id) + if settings['auto_delete']: + await joelkb.delete() + + + except Exception as e: + logger.exception(e) + break + else: + return False diff --git a/plugins/route.py b/plugins/route.py new file mode 100644 index 0000000000000000000000000000000000000000..6907189a7f41d9b6db4d2c6b4faf4c7d898a4751 --- /dev/null +++ b/plugins/route.py @@ -0,0 +1,152 @@ +from aiohttp import web +import re +import math +import logging +import secrets +import time +import mimetypes +from aiohttp.http_exceptions import BadStatusLine +from lazybot import multi_clients, work_loads, LazyPrincessBot +from server.exceptions import FIleNotFound, InvalidHash +from zzint import StartTime, __version__ +from util.custom_dl import ByteStreamer +from util.time_format import get_readable_time +from util.render_template import render_page +from info import * + + +routes = web.RouteTableDef() + +@routes.get("/", allow_head=True) +async def root_route_handler(request): + return web.json_response("BenFilterBot") + + +@routes.get(r"/watch/{path:\S+}", allow_head=True) +async def stream_handler(request: web.Request): + try: + path = request.match_info["path"] + match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path) + if match: + secure_hash = match.group(1) + id = int(match.group(2)) + else: + id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1)) + secure_hash = request.rel_url.query.get("hash") + return web.Response(text=await render_page(id, secure_hash), content_type='text/html') + except InvalidHash as e: + raise web.HTTPForbidden(text=e.message) + except FIleNotFound as e: + raise web.HTTPNotFound(text=e.message) + except (AttributeError, BadStatusLine, ConnectionResetError): + pass + except Exception as e: + logging.critical(e.with_traceback(None)) + raise web.HTTPInternalServerError(text=str(e)) + +@routes.get(r"/{path:\S+}", allow_head=True) +async def stream_handler(request: web.Request): + try: + path = request.match_info["path"] + match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path) + if match: + secure_hash = match.group(1) + id = int(match.group(2)) + else: + id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1)) + secure_hash = request.rel_url.query.get("hash") + return await media_streamer(request, id, secure_hash) + except InvalidHash as e: + raise web.HTTPForbidden(text=e.message) + except FIleNotFound as e: + raise web.HTTPNotFound(text=e.message) + except (AttributeError, BadStatusLine, ConnectionResetError): + pass + except Exception as e: + logging.critical(e.with_traceback(None)) + raise web.HTTPInternalServerError(text=str(e)) + +class_cache = {} + +async def media_streamer(request: web.Request, id: int, secure_hash: str): + range_header = request.headers.get("Range", 0) + + index = min(work_loads, key=work_loads.get) + faster_client = multi_clients[index] + + if MULTI_CLIENT: + logging.info(f"Client {index} is now serving {request.remote}") + + if faster_client in class_cache: + tg_connect = class_cache[faster_client] + logging.debug(f"Using cached ByteStreamer object for client {index}") + else: + logging.debug(f"Creating new ByteStreamer object for client {index}") + tg_connect = ByteStreamer(faster_client) + class_cache[faster_client] = tg_connect + logging.debug("before calling get_file_properties") + file_id = await tg_connect.get_file_properties(id) + logging.debug("after calling get_file_properties") + + if file_id.unique_id[:6] != secure_hash: + logging.debug(f"Invalid hash for message with ID {id}") + raise InvalidHash + + file_size = file_id.file_size + + if range_header: + from_bytes, until_bytes = range_header.replace("bytes=", "").split("-") + from_bytes = int(from_bytes) + until_bytes = int(until_bytes) if until_bytes else file_size - 1 + else: + from_bytes = request.http_range.start or 0 + until_bytes = (request.http_range.stop or file_size) - 1 + + if (until_bytes > file_size) or (from_bytes < 0) or (until_bytes < from_bytes): + return web.Response( + status=416, + body="416: Range not satisfiable", + headers={"Content-Range": f"bytes */{file_size}"}, + ) + + chunk_size = 1024 * 1024 + until_bytes = min(until_bytes, file_size - 1) + + offset = from_bytes - (from_bytes % chunk_size) + first_part_cut = from_bytes - offset + last_part_cut = until_bytes % chunk_size + 1 + + req_length = until_bytes - from_bytes + 1 + part_count = math.ceil(until_bytes / chunk_size) - math.floor(offset / chunk_size) + body = tg_connect.yield_file( + file_id, index, offset, first_part_cut, last_part_cut, part_count, chunk_size + ) + + mime_type = file_id.mime_type + file_name = file_id.file_name + disposition = "attachment" + + if mime_type: + if not file_name: + try: + file_name = f"{secrets.token_hex(2)}.{mime_type.split('/')[1]}" + except (IndexError, AttributeError): + file_name = f"{secrets.token_hex(2)}.unknown" + else: + if file_name: + mime_type = mimetypes.guess_type(file_id.file_name) + else: + mime_type = "application/octet-stream" + file_name = f"{secrets.token_hex(2)}.unknown" + + return web.Response( + status=206 if range_header else 200, + body=body, + headers={ + "Content-Type": f"{mime_type}", + "Content-Range": f"bytes {from_bytes}-{until_bytes}/{file_size}", + "Content-Length": str(req_length), + "Content-Disposition": f'{disposition}; filename="{file_name}"', + "Accept-Ranges": "bytes", + }, + ) diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8707a144e0af6af324174b2d8c08ae6376dc052e --- /dev/null +++ b/render.yaml @@ -0,0 +1,15 @@ +services: + # A Docker web service + - type: web + name: TheMovieProviderBot + env: python + startCommand: python3 bot.py + buildCommand: pip3 install -U -r requirements.txt + repo: https://github.com/HarshalPurohitEdits/TheMovieProviderBot.git # optional + region: oregon # optional (defaults to oregon) + plan: free # optional (defaults to starter) + branch: main # optional (defaults to master) + numInstances: 1 # optional (defaults to 1) + healthCheckPath: / + +#End of yaml diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..1569dd8e5ea9b93696d8d6cad4e20b50cc01caa2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +gradio +python-telegram-bot==13.15 +pymongo diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000000000000000000000000000000000000..69b0ccfc826ccfe406ab3433e8a092085309f8e2 --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.10.8 diff --git a/server/TheMovieProviderBot b/server/TheMovieProviderBot new file mode 100644 index 0000000000000000000000000000000000000000..321dee3414475db727d64d926b45e687c625cd74 --- /dev/null +++ b/server/TheMovieProviderBot @@ -0,0 +1,153 @@ + + + +# import re +# import math +# import logging +# import secrets +# import mimetypes +# from aiohttp import web +# from aiohttp.http_exceptions import BadStatusLine +# from lazybot import multi_clients, work_loads, StreamBot +# from server.exceptions import FIleNotFound, InvalidHash +# from zzint import StartTime, __version__ +# from ..util.custom_dl import ByteStreamer +# from util.render_template import render_page +# from info import * + + +# routes = web.RouteTableDef() + +# @routes.get("/", allow_head=True) +# async def root_route_handler(request): +# return web.json_response("in & as LazyDeveloper...") + + +# @routes.get(r"/watch/{path:\S+}", allow_head=True) +# async def stream_handler(request: web.Request): +# try: +# path = request.match_info["path"] +# match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path) +# if match: +# secure_hash = match.group(1) +# id = int(match.group(2)) +# else: +# id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1)) +# secure_hash = request.rel_url.query.get("hash") +# return web.Response(text=await render_page(id, secure_hash), content_type='text/html') +# except InvalidHash as e: +# raise web.HTTPForbidden(text=e.message) +# except FIleNotFound as e: +# raise web.HTTPNotFound(text=e.message) +# except (AttributeError, BadStatusLine, ConnectionResetError): +# pass +# except Exception as e: +# logging.critical(e.with_traceback(None)) +# raise web.HTTPInternalServerError(text=str(e)) + +# @routes.get(r"/{path:\S+}", allow_head=True) +# async def stream_handler(request: web.Request): +# try: +# path = request.match_info["path"] +# match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path) +# if match: +# secure_hash = match.group(1) +# id = int(match.group(2)) +# else: +# id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1)) +# secure_hash = request.rel_url.query.get("hash") +# return await media_streamer(request, id, secure_hash) +# except InvalidHash as e: +# raise web.HTTPForbidden(text=e.message) +# except FIleNotFound as e: +# raise web.HTTPNotFound(text=e.message) +# except (AttributeError, BadStatusLine, ConnectionResetError): +# pass +# except Exception as e: +# logging.critical(e.with_traceback(None)) +# raise web.HTTPInternalServerError(text=str(e)) + +# class_cache = {} + +# async def media_streamer(request: web.Request, id: int, secure_hash: str): +# range_header = request.headers.get("Range", 0) + +# index = min(work_loads, key=work_loads.get) +# faster_client = multi_clients[index] + +# if MULTI_CLIENT: +# logging.info(f"Client {index} is now serving {request.remote}") + +# if faster_client in class_cache: +# tg_connect = class_cache[faster_client] +# logging.debug(f"Using cached ByteStreamer object for client {index}") +# else: +# logging.debug(f"Creating new ByteStreamer object for client {index}") +# tg_connect = ByteStreamer(faster_client) +# class_cache[faster_client] = tg_connect +# logging.debug("before calling get_file_properties") +# file_id = await tg_connect.get_file_properties(id) +# logging.debug("after calling get_file_properties") + +# if file_id.unique_id[:6] != secure_hash: +# logging.debug(f"Invalid hash for message with ID {id}") +# raise InvalidHash + +# file_size = file_id.file_size + +# if range_header: +# from_bytes, until_bytes = range_header.replace("bytes=", "").split("-") +# from_bytes = int(from_bytes) +# until_bytes = int(until_bytes) if until_bytes else file_size - 1 +# else: +# from_bytes = request.http_range.start or 0 +# until_bytes = (request.http_range.stop or file_size) - 1 + +# if (until_bytes > file_size) or (from_bytes < 0) or (until_bytes < from_bytes): +# return web.Response( +# status=416, +# body="416: Range not satisfiable", +# headers={"Content-Range": f"bytes */{file_size}"}, +# ) + +# chunk_size = 1024 * 1024 +# until_bytes = min(until_bytes, file_size - 1) + +# offset = from_bytes - (from_bytes % chunk_size) +# first_part_cut = from_bytes - offset +# last_part_cut = until_bytes % chunk_size + 1 + +# req_length = until_bytes - from_bytes + 1 +# part_count = math.ceil(until_bytes / chunk_size) - math.floor(offset / chunk_size) +# body = tg_connect.yield_file( +# file_id, index, offset, first_part_cut, last_part_cut, part_count, chunk_size +# ) + +# mime_type = file_id.mime_type +# file_name = file_id.file_name +# disposition = "attachment" + +# if mime_type: +# if not file_name: +# try: +# file_name = f"{secrets.token_hex(2)}.{mime_type.split('/')[1]}" +# except (IndexError, AttributeError): +# file_name = f"{secrets.token_hex(2)}.unknown" +# else: +# if file_name: +# mime_type = mimetypes.guess_type(file_id.file_name) +# else: +# mime_type = "application/octet-stream" +# file_name = f"{secrets.token_hex(2)}.unknown" + +# return web.Response( +# status=206 if range_header else 200, +# body=body, +# headers={ +# "Content-Type": f"{mime_type}", +# "Content-Range": f"bytes {from_bytes}-{until_bytes}/{file_size}", +# "Content-Length": str(req_length), +# "Content-Disposition": f'{disposition}; filename="{file_name}"', +# "Accept-Ranges": "bytes", +# }, +# ) diff --git a/server/__init__.py b/server/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f1cb9cef876ae8ce06218060d2cdc7e4e2704911 --- /dev/null +++ b/server/__init__.py @@ -0,0 +1 @@ +# Made with Love by HP diff --git a/server/exceptions.py b/server/exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..b60f495ae620143f0dd1bfe7e656dceba55ee3f9 --- /dev/null +++ b/server/exceptions.py @@ -0,0 +1,5 @@ +class InvalidHash(Exception): + message = "Invalid hash" + +class FIleNotFound(Exception): + message = "File not found" diff --git a/start.sh b/start.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed23dfd5bae0ee54371b5f09c151d3b8a6040287 --- /dev/null +++ b/start.sh @@ -0,0 +1,12 @@ +if [ -z $UPSTREAM_REPO ] +then + echo "Cloning main Repository" + git clone https://github.com/HarshalPurohitEdits/TheMovieProviderBot.git /TheMovieProviderBot +else + echo "Cloning Custom Repo from $UPSTREAM_REPO " + git clone $UPSTREAM_REPO /TheMovieProviderBot +fi +cd /TheMovieProviderBot +pip3 install -U -r requirements.txt +echo "Starting TheMovieProviderBot...." +python3 bot.py diff --git a/template/dl.html b/template/dl.html new file mode 100644 index 0000000000000000000000000000000000000000..c37d285e3ff531b14bc8be5a8a9f2fe352e6701d --- /dev/null +++ b/template/dl.html @@ -0,0 +1,197 @@ + + + + + + + + + + + {{file_name}} + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+
+ +
+
+

File name :

+
+

{{file_name}}

+
+
+ + + + + + + +
+ +
+
+
+
+
+

WELCOME TO OUR STREAMING WEBSITE

+

+ We're + thrilled to have you here. + Get ready for an + amazing experience + filled with entertainment, fun, and surprises. + Grab + your snacks, sit back, and enjoy the show ! +

+
+ +
+

OUR ALL BOTS LIST

+ +
+
+ + + +

YOU CAN TALK WITH US FOR YOUR SUPPORT AND YOU CAN REPORT THROUGH + TELEGRAM

+ +
+
+
+
+
+
+
+

VISIT OUR BOT + FOR + MORE + INFO

+
+ +
+

+ Welcome to our online streaming platform! Our website allows users to generate streamable links for + various files using Telegram bot. Please note that we are not responsible for the content shared or + streamed through our service. Users are encouraged to respect copyright laws and adhere to our + community + guidelines. Enjoy easy, hassle-free file streaming service. +

+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/template/req.html b/template/req.html new file mode 100644 index 0000000000000000000000000000000000000000..c37d285e3ff531b14bc8be5a8a9f2fe352e6701d --- /dev/null +++ b/template/req.html @@ -0,0 +1,197 @@ + + + + + + + + + + + {{file_name}} + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+
+ +
+
+

File name :

+
+

{{file_name}}

+
+
+ + + + + + + +
+ +
+
+
+
+
+

WELCOME TO OUR STREAMING WEBSITE

+

+ We're + thrilled to have you here. + Get ready for an + amazing experience + filled with entertainment, fun, and surprises. + Grab + your snacks, sit back, and enjoy the show ! +

+
+ +
+

OUR ALL BOTS LIST

+ +
+
+ + + +

YOU CAN TALK WITH US FOR YOUR SUPPORT AND YOU CAN REPORT THROUGH + TELEGRAM

+ +
+
+
+
+
+
+
+

VISIT OUR BOT + FOR + MORE + INFO

+
+ +
+

+ Welcome to our online streaming platform! Our website allows users to generate streamable links for + various files using Telegram bot. Please note that we are not responsible for the content shared or + streamed through our service. Users are encouraged to respect copyright laws and adhere to our + community + guidelines. Enjoy easy, hassle-free file streaming service. +

+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/util/__init__.py b/util/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d9683e9861f092c605a52825b946d05981f606c1 --- /dev/null +++ b/util/__init__.py @@ -0,0 +1 @@ +# Made with love by HP diff --git a/util/config_parser.py b/util/config_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..582eedd5913ca5cd35516b011d4ddcce4c8692a9 --- /dev/null +++ b/util/config_parser.py @@ -0,0 +1,20 @@ +#Thanks @DeletedFromEarth for helping in this journey +from os import environ +from typing import Dict, Optional + + +class TokenParser: + def __init__(self, config_file: Optional[str] = None): + self.tokens = {} + self.config_file = config_file + + def parse_from_env(self) -> Dict[int, str]: + self.tokens = dict( + (c + 1, t) + for c, (_, t) in enumerate( + filter( + lambda n: n[0].startswith("MULTI_TOKEN"), sorted(environ.items()) + ) + ) + ) + return self.tokens diff --git a/util/custom_dl.py b/util/custom_dl.py new file mode 100644 index 0000000000000000000000000000000000000000..59424fc4fad1d41813763f95578318d033b404ec --- /dev/null +++ b/util/custom_dl.py @@ -0,0 +1,232 @@ +#Thanks @DeletedFromEarth for helping in this journey +import math +import asyncio +import logging +from info import * +from typing import Dict, Union +from lazybot import work_loads +from pyrogram import Client, utils, raw +from .file_properties import get_file_ids +from pyrogram.session import Session, Auth +from pyrogram.errors import AuthBytesInvalid +from server.exceptions import FIleNotFound +from pyrogram.file_id import FileId, FileType, ThumbnailSource + + +class ByteStreamer: + def __init__(self, client: Client): + """A custom class that holds the cache of a specific client and class functions. + attributes: + client: the client that the cache is for. + cached_file_ids: a dict of cached file IDs. + cached_file_properties: a dict of cached file properties. + + functions: + generate_file_properties: returns the properties for a media of a specific message contained in Tuple. + generate_media_session: returns the media session for the DC that contains the media file. + yield_file: yield a file from telegram servers for streaming. + + This is a modified version of the + Thanks to Eyaadh + """ + self.clean_timer = 30 * 60 + self.client: Client = client + self.cached_file_ids: Dict[int, FileId] = {} + asyncio.create_task(self.clean_cache()) + + async def get_file_properties(self, id: int) -> FileId: + """ + Returns the properties of a media of a specific message in a FIleId class. + if the properties are cached, then it'll return the cached results. + or it'll generate the properties from the Message ID and cache them. + """ + if id not in self.cached_file_ids: + await self.generate_file_properties(id) + logging.debug(f"Cached file properties for message with ID {id}") + return self.cached_file_ids[id] + + async def generate_file_properties(self, id: int) -> FileId: + """ + Generates the properties of a media file on a specific message. + returns ths properties in a FIleId class. + """ + file_id = await get_file_ids(self.client, LOG_CHANNEL, id) + logging.debug(f"Generated file ID and Unique ID for message with ID {id}") + if not file_id: + logging.debug(f"Message with ID {id} not found") + raise FIleNotFound + self.cached_file_ids[id] = file_id + logging.debug(f"Cached media message with ID {id}") + return self.cached_file_ids[id] + + async def generate_media_session(self, client: Client, file_id: FileId) -> Session: + """ + Generates the media session for the DC that contains the media file. + This is required for getting the bytes from Telegram servers. + """ + + media_session = client.media_sessions.get(file_id.dc_id, None) + + if media_session is None: + if file_id.dc_id != await client.storage.dc_id(): + media_session = Session( + client, + file_id.dc_id, + await Auth( + client, file_id.dc_id, await client.storage.test_mode() + ).create(), + await client.storage.test_mode(), + is_media=True, + ) + await media_session.start() + + for _ in range(6): + exported_auth = await client.invoke( + raw.functions.auth.ExportAuthorization(dc_id=file_id.dc_id) + ) + + try: + await media_session.send( + raw.functions.auth.ImportAuthorization( + id=exported_auth.id, bytes=exported_auth.bytes + ) + ) + break + except AuthBytesInvalid: + logging.debug( + f"Invalid authorization bytes for DC {file_id.dc_id}" + ) + continue + else: + await media_session.stop() + raise AuthBytesInvalid + else: + media_session = Session( + client, + file_id.dc_id, + await client.storage.auth_key(), + await client.storage.test_mode(), + is_media=True, + ) + await media_session.start() + logging.debug(f"Created media session for DC {file_id.dc_id}") + client.media_sessions[file_id.dc_id] = media_session + else: + logging.debug(f"Using cached media session for DC {file_id.dc_id}") + return media_session + + + @staticmethod + async def get_location(file_id: FileId) -> Union[raw.types.InputPhotoFileLocation, + raw.types.InputDocumentFileLocation, + raw.types.InputPeerPhotoFileLocation,]: + """ + Returns the file location for the media file. + """ + file_type = file_id.file_type + + if file_type == FileType.CHAT_PHOTO: + if file_id.chat_id > 0: + peer = raw.types.InputPeerUser( + user_id=file_id.chat_id, access_hash=file_id.chat_access_hash + ) + else: + if file_id.chat_access_hash == 0: + peer = raw.types.InputPeerChat(chat_id=-file_id.chat_id) + else: + peer = raw.types.InputPeerChannel( + channel_id=utils.get_channel_id(file_id.chat_id), + access_hash=file_id.chat_access_hash, + ) + + location = raw.types.InputPeerPhotoFileLocation( + peer=peer, + volume_id=file_id.volume_id, + local_id=file_id.local_id, + big=file_id.thumbnail_source == ThumbnailSource.CHAT_PHOTO_BIG, + ) + elif file_type == FileType.PHOTO: + location = raw.types.InputPhotoFileLocation( + id=file_id.media_id, + access_hash=file_id.access_hash, + file_reference=file_id.file_reference, + thumb_size=file_id.thumbnail_size, + ) + else: + location = raw.types.InputDocumentFileLocation( + id=file_id.media_id, + access_hash=file_id.access_hash, + file_reference=file_id.file_reference, + thumb_size=file_id.thumbnail_size, + ) + return location + + async def yield_file( + self, + file_id: FileId, + index: int, + offset: int, + first_part_cut: int, + last_part_cut: int, + part_count: int, + chunk_size: int, + ) -> Union[str, None]: + """ + Custom generator that yields the bytes of the media file. + Modded from + Thanks to Eyaadh + """ + client = self.client + work_loads[index] += 1 + logging.debug(f"Starting to yielding file with client {index}.") + media_session = await self.generate_media_session(client, file_id) + + current_part = 1 + location = await self.get_location(file_id) + + try: + r = await media_session.send( + raw.functions.upload.GetFile( + location=location, offset=offset, limit=chunk_size + ), + ) + if isinstance(r, raw.types.upload.File): + while True: + chunk = r.bytes + if not chunk: + break + elif part_count == 1: + yield chunk[first_part_cut:last_part_cut] + elif current_part == 1: + yield chunk[first_part_cut:] + elif current_part == part_count: + yield chunk[:last_part_cut] + else: + yield chunk + + current_part += 1 + offset += chunk_size + + if current_part > part_count: + break + + r = await media_session.send( + raw.functions.upload.GetFile( + location=location, offset=offset, limit=chunk_size + ), + ) + except (TimeoutError, AttributeError): + pass + finally: + logging.debug("Finished yielding file with {current_part} parts.") + work_loads[index] -= 1 + + + async def clean_cache(self) -> None: + """ + function to clean the cache to reduce memory usage + """ + while True: + await asyncio.sleep(self.clean_timer) + self.cached_file_ids.clear() + logging.debug("Cleaned the cache") diff --git a/util/file_properties.py b/util/file_properties.py new file mode 100644 index 0000000000000000000000000000000000000000..15a0153fa1d0e6e139dbd1b9c18ad0bf83311784 --- /dev/null +++ b/util/file_properties.py @@ -0,0 +1,60 @@ +#Thanks @DeletedFromEarth for helping in this journey +from pyrogram import Client +from typing import Any, Optional +from pyrogram.types import Message +from pyrogram.file_id import FileId +from pyrogram.raw.types.messages import Messages +from server.exceptions import FIleNotFound + + +async def parse_file_id(message: "Message") -> Optional[FileId]: + media = get_media_from_message(message) + if media: + return FileId.decode(media.file_id) + +async def parse_file_unique_id(message: "Messages") -> Optional[str]: + media = get_media_from_message(message) + if media: + return media.file_unique_id + +async def get_file_ids(client: Client, chat_id: int, id: int) -> Optional[FileId]: + message = await client.get_messages(chat_id, id) + if message.empty: + raise FIleNotFound + media = get_media_from_message(message) + file_unique_id = await parse_file_unique_id(message) + file_id = await parse_file_id(message) + setattr(file_id, "file_size", getattr(media, "file_size", 0)) + setattr(file_id, "mime_type", getattr(media, "mime_type", "")) + setattr(file_id, "file_name", getattr(media, "file_name", "")) + setattr(file_id, "unique_id", file_unique_id) + return file_id + +def get_media_from_message(message: "Message") -> Any: + media_types = ( + "audio", + "document", + "photo", + "sticker", + "animation", + "video", + "voice", + "video_note", + ) + for attr in media_types: + media = getattr(message, attr, None) + if media: + return media + + +def get_hash(media_msg: Message) -> str: + media = get_media_from_message(media_msg) + return getattr(media, "file_unique_id", "")[:6] + +def get_name(media_msg: Message) -> str: + media = get_media_from_message(media_msg) + return getattr(media, 'file_name', "") + +def get_media_file_size(m): + media = get_media_from_message(m) + return getattr(media, "file_size", 0) diff --git a/util/file_size.py b/util/file_size.py new file mode 100644 index 0000000000000000000000000000000000000000..acf90e62eafc354b2635baafa613d7cd8a2c2000 --- /dev/null +++ b/util/file_size.py @@ -0,0 +1,4 @@ +#Thanks @DeletedFromEarth for helping in this journey +def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']): + """ Returns a human readable string representation of bytes """ + return str(bytes) + units[0] if int(bytes) < 1024 else human_size(int(bytes)>>10, units[1:]) diff --git a/util/human_readable.py b/util/human_readable.py new file mode 100644 index 0000000000000000000000000000000000000000..7d80d0b7c7a260648f0342ca83474ea00ad57557 --- /dev/null +++ b/util/human_readable.py @@ -0,0 +1,13 @@ +#Thanks @DeletedFromEarth for helping in this journey +def humanbytes(size): + # https://stackoverflow.com/a/49361727/4723940 + # 2**10 = 1024 + if not size: + return "" + power = 2**10 + n = 0 + Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'} + while size > power: + size /= power + n += 1 + return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' diff --git a/util/keepalive.py b/util/keepalive.py new file mode 100644 index 0000000000000000000000000000000000000000..c8cf911d8c3912eaa0769b9b6e4f6da175f1bd22 --- /dev/null +++ b/util/keepalive.py @@ -0,0 +1,22 @@ +#Thanks @DeletedFromEarth for helping in this journey +import asyncio +import logging +import aiohttp +import traceback +from info import * + + +async def ping_server(): + sleep_time = PING_INTERVAL + while True: + await asyncio.sleep(sleep_time) + try: + async with aiohttp.ClientSession( + timeout=aiohttp.ClientTimeout(total=10) + ) as session: + async with session.get(URL) as resp: + logging.info("Pinged server with response: {}".format(resp.status)) + except TimeoutError: + logging.warning("Couldn't connect to the site URL..!") + except Exception: + traceback.print_exc() diff --git a/util/render_template.py b/util/render_template.py new file mode 100644 index 0000000000000000000000000000000000000000..696abe05688cc302fe438ffb280010d8a9b061a7 --- /dev/null +++ b/util/render_template.py @@ -0,0 +1,47 @@ +#Thanks @DeletedFromEarth for helping in this journey + +import jinja2 +from info import * +from lazybot import LazyPrincessBot +from util.human_readable import humanbytes +from util.file_properties import get_file_ids +from server.exceptions import InvalidHash +import urllib.parse +import logging +import aiohttp + + +async def render_page(id, secure_hash, src=None): + file = await LazyPrincessBot.get_messages(int(LOG_CHANNEL), int(id)) + file_data = await get_file_ids(LazyPrincessBot, int(LOG_CHANNEL), int(id)) + if file_data.unique_id[:6] != secure_hash: + logging.debug(f"link hash: {secure_hash} - {file_data.unique_id[:6]}") + logging.debug(f"Invalid hash for message with - ID {id}") + raise InvalidHash + + src = urllib.parse.urljoin( + URL, + f"{id}/{urllib.parse.quote_plus(file_data.file_name)}?hash={secure_hash}", + ) + + tag = file_data.mime_type.split("/")[0].strip() + file_size = humanbytes(file_data.file_size) + if tag in ["video", "audio"]: + template_file = "template/req.html" + else: + template_file = "template/dl.html" + async with aiohttp.ClientSession() as s: + async with s.get(src) as u: + file_size = humanbytes(int(u.headers.get("Content-Length"))) + + with open(template_file) as f: + template = jinja2.Template(f.read()) + + file_name = file_data.file_name.replace("_", " ") + + return template.render( + file_name=file_name, + file_url=src, + file_size=file_size, + file_unique_id=file_data.unique_id, + ) diff --git a/util/time_format.py b/util/time_format.py new file mode 100644 index 0000000000000000000000000000000000000000..c261dd65ecb6fc914138d43ce4185d08746feedd --- /dev/null +++ b/util/time_format.py @@ -0,0 +1,24 @@ +#Thanks @DeletedFromEarth for helping in this journey + +def get_readable_time(seconds: int) -> str: + count = 0 + readable_time = "" + time_list = [] + time_suffix_list = ["s", "m", "h", " days"] + while count < 4: + count += 1 + if count < 3: + remainder, result = divmod(seconds, 60) + else: + remainder, result = divmod(seconds, 24) + if seconds == 0 and remainder == 0: + break + time_list.append(int(result)) + seconds = int(remainder) + for x in range(len(time_list)): + time_list[x] = str(time_list[x]) + time_suffix_list[x] + if len(time_list) == 4: + readable_time += time_list.pop() + ", " + time_list.reverse() + readable_time += ": ".join(time_list) + return readable_time diff --git a/utils.py b/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..53f7fa04040d97950405415574b62956197e9f23 --- /dev/null +++ b/utils.py @@ -0,0 +1,779 @@ +import logging +from pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid +from info import AUTH_CHANNEL, LONG_IMDB_DESCRIPTION, MAX_LIST_ELM, SHORTLINK_URL, SHORTLINK_API, IS_SHORTLINK, LOG_CHANNEL, TUTORIAL, GRP_LNK, CHNL_LNK, CUSTOM_FILE_CAPTION +from imdb import Cinemagoer +import asyncio +from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup +from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid +from pyrogram import enums +from typing import Union +from Script import script +import pytz +import random +import re +import os +from datetime import datetime, date +import string +from typing import List +from database.users_chats_db import db +from bs4 import BeautifulSoup +import requests +import aiohttp +from shortzy import Shortzy +import http.client +import json + +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) + +BTN_URL_REGEX = re.compile( + r"(\[([^\[]+?)\]\((buttonurl|buttonalert):(?:/{0,2})(.+?)(:same)?\))" +) + +imdb = Cinemagoer() +TOKENS = {} +VERIFIED = {} +BANNED = {} +SECOND_SHORTENER = {} +SMART_OPEN = '“' +SMART_CLOSE = '”' +START_CHAR = ('\'', '"', SMART_OPEN) + +# temp db for banned +class temp(object): + BANNED_USERS = [] + BANNED_CHATS = [] + ME = None + CURRENT=int(os.environ.get("SKIP", 2)) + CANCEL = False + MELCOW = {} + U_NAME = None + B_NAME = None + GETALL = {} + SHORT = {} + SETTINGS = {} + IMDB_CAP = {} + +async def is_req_subscribed(bot, query): + if await db.find_join_req(query.from_user.id): + return True + try: + user = await bot.get_chat_member(AUTH_CHANNEL, query.from_user.id) + except UserNotParticipant: + pass + except Exception as e: + logger.exception(e) + else: + if user.status != enums.ChatMemberStatus.BANNED: + return True + + return False + +async def get_poster(query, bulk=False, id=False, file=None): + if not id: + # https://t.me/GetTGLink/4183 + query = (query.strip()).lower() + title = query + year = re.findall(r'[1-2]\d{3}$', query, re.IGNORECASE) + if year: + year = list_to_str(year[:1]) + title = (query.replace(year, "")).strip() + elif file is not None: + year = re.findall(r'[1-2]\d{3}', file, re.IGNORECASE) + if year: + year = list_to_str(year[:1]) + else: + year = None + movieid = imdb.search_movie(title.lower(), results=10) + if not movieid: + return None + if year: + filtered=list(filter(lambda k: str(k.get('year')) == str(year), movieid)) + if not filtered: + filtered = movieid + else: + filtered = movieid + movieid=list(filter(lambda k: k.get('kind') in ['movie', 'tv series'], filtered)) + if not movieid: + movieid = filtered + if bulk: + return movieid + movieid = movieid[0].movieID + else: + movieid = query + movie = imdb.get_movie(movieid) + if movie.get("original air date"): + date = movie["original air date"] + elif movie.get("year"): + date = movie.get("year") + else: + date = "N/A" + plot = "" + if not LONG_IMDB_DESCRIPTION: + plot = movie.get('plot') + if plot and len(plot) > 0: + plot = plot[0] + else: + plot = movie.get('plot outline') + if plot and len(plot) > 800: + plot = plot[0:800] + "..." + + return { + 'title': movie.get('title'), + 'votes': movie.get('votes'), + "aka": list_to_str(movie.get("akas")), + "seasons": movie.get("number of seasons"), + "box_office": movie.get('box office'), + 'localized_title': movie.get('localized title'), + 'kind': movie.get("kind"), + "imdb_id": f"tt{movie.get('imdbID')}", + "cast": list_to_str(movie.get("cast")), + "runtime": list_to_str(movie.get("runtimes")), + "countries": list_to_str(movie.get("countries")), + "certificates": list_to_str(movie.get("certificates")), + "languages": list_to_str(movie.get("languages")), + "director": list_to_str(movie.get("director")), + "writer":list_to_str(movie.get("writer")), + "producer":list_to_str(movie.get("producer")), + "composer":list_to_str(movie.get("composer")) , + "cinematographer":list_to_str(movie.get("cinematographer")), + "music_team": list_to_str(movie.get("music department")), + "distributors": list_to_str(movie.get("distributors")), + 'release_date': date, + 'year': movie.get('year'), + 'genres': list_to_str(movie.get("genres")), + 'poster': movie.get('full-size cover url'), + 'plot': plot, + 'rating': str(movie.get("rating")), + 'url':f'https://www.imdb.com/title/tt{movieid}' + } +# https://github.com/odysseusmax/animated-lamp/blob/2ef4730eb2b5f0596ed6d03e7b05243d93e3415b/bot/utils/broadcast.py#L37 + +async def broadcast_messages(user_id, message): + try: + await message.copy(chat_id=user_id) + return True, "Success" + except FloodWait as e: + await asyncio.sleep(e.x) + return await broadcast_messages(user_id, message) + except InputUserDeactivated: + await db.delete_user(int(user_id)) + logging.info(f"{user_id}-Removed from Database, since deleted account.") + return False, "Deleted" + except UserIsBlocked: + logging.info(f"{user_id} -Blocked the bot.") + return False, "Blocked" + except PeerIdInvalid: + await db.delete_user(int(user_id)) + logging.info(f"{user_id} - PeerIdInvalid") + return False, "Error" + except Exception as e: + return False, "Error" + +async def broadcast_messages_group(chat_id, message): + try: + kd = await message.copy(chat_id=chat_id) + try: + await kd.pin() + except: + pass + return True, "Success" + except FloodWait as e: + await asyncio.sleep(e.x) + return await broadcast_messages_group(chat_id, message) + except Exception as e: + return False, "Error" + +async def search_gagala(text): + usr_agent = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Chrome/61.0.3163.100 Safari/537.36' + } + text = text.replace(" ", '+') + url = f'https://www.google.com/search?q={text}' + response = requests.get(url, headers=usr_agent) + response.raise_for_status() + soup = BeautifulSoup(response.text, 'html.parser') + titles = soup.find_all( 'h3' ) + return [title.getText() for title in titles] + +async def get_settings(group_id): + settings = temp.SETTINGS.get(group_id) + if not settings: + settings = await db.get_settings(group_id) + temp.SETTINGS[group_id] = settings + return settings + +async def save_group_settings(group_id, key, value): + current = await get_settings(group_id) + current[key] = value + temp.SETTINGS[group_id] = current + await db.update_settings(group_id, current) + +def get_size(size): + """Get size in readable format""" + + units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"] + size = float(size) + i = 0 + while size >= 1024.0 and i < len(units): + i += 1 + size /= 1024.0 + return "%.2f %s" % (size, units[i]) + +def split_list(l, n): + for i in range(0, len(l), n): + yield l[i:i + n] + +def get_file_id(msg: Message): + if msg.media: + for message_type in ( + "photo", + "animation", + "audio", + "document", + "video", + "video_note", + "voice", + "sticker" + ): + obj = getattr(msg, message_type) + if obj: + setattr(obj, "message_type", message_type) + return obj + +def extract_user(message: Message) -> Union[int, str]: + """extracts the user from a message""" + # https://github.com/SpEcHiDe/PyroGramBot/blob/f30e2cca12002121bad1982f68cd0ff9814ce027/pyrobot/helper_functions/extract_user.py#L7 + user_id = None + user_first_name = None + if message.reply_to_message: + user_id = message.reply_to_message.from_user.id + user_first_name = message.reply_to_message.from_user.first_name + + elif len(message.command) > 1: + if ( + len(message.entities) > 1 and + message.entities[1].type == enums.MessageEntityType.TEXT_MENTION + ): + + required_entity = message.entities[1] + user_id = required_entity.user.id + user_first_name = required_entity.user.first_name + else: + user_id = message.command[1] + # don't want to make a request -_- + user_first_name = user_id + try: + user_id = int(user_id) + except ValueError: + pass + else: + user_id = message.from_user.id + user_first_name = message.from_user.first_name + return (user_id, user_first_name) + +def list_to_str(k): + if not k: + return "N/A" + elif len(k) == 1: + return str(k[0]) + elif MAX_LIST_ELM: + k = k[:int(MAX_LIST_ELM)] + return ' '.join(f'{elem}, ' for elem in k) + else: + return ' '.join(f'{elem}, ' for elem in k) + +def last_online(from_user): + time = "" + if from_user.is_bot: + time += "🤖 Bot :(" + elif from_user.status == enums.UserStatus.RECENTLY: + time += "Recently" + elif from_user.status == enums.UserStatus.LAST_WEEK: + time += "Within the last week" + elif from_user.status == enums.UserStatus.LAST_MONTH: + time += "Within the last month" + elif from_user.status == enums.UserStatus.LONG_AGO: + time += "A long time ago :(" + elif from_user.status == enums.UserStatus.ONLINE: + time += "Currently Online" + elif from_user.status == enums.UserStatus.OFFLINE: + time += from_user.last_online_date.strftime("%a, %d %b %Y, %H:%M:%S") + return time + + +def split_quotes(text: str) -> List: + if not any(text.startswith(char) for char in START_CHAR): + return text.split(None, 1) + counter = 1 # ignore first char -> is some kind of quote + while counter < len(text): + if text[counter] == "\\": + counter += 1 + elif text[counter] == text[0] or (text[0] == SMART_OPEN and text[counter] == SMART_CLOSE): + break + counter += 1 + else: + return text.split(None, 1) + + # 1 to avoid starting quote, and counter is exclusive so avoids ending + key = remove_escapes(text[1:counter].strip()) + # index will be in range, or `else` would have been executed and returned + rest = text[counter + 1:].strip() + if not key: + key = text[0] + text[0] + return list(filter(None, [key, rest])) + +def gfilterparser(text, keyword): + if "buttonalert" in text: + text = (text.replace("\n", "\\n").replace("\t", "\\t")) + buttons = [] + note_data = "" + prev = 0 + i = 0 + alerts = [] + for match in BTN_URL_REGEX.finditer(text): + # Check if btnurl is escaped + n_escapes = 0 + to_check = match.start(1) - 1 + while to_check > 0 and text[to_check] == "\\": + n_escapes += 1 + to_check -= 1 + + # if even, not escaped -> create button + if n_escapes % 2 == 0: + note_data += text[prev:match.start(1)] + prev = match.end(1) + if match.group(3) == "buttonalert": + # create a thruple with button label, url, and newline status + if bool(match.group(5)) and buttons: + buttons[-1].append(InlineKeyboardButton( + text=match.group(2), + callback_data=f"gfilteralert:{i}:{keyword}" + )) + else: + buttons.append([InlineKeyboardButton( + text=match.group(2), + callback_data=f"gfilteralert:{i}:{keyword}" + )]) + i += 1 + alerts.append(match.group(4)) + elif bool(match.group(5)) and buttons: + buttons[-1].append(InlineKeyboardButton( + text=match.group(2), + url=match.group(4).replace(" ", "") + )) + else: + buttons.append([InlineKeyboardButton( + text=match.group(2), + url=match.group(4).replace(" ", "") + )]) + + else: + note_data += text[prev:to_check] + prev = match.start(1) - 1 + else: + note_data += text[prev:] + + try: + return note_data, buttons, alerts + except: + return note_data, buttons, None + +def parser(text, keyword): + if "buttonalert" in text: + text = (text.replace("\n", "\\n").replace("\t", "\\t")) + buttons = [] + note_data = "" + prev = 0 + i = 0 + alerts = [] + for match in BTN_URL_REGEX.finditer(text): + # Check if btnurl is escaped + n_escapes = 0 + to_check = match.start(1) - 1 + while to_check > 0 and text[to_check] == "\\": + n_escapes += 1 + to_check -= 1 + + # if even, not escaped -> create button + if n_escapes % 2 == 0: + note_data += text[prev:match.start(1)] + prev = match.end(1) + if match.group(3) == "buttonalert": + # create a thruple with button label, url, and newline status + if bool(match.group(5)) and buttons: + buttons[-1].append(InlineKeyboardButton( + text=match.group(2), + callback_data=f"alertmessage:{i}:{keyword}" + )) + else: + buttons.append([InlineKeyboardButton( + text=match.group(2), + callback_data=f"alertmessage:{i}:{keyword}" + )]) + i += 1 + alerts.append(match.group(4)) + elif bool(match.group(5)) and buttons: + buttons[-1].append(InlineKeyboardButton( + text=match.group(2), + url=match.group(4).replace(" ", "") + )) + else: + buttons.append([InlineKeyboardButton( + text=match.group(2), + url=match.group(4).replace(" ", "") + )]) + + else: + note_data += text[prev:to_check] + prev = match.start(1) - 1 + else: + note_data += text[prev:] + + try: + return note_data, buttons, alerts + except: + return note_data, buttons, None + +def remove_escapes(text: str) -> str: + res = "" + is_escaped = False + for counter in range(len(text)): + if is_escaped: + res += text[counter] + is_escaped = False + elif text[counter] == "\\": + is_escaped = True + else: + res += text[counter] + return res + + +def humanbytes(size): + if not size: + return "" + power = 2**10 + n = 0 + Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'} + while size > power: + size /= power + n += 1 + return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' + +async def get_shortlink(chat_id, link): + settings = await get_settings(chat_id) #fetching settings for group + if 'shortlink' in settings.keys(): + URL = settings['shortlink'] + API = settings['shortlink_api'] + else: + URL = SHORTLINK_URL + API = SHORTLINK_API + if URL.startswith("shorturllink") or URL.startswith("terabox.in") or URL.startswith("urlshorten.in"): + URL = SHORTLINK_URL + API = SHORTLINK_API + if URL == "api.shareus.io": + # method 1: + # https = link.split(":")[0] #splitting https or http from link + # if "http" == https: #if https == "http": + # https = "https" + # link = link.replace("http", https) #replacing http to https + # conn = http.client.HTTPSConnection("api.shareus.io") + # payload = json.dumps({ + # "api_key": "4c1YTBacB6PTuwogBiEIFvZN5TI3", + # "monetization": True, + # "destination": link, + # "ad_page": 3, + # "category": "Entertainment", + # "tags": ["trendinglinks"], + # "monetize_with_money": False, + # "price": 0, + # "currency": "INR", + # "purchase_note":"" + + # }) + # headers = { + # 'Keep-Alive': '', + # 'Content-Type': 'application/json' + # } + # conn.request("POST", "/generate_link", payload, headers) + # res = conn.getresponse() + # data = res.read().decode("utf-8") + # parsed_data = json.loads(data) + # if parsed_data["status"] == "success": + # return parsed_data["link"] + #method 2 + url = f'https://{URL}/easy_api' + params = { + "key": API, + "link": link, + } + try: + async with aiohttp.ClientSession() as session: + async with session.get(url, params=params, raise_for_status=True, ssl=False) as response: + data = await response.text() + return data + except Exception as e: + logger.error(e) + return link + else: + shortzy = Shortzy(api_key=API, base_site=URL) + link = await shortzy.convert(link) + return link + +async def get_tutorial(chat_id): + settings = await get_settings(chat_id) #fetching settings for group + if 'tutorial' in settings.keys(): + if settings['is_tutorial']: + TUTORIAL_URL = settings['tutorial'] + else: + TUTORIAL_URL = TUTORIAL + else: + TUTORIAL_URL = TUTORIAL + return TUTORIAL_URL + +async def get_verify_shorted_link(link): + API = SHORTLINK_API + URL = SHORTLINK_URL + https = link.split(":")[0] + if "http" == https: + https = "https" + link = link.replace("http", https) + + if URL == "api.shareus.in": + url = f"https://{URL}/shortLink" + params = {"token": API, + "format": "json", + "link": link, + } + try: + async with aiohttp.ClientSession() as session: + async with session.get(url, params=params, raise_for_status=True, ssl=False) as response: + data = await response.json(content_type="text/html") + if data["status"] == "success": + return data["shortlink"] + else: + logger.error(f"Error: {data['message']}") + return f'https://{URL}/shortLink?token={API}&format=json&link={link}' + + except Exception as e: + logger.error(e) + return f'https://{URL}/shortLink?token={API}&format=json&link={link}' + else: + url = f'https://{URL}/api' + params = {'api': API, + 'url': link, + } + try: + async with aiohttp.ClientSession() as session: + async with session.get(url, params=params, raise_for_status=True, ssl=False) as response: + data = await response.json() + if data["status"] == "success": + return data['shortenedUrl'] + else: + logger.error(f"Error: {data['message']}") + return f'https://{URL}/api?api={API}&link={link}' + + except Exception as e: + logger.error(e) + return f'{URL}/api?api={API}&link={link}' + +async def check_token(bot, userid, token): + user = await bot.get_users(userid) + if not await db.is_user_exist(user.id): + await db.add_user(user.id, user.first_name) + await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) + if user.id in TOKENS.keys(): + TKN = TOKENS[user.id] + if token in TKN.keys(): + is_used = TKN[token] + if is_used == True: + return False + else: + return True + else: + return False + +async def get_token(bot, userid, link): + user = await bot.get_users(userid) + if not await db.is_user_exist(user.id): + await db.add_user(user.id, user.first_name) + await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) + token = ''.join(random.choices(string.ascii_letters + string.digits, k=7)) + TOKENS[user.id] = {token: False} + link = f"{link}verify-{user.id}-{token}" + shortened_verify_url = await get_verify_shorted_link(link) + return str(shortened_verify_url) + +async def verify_user(bot, userid, token): + user = await bot.get_users(userid) + if not await db.is_user_exist(user.id): + await db.add_user(user.id, user.first_name) + await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) + TOKENS[user.id] = {token: True} + tz = pytz.timezone('Asia/Kolkata') + today = date.today() + VERIFIED[user.id] = str(today) + +async def get_seconds(time_string): + def extract_value_and_unit(ts): + value = "" + unit = "" + + index = 0 + while index < len(ts) and ts[index].isdigit(): + value += ts[index] + index += 1 + + unit = ts[index:].lstrip() + + if value: + value = int(value) + + return value, unit + + value, unit = extract_value_and_unit(time_string) + + if unit == 's': + return value + elif unit == 'min': + return value * 60 + elif unit == 'hour': + return value * 3600 + elif unit == 'day': + return value * 86400 + elif unit == 'month': + return value * 86400 * 30 + elif unit == 'year': + return value * 86400 * 365 + else: + return 0 + +async def check_verification(bot, userid): + user = await bot.get_users(userid) + if not await db.is_user_exist(user.id): + await db.add_user(user.id, user.first_name) + await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention)) + tz = pytz.timezone('Asia/Kolkata') + today = date.today() + if user.id in VERIFIED.keys(): + EXP = VERIFIED[user.id] + years, month, day = EXP.split('-') + comp = date(int(years), int(month), int(day)) + if compHᴇʏ ᴛʜᴇʀᴇ {user_name} 👋🏽 \n\n✅ Sᴇᴄᴜʀᴇ ʟɪɴᴋ ᴛᴏ ʏᴏᴜʀ ғɪʟᴇ ʜᴀs sᴜᴄᴄᴇssғᴜʟʟʏ ʙᴇᴇɴ ɢᴇɴᴇʀᴀᴛᴇᴅ ᴘʟᴇᴀsᴇ ᴄʟɪᴄᴋ ᴅᴏᴡɴʟᴏᴀᴅ ʙᴜᴛᴛᴏɴ\n\n🗃️ Fɪʟᴇ Nᴀᴍᴇ : {title}\n🔖 Fɪʟᴇ Sɪᴢᴇ : {size}
", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("📤 Dᴏᴡɴʟᴏᴀᴅ 📥", url=await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}"))]])) + else: + for file in files: + f_caption = file.caption + title = file.file_name + size = get_size(file.file_size) + if CUSTOM_FILE_CAPTION: + try: + 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) + except Exception as e: + print(e) + f_caption = f_caption + if f_caption is None: + f_caption = f"{title}" + await bot.send_cached_media( + chat_id=userid, + file_id=file.file_id, + caption=f_caption, + protect_content=True if ident == "filep" else False, + reply_markup=InlineKeyboardMarkup( + [ + [ + InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), + InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) + ],[ + InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/Rexisop99") + ] + ] + ) + ) + except UserIsBlocked: + await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True) + except PeerIdInvalid: + await query.answer('Hᴇʏ, Sᴛᴀʀᴛ Bᴏᴛ Fɪʀsᴛ Aɴᴅ Cʟɪᴄᴋ Sᴇɴᴅ Aʟʟ', show_alert=True) + except Exception as e: + await query.answer('Hᴇʏ, Sᴛᴀʀᴛ Bᴏᴛ Fɪʀsᴛ Aɴᴅ Cʟɪᴄᴋ Sᴇɴᴅ Aʟʟ', show_alert=True) + +async def get_cap(settings, remaining_seconds, files, query, total_results, search): + # Aᴅᴅᴇᴅ Bʏ @creatorrio + if settings["imdb"]: + IMDB_CAP = temp.IMDB_CAP.get(query.from_user.id) + if IMDB_CAP: + cap = IMDB_CAP + cap+="\n\n📚 Your Requested Files 👇\n" + for file in files: + cap += f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n" + else: + imdb = await get_poster(search, file=(files[0]).file_name) if settings["imdb"] else None + if imdb: + TEMPLATE = script.IMDB_TEMPLATE_TXT + cap = TEMPLATE.format( + qurey=search, + title=imdb['title'], + votes=imdb['votes'], + aka=imdb["aka"], + seasons=imdb["seasons"], + box_office=imdb['box_office'], + localized_title=imdb['localized_title'], + kind=imdb['kind'], + imdb_id=imdb["imdb_id"], + cast=imdb["cast"], + runtime=imdb["runtime"], + countries=imdb["countries"], + certificates=imdb["certificates"], + languages=imdb["languages"], + director=imdb["director"], + writer=imdb["writer"], + producer=imdb["producer"], + composer=imdb["composer"], + cinematographer=imdb["cinematographer"], + music_team=imdb["music_team"], + distributors=imdb["distributors"], + release_date=imdb['release_date'], + year=imdb['year'], + genres=imdb['genres'], + poster=imdb['poster'], + plot=imdb['plot'], + rating=imdb['rating'], + url=imdb['url'], + **locals() + ) + cap+="\n\n📚 Your Requested Files 👇\n\n" + for file in files: + cap += f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n" + else: + cap = f"🧿 ᴛɪᴛʟᴇ : {search}\n📂 ᴛᴏᴛᴀʟ ꜰɪʟᴇꜱ : {total_results}\n📝 ʀᴇǫᴜᴇsᴛᴇᴅ ʙʏ : {message.from_user.mention}\n⏰ ʀᴇsᴜʟᴛ ɪɴ : {remaining_seconds} Sᴇᴄᴏɴᴅs\n⚜️ ᴘᴏᴡᴇʀᴇᴅ ʙʏ : 👇\n⚡ {message.chat.title}\n" + cap+="\n\n📚 Your Requested Files 👇\n\n" + for file in files: + cap += f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n" + else: + cap = f"🧿 ᴛɪᴛʟᴇ : {search}\n📂 ᴛᴏᴛᴀʟ ꜰɪʟᴇꜱ : {total_results}\n📝 ʀᴇǫᴜᴇsᴛᴇᴅ ʙʏ : {query.from_user.mention}\n⚜️ ᴘᴏᴡᴇʀᴇᴅ ʙʏ : 👇\n⚡ ᴛʜᴇ ᴍᴏᴠɪᴇ ᴘʀᴏᴠɪᴅᴇʀ™\n" + cap+="\n\n📚 Your Requested Files 👇\n\n" + for file in files: + cap += f"📁 {get_size(file.file_size)} ▷ {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n" + return cap diff --git a/zzint/__init__.py b/zzint/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..fc0dcd1cc05c81d29899bd90de32f88a8bc6cefd --- /dev/null +++ b/zzint/__init__.py @@ -0,0 +1,4 @@ +import time + +StartTime = time.time() +__version__ = 1.1