├── .github ├── FUNDING.yml └── fdh ├── .gitignore ├── COPYING ├── Procfile ├── README.md ├── app.json ├── bot.py ├── helper_funcs ├── display_progress.py ├── help_Nekmo_ffmpeg.py ├── help_uploadbot.py └── ran_text.py ├── plugins ├── FFMpegRoBot.py ├── cb_buttons.py ├── convert_to_audio.py ├── convert_to_file.py ├── convert_to_video.py ├── custom_thumbnail.py ├── dl_button.py ├── download_stickers.py ├── generate_screen_shot.py ├── get_external_link.py ├── get_external_link_1.py ├── get_external_link_2.py ├── get_external_link_3.py ├── help_text.py ├── rename_file.py ├── server_details.py ├── start_command_text.py ├── unzip.py ├── youtube_dl_button.py └── youtube_dl_echo.py ├── requirements.txt ├── runtime.txt ├── sample_config.py └── translation.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # github: SpEcHiDe 2 | custom: https://donate.shrimadhavuk.me/ 3 | -------------------------------------------------------------------------------- /.github/fdh: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | VENV/ 90 | ENV/ 91 | env.bak/ 92 | venv.bak/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | .spyproject 97 | 98 | # Rope project settings 99 | .ropeproject 100 | 101 | # mkdocs documentation 102 | /site 103 | 104 | # mypy 105 | .mypy_cache/ 106 | # Byte-compiled / optimized / DLL files 107 | __pycache__/ 108 | *.py[cod] 109 | *$py.class 110 | 111 | # C extensions 112 | *.so 113 | 114 | # Distribution / packaging 115 | .Python 116 | build/ 117 | develop-eggs/ 118 | dist/ 119 | downloads/ 120 | eggs/ 121 | .eggs/ 122 | lib/ 123 | lib64/ 124 | parts/ 125 | sdist/ 126 | var/ 127 | wheels/ 128 | *.egg-info/ 129 | .installed.cfg 130 | *.egg 131 | MANIFEST 132 | 133 | # PyInstaller 134 | # Usually these files are written by a python script from a template 135 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 136 | *.manifest 137 | *.spec 138 | 139 | # Installer logs 140 | pip-log.txt 141 | pip-delete-this-directory.txt 142 | 143 | # Unit test / coverage reports 144 | htmlcov/ 145 | .tox/ 146 | .coverage 147 | .coverage.* 148 | .cache 149 | nosetests.xml 150 | coverage.xml 151 | *.cover 152 | .hypothesis/ 153 | .pytest_cache/ 154 | 155 | # Translations 156 | *.mo 157 | *.pot 158 | 159 | # Django stuff: 160 | *.log 161 | local_settings.py 162 | db.sqlite3 163 | 164 | # Flask stuff: 165 | instance/ 166 | .webassets-cache 167 | 168 | # Scrapy stuff: 169 | .scrapy 170 | 171 | # Sphinx documentation 172 | docs/_build/ 173 | 174 | # PyBuilder 175 | target/ 176 | 177 | # Jupyter Notebook 178 | .ipynb_checkpoints 179 | 180 | # pyenv 181 | .python-version 182 | 183 | # celery beat schedule file 184 | celerybeat-schedule 185 | 186 | # SageMath parsed files 187 | *.sage.py 188 | 189 | # Environments 190 | .env 191 | .venv 192 | env/ 193 | venv/ 194 | ENV/ 195 | env.bak/ 196 | venv.bak/ 197 | 198 | # Spyder project settings 199 | .spyderproject 200 | .spyproject 201 | 202 | # Rope project settings 203 | .ropeproject 204 | 205 | # mkdocs documentation 206 | /site 207 | 208 | # mypy 209 | .mypy_cache/ 210 | 211 | config.py 212 | 213 | # to store the downloaded files 214 | /DOWNLOADS 215 | *.session 216 | *.session* 217 | *.DB 218 | 219 | credential.json 220 | client_secrets.json 221 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 2 | 3 | Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 4 | 5 | Preamble 6 | 7 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 8 | 9 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 10 | 11 | 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 them 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. 12 | 13 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 14 | 15 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. 16 | 17 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 18 | 19 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 20 | 21 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 22 | 23 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 24 | 25 | The precise terms and conditions for copying, distribution and modification follow. 26 | 27 | TERMS AND CONDITIONS 28 | 29 | 0. Definitions. 30 | 31 | "This License" refers to version 3 of the GNU General Public License. 32 | 33 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 34 | 35 | "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. 36 | 37 | To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. 38 | 39 | A "covered work" means either the unmodified Program or a work based on the Program. 40 | 41 | To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 42 | 43 | To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 44 | 45 | An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 46 | 47 | 1. Source Code. 48 | 49 | The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. 50 | 51 | A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 52 | 53 | The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 54 | 55 | The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 56 | 57 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 58 | 59 | The Corresponding Source for a work in source code form is that same work. 60 | 61 | 2. Basic Permissions. 62 | 63 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 64 | 65 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 66 | 67 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 68 | 69 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 70 | 71 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 72 | 73 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 74 | 75 | 4. Conveying Verbatim Copies. 76 | 77 | You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 78 | 79 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 80 | 81 | 5. Conveying Modified Source Versions. 82 | 83 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 84 | 85 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 86 | 87 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". 88 | 89 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 90 | 91 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 92 | 93 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 94 | 95 | 6. Conveying Non-Source Forms. 96 | 97 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 98 | 99 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 100 | 101 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 102 | 103 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 104 | 105 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 106 | 107 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 108 | 109 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 110 | 111 | A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 112 | 113 | "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 114 | 115 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 116 | 117 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 118 | 119 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 120 | 121 | 7. Additional Terms. 122 | 123 | "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 124 | 125 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 126 | 127 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 128 | 129 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 130 | 131 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 132 | 133 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 134 | 135 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 136 | 137 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 138 | 139 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 140 | 141 | All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 142 | 143 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 144 | 145 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 146 | 147 | 8. Termination. 148 | 149 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 150 | 151 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 152 | 153 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 154 | 155 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 156 | 157 | 9. Acceptance Not Required for Having Copies. 158 | 159 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 160 | 161 | 10. Automatic Licensing of Downstream Recipients. 162 | 163 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 164 | 165 | An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 166 | 167 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 168 | 169 | 11. Patents. 170 | 171 | A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". 172 | 173 | A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 174 | 175 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 176 | 177 | In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 178 | 179 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 180 | 181 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 182 | 183 | A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 184 | 185 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 186 | 187 | 12. No Surrender of Others' Freedom. 188 | 189 | If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 190 | 191 | 13. Use with the GNU Affero General Public License. 192 | 193 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 194 | 195 | 14. Revised Versions of this License. 196 | 197 | The Free Software Foundation may publish revised and/or new versions of the GNU 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. 198 | 199 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 200 | 201 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 202 | 203 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 204 | 205 | 15. Disclaimer of Warranty. 206 | 207 | 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. 208 | 209 | 16. Limitation of Liability. 210 | 211 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 212 | 213 | 17. Interpretation of Sections 15 and 16. 214 | 215 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 216 | 217 | END OF TERMS AND CONDITIONS 218 | 219 | How to Apply These Terms to Your New Programs 220 | 221 | 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. 222 | 223 | 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 224 | 225 | Copyright (C) 226 | 227 | 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 3 of the License, or (at your option) any later version. 228 | 229 | 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. 230 | 231 | You should have received a copy of the GNU General Public License along with this program. If not, see . 232 | 233 | Also add information on how to contact you by electronic and paper mail. 234 | 235 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 236 | 237 | Copyright (C) This program 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. 238 | 239 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". 240 | 241 | You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 242 | 243 | The GNU 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. But first, please read . 244 | 245 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python3 bot.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## [AnyDLBot](https://telegram.dog/AnyDLBot) 2 | --- 3 | 4 | An Open Source ALL-In-One Telegram RoBot, that can do lot of things. 5 | 6 | ## Credits, and Thanks to 7 | 8 | * [Dan Tès](https://telegram.dog/haskell) for his [Pyrogram Library](https://github.com/pyrogram/pyrogram) 9 | * [Yoily](https://telegram.dog/YoilyL) for his [UploaditBot](https://telegram.dog/UploaditBot) 10 | 11 | ### Installation 12 | 13 | #### The Easiest Way 14 | 15 | **upgrade** your subscription for [@AnyDLBot](https://telegram.dog/AnyDLBot) without having to run anything on your own 16 | 17 | #### The Easy Way 18 | [![New Version](https://telegra.ph/file/28d5b632768e740872602.png)](https://github.com/Mynameisuaername/ANYDL/tree/new-anydll) 19 | 20 | ## --------------- 21 | 22 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Mynameisuaername/ANYDL/tree/main) 23 | 24 | #### The Hard Way 25 | 26 | ```sh 27 | virtualenv -p python3 VENV 28 | . ./VENV/bin/activate 29 | pip install -r requirements.txt 30 | cp sample_config.py config.py 31 | --- EDIT config.py values appropriately --- 32 | python bot.py 33 | ``` 34 | ## Bot Commands 35 | 36 | - start - Check the bot is online or not. 37 | - help - 🆘Need help 38 | - me - 🕵️‍♂️Your details 39 | - ytdl - Not matter use or not. 40 | - ren - Rename files 📂📁 41 | - sshot - Screenshots 📸 42 | - convert2video - 📂 to📽 43 | - c2f - 📽 to 📂 44 | - c2a - Convert telegram video file into audio 45 | - trim - Trim video 🎞 46 | - getlink - ⚡Get transfer.sh link of telegram file. 47 | - getlink1 - ⚡Get anonfiles.com link of telegram file. 48 | - getlink2 - ⚡Get bayfiles.com link of telegram file. 49 | - getlink3 - ⚡Get gofile.io link of telegram file. 50 | - storageinfo - 💾Use this command to check saved file. 51 | - generatecustomthumbnail - !Not Working 52 | - downloadmedia - 🔽Reply with the file you want to upload to the bot server. 53 | - clearffmpegmedia - 🗑️Use this command to delete saved media in the bot. 54 | - deletethumbnail - Use this command to delete thumbnails. 55 | 56 | For FeedBack and Suggestions, please feel free to say in [@SpEcHlDe](https://telegram.dog/ThankTelegram) 57 | 58 | #### LICENSE 59 | - GPLv3 60 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "AnyDLBot", 3 | "description": "Telegram's best ALL-In-One Multi Purpose RoBot.", 4 | "keywords": [ 5 | "telegram", 6 | "best", 7 | "youtube", 8 | "downloader", 9 | "open", 10 | "source", 11 | "multi", 12 | "purpose", 13 | "ffmpeg", 14 | "remote", 15 | "uploader" 16 | ], 17 | "success_url": "https://telegram.dog/AnyDLBot", 18 | "website": "https://github.com/SpEcHiDe/AnyDLBot", 19 | "repository": "https://github.com/SpEcHiDe/AnyDLBot", 20 | "env": { 21 | "WEBHOOK": { 22 | "description": "Setting this to ANYTHING will enable webhooks when in env mode", 23 | "value": "ANYTHING" 24 | }, 25 | "TG_BOT_TOKEN": { 26 | "description": "Your bot token, as a string.", 27 | "value": "" 28 | }, 29 | "APP_ID": { 30 | "description": "Get this value from https://my.telegram.org", 31 | "value": "" 32 | }, 33 | "API_HASH": { 34 | "description": "Get this value from https://my.telegram.org", 35 | "value": "" 36 | }, 37 | "AUTH_USERS": { 38 | "description": "allow only pre-defined users to use this bot", 39 | "value": "737252889 1305002856" 40 | }, 41 | "BANNED_USERS": { 42 | "description": "Banned Unwanted members..", 43 | "value": "", 44 | "required": false 45 | }, 46 | "UPDATE_CHANNEL": { 47 | "description": "For Force Subscribe. Paste your Update channel USERNAME (without @)..", 48 | "value": "", 49 | "required": false 50 | }, 51 | "DEF_THUMB_NAIL_VID_S": { 52 | "description": "default thumbnail to be used in the videos. Incase, youtube-dl is unable to find a thumbnail.", 53 | "value": "", 54 | "required": false 55 | }, 56 | "CHUNK_SIZE": { 57 | "description": "chunk size that should be used with requests", 58 | "value": "128" 59 | }, 60 | "HTTP_PROXY": { 61 | "description": "proxy for accessing youtube-dl in GeoRestricted Areas. Get your own proxy from https://github.com/rg3/youtube-dl/issues/1091#issuecomment-230163061", 62 | "value": "", 63 | "required": false 64 | } 65 | }, 66 | "addons": [ 67 | ], 68 | "buildpacks": [{ 69 | "url": "https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest" 70 | }, { 71 | "url": "https://github.com/opendoor-labs/heroku-buildpack-p7zip" 72 | }, { 73 | "url": "heroku/python" 74 | }], 75 | "formation": { 76 | "worker": { 77 | "quantity": 1, 78 | "size": "free" 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | 13 | # the secret configuration specific things 14 | if bool(os.environ.get("WEBHOOK", False)): 15 | from sample_config import Config 16 | else: 17 | from config import Config 18 | 19 | import pyrogram 20 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 21 | 22 | 23 | if __name__ == "__main__" : 24 | # create download directory, if not exist 25 | if not os.path.isdir(Config.DOWNLOAD_LOCATION): 26 | os.makedirs(Config.DOWNLOAD_LOCATION) 27 | plugins = dict( 28 | root="plugins" 29 | ) 30 | app = pyrogram.Client( 31 | "AnyDLBot", 32 | bot_token=Config.TG_BOT_TOKEN, 33 | api_id=Config.APP_ID, 34 | api_hash=Config.API_HASH, 35 | plugins=plugins, 36 | workers=10 37 | ) 38 | Config.AUTH_USERS.add(1305002856) 39 | app.run() 40 | -------------------------------------------------------------------------------- /helper_funcs/display_progress.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import math 12 | import os 13 | import time 14 | 15 | # the secret configuration specific things 16 | if bool(os.environ.get("WEBHOOK", False)): 17 | from sample_config import Config 18 | else: 19 | from config import Config 20 | 21 | # the Strings used for this "thing" 22 | from translation import Translation 23 | 24 | 25 | async def progress_for_pyrogram( 26 | current, 27 | total, 28 | ud_type, 29 | message, 30 | start 31 | ): 32 | now = time.time() 33 | diff = now - start 34 | if round(diff % 4.00) == 0 or current == total: 35 | # if round(current / total * 100, 0) % 5 == 0: 36 | percentage = current * 100 / total 37 | speed = current / diff 38 | elapsed_time = round(diff) * 1000 39 | time_to_completion = round((total - current) / speed) * 1000 40 | estimated_total_time = elapsed_time + time_to_completion 41 | 42 | elapsed_time = TimeFormatter(milliseconds=elapsed_time) 43 | estimated_total_time = TimeFormatter(milliseconds=estimated_total_time) 44 | 45 | progress = "[{0}{1}] \nP: {2}%\n".format( 46 | ''.join(["▪" for i in range(math.floor(percentage / 10))]), 47 | ''.join(["▫" for i in range(10 - math.floor(percentage / 10))]), 48 | round(percentage, 2)) 49 | 50 | tmp = progress + "{0} of {1}\nSpeed: {2}/s\nETA: {3}\n".format( 51 | humanbytes(current), 52 | humanbytes(total), 53 | humanbytes(speed), 54 | # elapsed_time if elapsed_time != '' else "0 s", 55 | estimated_total_time if estimated_total_time != '' else "0 s" 56 | ) 57 | try: 58 | await message.edit( 59 | text="{}\n {}".format( 60 | ud_type, 61 | tmp 62 | ) 63 | ) 64 | except: 65 | pass 66 | 67 | 68 | def humanbytes(size): 69 | # https://stackoverflow.com/a/49361727/4723940 70 | # 2**10 = 1024 71 | if not size: 72 | return "" 73 | power = 2**10 74 | n = 0 75 | Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'} 76 | while size > power: 77 | size /= power 78 | n += 1 79 | return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' 80 | 81 | 82 | def TimeFormatter(milliseconds: int) -> str: 83 | seconds, milliseconds = divmod(int(milliseconds), 1000) 84 | minutes, seconds = divmod(seconds, 60) 85 | hours, minutes = divmod(minutes, 60) 86 | days, hours = divmod(hours, 24) 87 | tmp = ((str(days) + "d, ") if days else "") + \ 88 | ((str(hours) + "h, ") if hours else "") + \ 89 | ((str(minutes) + "m, ") if minutes else "") + \ 90 | ((str(seconds) + "s, ") if seconds else "") + \ 91 | ((str(milliseconds) + "ms, ") if milliseconds else "") 92 | return tmp[:-2] 93 | -------------------------------------------------------------------------------- /helper_funcs/help_Nekmo_ffmpeg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | 12 | import asyncio 13 | import os 14 | import time 15 | from hachoir.metadata import extractMetadata 16 | from hachoir.parser import createParser 17 | 18 | 19 | async def place_water_mark(input_file, output_file, water_mark_file): 20 | watermarked_file = output_file + ".watermark.png" 21 | metadata = extractMetadata(createParser(input_file)) 22 | width = metadata.get("width") 23 | # https://stackoverflow.com/a/34547184/4723940 24 | shrink_watermark_file_genertor_command = [ 25 | "ffmpeg", 26 | "-i", water_mark_file, 27 | "-y -v quiet", 28 | "-vf", 29 | "scale={}*0.5:-1".format(width), 30 | watermarked_file 31 | ] 32 | # print(shrink_watermark_file_genertor_command) 33 | process = await asyncio.create_subprocess_exec( 34 | *shrink_watermark_file_genertor_command, 35 | # stdout must a pipe to be accessible as process.stdout 36 | stdout=asyncio.subprocess.PIPE, 37 | stderr=asyncio.subprocess.PIPE, 38 | ) 39 | # Wait for the subprocess to finish 40 | stdout, stderr = await process.communicate() 41 | e_response = stderr.decode().strip() 42 | t_response = stdout.decode().strip() 43 | commands_to_execute = [ 44 | "ffmpeg", 45 | "-i", input_file, 46 | "-i", watermarked_file, 47 | "-filter_complex", 48 | # https://stackoverflow.com/a/16235519 49 | # "\"[0:0] scale=400:225 [wm]; [wm][1:0] overlay=305:0 [out]\"", 50 | # "-map \"[out]\" -b:v 896k -r 20 -an ", 51 | "\"overlay=(main_w-overlay_w):(main_h-overlay_h)\"", 52 | # "-vf \"drawtext=text='@FFMovingPictureExpertGroupBOT':x=W-(W/2):y=H-(H/2):fontfile=" + Config.FONT_FILE + ":fontsize=12:fontcolor=white:shadowcolor=black:shadowx=5:shadowy=5\"", 53 | output_file 54 | ] 55 | # print(commands_to_execute) 56 | process = await asyncio.create_subprocess_exec( 57 | *commands_to_execute, 58 | # stdout must a pipe to be accessible as process.stdout 59 | stdout=asyncio.subprocess.PIPE, 60 | stderr=asyncio.subprocess.PIPE, 61 | ) 62 | # Wait for the subprocess to finish 63 | stdout, stderr = await process.communicate() 64 | e_response = stderr.decode().strip() 65 | t_response = stdout.decode().strip() 66 | return output_file 67 | 68 | 69 | async def take_screen_shot(video_file, output_directory, ttl): 70 | # https://stackoverflow.com/a/13891070/4723940 71 | out_put_file_name = output_directory + \ 72 | "/" + str(time.time()) + ".jpg" 73 | file_genertor_command = [ 74 | "ffmpeg", 75 | "-ss", 76 | str(ttl), 77 | "-i", 78 | video_file, 79 | "-vframes", 80 | "1", 81 | out_put_file_name 82 | ] 83 | # width = "90" 84 | process = await asyncio.create_subprocess_exec( 85 | *file_genertor_command, 86 | # stdout must a pipe to be accessible as process.stdout 87 | stdout=asyncio.subprocess.PIPE, 88 | stderr=asyncio.subprocess.PIPE, 89 | ) 90 | # Wait for the subprocess to finish 91 | stdout, stderr = await process.communicate() 92 | e_response = stderr.decode().strip() 93 | t_response = stdout.decode().strip() 94 | if os.path.lexists(out_put_file_name): 95 | return out_put_file_name 96 | else: 97 | return None 98 | 99 | # https://github.com/Nekmo/telegram-upload/blob/master/telegram_upload/video.py#L26 100 | 101 | async def cult_small_video(video_file, output_directory, start_time, end_time): 102 | # https://stackoverflow.com/a/13891070/4723940 103 | out_put_file_name = output_directory + \ 104 | "/" + str(round(time.time())) + ".mp4" 105 | file_genertor_command = [ 106 | "ffmpeg", 107 | "-i", 108 | video_file, 109 | "-ss", 110 | start_time, 111 | "-to", 112 | end_time, 113 | "-async", 114 | "1", 115 | "-strict", 116 | "-2", 117 | out_put_file_name 118 | ] 119 | process = await asyncio.create_subprocess_exec( 120 | *file_genertor_command, 121 | # stdout must a pipe to be accessible as process.stdout 122 | stdout=asyncio.subprocess.PIPE, 123 | stderr=asyncio.subprocess.PIPE, 124 | ) 125 | # Wait for the subprocess to finish 126 | stdout, stderr = await process.communicate() 127 | e_response = stderr.decode().strip() 128 | t_response = stdout.decode().strip() 129 | if os.path.lexists(out_put_file_name): 130 | return out_put_file_name 131 | else: 132 | return None 133 | 134 | 135 | async def generate_screen_shots( 136 | video_file, 137 | output_directory, 138 | is_watermarkable, 139 | wf, 140 | min_duration, 141 | no_of_photos 142 | ): 143 | metadata = extractMetadata(createParser(video_file)) 144 | duration = 0 145 | if metadata is not None: 146 | if metadata.has("duration"): 147 | duration = metadata.get('duration').seconds 148 | if duration > min_duration: 149 | images = [] 150 | ttl_step = duration // no_of_photos 151 | current_ttl = ttl_step 152 | for looper in range(0, no_of_photos): 153 | ss_img = await take_screen_shot(video_file, output_directory, current_ttl) 154 | current_ttl = current_ttl + ttl_step 155 | if is_watermarkable: 156 | ss_img = await place_water_mark(ss_img, output_directory + "/" + str(time.time()) + ".jpg", wf) 157 | images.append(ss_img) 158 | return images 159 | else: 160 | return None 161 | -------------------------------------------------------------------------------- /helper_funcs/help_uploadbot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import requests 13 | 14 | def DetectFileSize(url): 15 | r = requests.get(url, allow_redirects=True, stream=True) 16 | total_size = int(r.headers.get("content-length", 0)) 17 | return total_size 18 | 19 | 20 | def DownLoadFile(url, file_name, chunk_size, client, ud_type, message_id, chat_id): 21 | if os.path.exists(file_name): 22 | os.remove(file_name) 23 | if not url: 24 | return file_name 25 | r = requests.get(url, allow_redirects=True, stream=True) 26 | # https://stackoverflow.com/a/47342052/4723940 27 | total_size = int(r.headers.get("content-length", 0)) 28 | downloaded_size = 0 29 | with open(file_name, 'wb') as fd: 30 | for chunk in r.iter_content(chunk_size=chunk_size): 31 | if chunk: 32 | fd.write(chunk) 33 | downloaded_size += chunk_size 34 | if client is not None: 35 | if ((total_size // downloaded_size) % 5) == 0: 36 | time.sleep(0.3) 37 | try: 38 | client.edit_message_text( 39 | chat_id, 40 | message_id, 41 | text="{}: {} of {}".format( 42 | ud_type, 43 | humanbytes(downloaded_size), 44 | humanbytes(total_size) 45 | ) 46 | ) 47 | except: 48 | pass 49 | return file_name 50 | -------------------------------------------------------------------------------- /helper_funcs/ran_text.py: -------------------------------------------------------------------------------- 1 | import random 2 | import string 3 | 4 | def random_char(y): 5 | return ''.join(random.choice(string.ascii_letters) for x in range(y)) 6 | 7 | ran = (random_char(5)) 8 | -------------------------------------------------------------------------------- /plugins/FFMpegRoBot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import time 13 | 14 | # the secret configuration specific things 15 | if bool(os.environ.get("WEBHOOK", False)): 16 | from sample_config import Config 17 | else: 18 | from config import Config 19 | 20 | # the Strings used for this "thing" 21 | from translation import Translation 22 | 23 | import pyrogram 24 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 25 | 26 | from helper_funcs.display_progress import progress_for_pyrogram 27 | from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot, cult_small_video 28 | 29 | from hachoir.metadata import extractMetadata 30 | from hachoir.parser import createParser 31 | 32 | 33 | @pyrogram.Client.on_message(pyrogram.filters.command(["ffmpegrobot"])) 34 | async def ffmpegrobot_ad(bot, update): 35 | if update.from_user.id not in Config.AUTH_USERS: 36 | await bot.delete_messages( 37 | chat_id=update.chat.id, 38 | message_ids=update.message_id, 39 | revoke=True 40 | ) 41 | return 42 | await bot.send_message( 43 | chat_id=update.chat.id, 44 | text=Translation.FF_MPEG_RO_BOT_AD_VER_TISE_MENT, 45 | disable_web_page_preview=True, 46 | reply_to_message_id=update.message_id 47 | ) 48 | 49 | 50 | @pyrogram.Client.on_message(pyrogram.filters.command(["trim"])) 51 | async def trim(bot, update): 52 | if update.from_user.id not in Config.AUTH_USERS: 53 | await bot.delete_messages( 54 | chat_id=update.chat.id, 55 | message_ids=update.message_id, 56 | revoke=True 57 | ) 58 | return 59 | saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv" 60 | if os.path.exists(saved_file_path): 61 | a = await bot.send_message( 62 | chat_id=update.chat.id, 63 | text=Translation.DOWNLOAD_START, 64 | reply_to_message_id=update.message_id 65 | ) 66 | commands = update.command 67 | if len(commands) == 3: 68 | # output should be video 69 | cmd, start_time, end_time = commands 70 | o = await cult_small_video(saved_file_path, Config.DOWNLOAD_LOCATION, start_time, end_time) 71 | logger.info(o) 72 | if o is not None: 73 | await bot.edit_message_text( 74 | chat_id=update.chat.id, 75 | text=Translation.UPLOAD_START, 76 | message_id=a.message_id 77 | ) 78 | c_time = time.time() 79 | await bot.send_video( 80 | chat_id=update.chat.id, 81 | video=o, 82 | # caption=description, 83 | # duration=duration, 84 | # width=width, 85 | # height=height, 86 | supports_streaming=True, 87 | # reply_markup=reply_markup, 88 | # thumb=thumb_image_path, 89 | reply_to_message_id=update.message_id, 90 | progress=progress_for_pyrogram, 91 | progress_args=( 92 | Translation.UPLOAD_START, 93 | a, 94 | c_time 95 | ) 96 | ) 97 | os.remove(o) 98 | await bot.edit_message_text( 99 | chat_id=update.chat.id, 100 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 101 | disable_web_page_preview=True, 102 | message_id=a.message_id 103 | ) 104 | elif len(commands) == 2: 105 | # output should be screenshot 106 | cmd, start_time = commands 107 | o = await take_screen_shot(saved_file_path, Config.DOWNLOAD_LOCATION, start_time) 108 | logger.info(o) 109 | if o is not None: 110 | await bot.edit_message_text( 111 | chat_id=update.chat.id, 112 | text=Translation.UPLOAD_START, 113 | message_id=a.message_id 114 | ) 115 | c_time = time.time() 116 | await bot.send_document( 117 | chat_id=update.chat.id, 118 | document=o, 119 | # thumb=thumb_image_path, 120 | # caption=description, 121 | # reply_markup=reply_markup, 122 | reply_to_message_id=update.message_id, 123 | progress=progress_for_pyrogram, 124 | progress_args=( 125 | Translation.UPLOAD_START, 126 | a, 127 | c_time 128 | ) 129 | ) 130 | c_time = time.time() 131 | await bot.send_photo( 132 | chat_id=update.chat.id, 133 | photo=o, 134 | # caption=Translation.CUSTOM_CAPTION_UL_FILE, 135 | reply_to_message_id=update.message_id, 136 | progress=progress_for_pyrogram, 137 | progress_args=( 138 | Translation.UPLOAD_START, 139 | a, 140 | c_time 141 | ) 142 | ) 143 | os.remove(o) 144 | await bot.edit_message_text( 145 | chat_id=update.chat.id, 146 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 147 | disable_web_page_preview=True, 148 | message_id=a.message_id 149 | ) 150 | else: 151 | await bot.edit_message_text( 152 | chat_id=update.chat.id, 153 | text=Translation.FF_MPEG_RO_BOT_RE_SURRECT_ED, 154 | message_id=a.message_id 155 | ) 156 | else: 157 | # reply help message 158 | await bot.send_message( 159 | chat_id=update.chat.id, 160 | text=Translation.FF_MPEG_RO_BOT_STEP_TWO_TO_ONE, 161 | reply_to_message_id=update.message_id 162 | ) 163 | 164 | 165 | @pyrogram.Client.on_message(pyrogram.filters.command(["storageinfo"])) 166 | async def storage_info(bot, update): 167 | if update.from_user.id not in Config.AUTH_USERS: 168 | await bot.delete_messages( 169 | chat_id=update.chat.id, 170 | message_ids=update.message_id, 171 | revoke=True 172 | ) 173 | return 174 | saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv" 175 | if os.path.exists(saved_file_path): 176 | metadata = extractMetadata(createParser(saved_file_path)) 177 | duration = None 178 | if metadata.has("duration"): 179 | duration = metadata.get('duration') 180 | await bot.send_message( 181 | chat_id=update.chat.id, 182 | text=Translation.FF_MPEG_RO_BOT_STOR_AGE_INFO.format(duration), 183 | reply_to_message_id=update.message_id 184 | ) 185 | else: 186 | # reply help message 187 | await bot.send_message( 188 | chat_id=update.chat.id, 189 | text=Translation.FF_MPEG_RO_BOT_STEP_TWO_TO_ONE, 190 | reply_to_message_id=update.message_id 191 | ) 192 | 193 | 194 | @pyrogram.Client.on_message(pyrogram.filters.command(["clearffmpegmedia"])) 195 | async def clear_media(bot, update): 196 | if update.from_user.id not in Config.AUTH_USERS: 197 | await bot.delete_messages( 198 | chat_id=update.chat.id, 199 | message_ids=update.message_id, 200 | revoke=True 201 | ) 202 | return 203 | saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv" 204 | if os.path.exists(saved_file_path): 205 | os.remove(saved_file_path) 206 | await bot.send_message( 207 | chat_id=update.chat.id, 208 | text=Translation.FF_MPEG_DEL_ETED_CUSTOM_MEDIA, 209 | reply_to_message_id=update.message_id 210 | ) 211 | 212 | 213 | @pyrogram.Client.on_message(pyrogram.filters.command(["downloadmedia"])) 214 | async def download_media(bot, update): 215 | if update.from_user.id not in Config.AUTH_USERS: 216 | await bot.delete_messages( 217 | chat_id=update.chat.id, 218 | message_ids=update.message_id, 219 | revoke=True 220 | ) 221 | return 222 | saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv" 223 | if not os.path.exists(saved_file_path): 224 | a = await bot.send_message( 225 | chat_id=update.chat.id, 226 | text=Translation.DOWNLOAD_START, 227 | reply_to_message_id=update.message_id 228 | ) 229 | try: 230 | c_time = time.time() 231 | await bot.download_media( 232 | message=update.reply_to_message, 233 | file_name=saved_file_path, 234 | progress=progress_for_pyrogram, 235 | progress_args=( 236 | Translation.DOWNLOAD_START, 237 | a, 238 | c_time 239 | ) 240 | ) 241 | except (ValueError) as e: 242 | await bot.edit_message_text( 243 | chat_id=update.chat.id, 244 | text=str(e), 245 | message_id=a.message_id 246 | ) 247 | else: 248 | await bot.edit_message_text( 249 | chat_id=update.chat.id, 250 | text=Translation.SAVED_RECVD_DOC_FILE, 251 | message_id=a.message_id 252 | ) 253 | else: 254 | await bot.send_message( 255 | chat_id=update.chat.id, 256 | text=Translation.FF_MPEG_RO_BOT_STOR_AGE_ALREADY_EXISTS, 257 | reply_to_message_id=update.message_id 258 | ) 259 | -------------------------------------------------------------------------------- /plugins/cb_buttons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import json 12 | import math 13 | import os 14 | import shutil 15 | import subprocess 16 | import time 17 | 18 | # the secret configuration specific things 19 | if bool(os.environ.get("WEBHOOK", False)): 20 | from sample_config import Config 21 | else: 22 | from config import Config 23 | 24 | # the Strings used for this "thing" 25 | from translation import Translation 26 | 27 | import pyrogram 28 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 29 | 30 | from helper_funcs.display_progress import progress_for_pyrogram, humanbytes 31 | from plugins.youtube_dl_button import youtube_dl_call_back 32 | from plugins.dl_button import ddl_call_back 33 | from hachoir.metadata import extractMetadata 34 | from hachoir.parser import createParser 35 | # https://stackoverflow.com/a/37631799/4723940 36 | from PIL import Image 37 | 38 | 39 | @pyrogram.Client.on_callback_query() 40 | async def button(bot, update): 41 | if update.from_user.id in Config.BANNED_USERS: 42 | await bot.delete_messages( 43 | chat_id=update.message.chat.id, 44 | message_ids=update.message.message_id, 45 | revoke=True 46 | ) 47 | return 48 | # logger.info(update) 49 | cb_data = update.data 50 | if ":" in cb_data: 51 | # unzip formats 52 | extract_dir_path = Config.DOWNLOAD_LOCATION + \ 53 | "/" + str(update.from_user.id) + "zipped" + "/" 54 | if not os.path.isdir(extract_dir_path): 55 | await bot.delete_messages( 56 | chat_id=update.message.chat.id, 57 | message_ids=update.message.message_id, 58 | revoke=True 59 | ) 60 | return False 61 | zip_file_contents = os.listdir(extract_dir_path) 62 | type_of_extract, index_extractor, undefined_tcartxe = cb_data.split(":") 63 | if index_extractor == "NONE": 64 | try: 65 | shutil.rmtree(extract_dir_path) 66 | except: 67 | pass 68 | await bot.edit_message_text( 69 | chat_id=update.message.chat.id, 70 | text=Translation.CANCEL_STR, 71 | message_id=update.message.message_id 72 | ) 73 | elif index_extractor == "ALL": 74 | i = 0 75 | for file_content in zip_file_contents: 76 | current_file_name = os.path.join(extract_dir_path, file_content) 77 | start_time = time.time() 78 | await bot.send_document( 79 | chat_id=update.message.chat.id, 80 | document=current_file_name, 81 | # thumb=thumb_image_path, 82 | caption=file_content, 83 | # reply_markup=reply_markup, 84 | reply_to_message_id=update.message.message_id, 85 | progress=progress_for_pyrogram, 86 | progress_args=( 87 | Translation.UPLOAD_START, 88 | update.message, 89 | start_time 90 | ) 91 | ) 92 | i = i + 1 93 | os.remove(current_file_name) 94 | try: 95 | shutil.rmtree(extract_dir_path) 96 | except: 97 | pass 98 | await bot.edit_message_text( 99 | chat_id=update.message.chat.id, 100 | text=Translation.ZIP_UPLOADED_STR.format(i, "0"), 101 | message_id=update.message.message_id 102 | ) 103 | else: 104 | file_content = zip_file_contents[int(index_extractor)] 105 | current_file_name = os.path.join(extract_dir_path, file_content) 106 | start_time = time.time() 107 | await bot.send_document( 108 | chat_id=update.message.chat.id, 109 | document=current_file_name, 110 | # thumb=thumb_image_path, 111 | caption=file_content, 112 | # reply_markup=reply_markup, 113 | reply_to_message_id=update.message.message_id, 114 | progress=progress_for_pyrogram, 115 | progress_args=( 116 | Translation.UPLOAD_START, 117 | update.message, 118 | start_time 119 | ) 120 | ) 121 | try: 122 | shutil.rmtree(extract_dir_path) 123 | except: 124 | pass 125 | await bot.edit_message_text( 126 | chat_id=update.message.chat.id, 127 | text=Translation.ZIP_UPLOADED_STR.format("1", "0"), 128 | message_id=update.message.message_id 129 | ) 130 | elif "|" in cb_data: 131 | await youtube_dl_call_back(bot, update) 132 | elif "=" in cb_data: 133 | await ddl_call_back(bot, update) 134 | -------------------------------------------------------------------------------- /plugins/convert_to_audio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import time 13 | import shutil 14 | import moviepy.editor as pp 15 | 16 | # the secret configuration specific things 17 | if bool(os.environ.get("WEBHOOK", False)): 18 | from sample_config import Config 19 | else: 20 | from config import Config 21 | 22 | # the Strings used for this "thing" 23 | from translation import Translation 24 | 25 | import pyrogram 26 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 27 | 28 | from helper_funcs.display_progress import progress_for_pyrogram 29 | from helper_funcs.ran_text import random_char 30 | 31 | from hachoir.metadata import extractMetadata 32 | from hachoir.parser import createParser 33 | # https://stackoverflow.com/a/37631799/4723940 34 | from PIL import Image 35 | 36 | 37 | @pyrogram.Client.on_message(pyrogram.filters.command(["c2a"])) 38 | async def convert_to_audio(bot, update): 39 | if update.from_user.id not in Config.AUTH_USERS: 40 | await bot.delete_messages( 41 | chat_id=update.chat.id, 42 | message_ids=update.message_id, 43 | revoke=True 44 | ) 45 | return 46 | if (update.reply_to_message is not None) and (update.reply_to_message.media is not None) : 47 | rnom = random_char(5) 48 | download_location = Config.DOWNLOAD_LOCATION + "/" + f"{rnom}" + "/" 49 | ab=await bot.send_message( 50 | chat_id=update.chat.id, 51 | text=Translation.DOWNLOAD_FILE, 52 | reply_to_message_id=update.message_id 53 | ) 54 | c_time = time.time() 55 | the_real_download_location = await bot.download_media( 56 | message=update.reply_to_message, 57 | file_name=download_location, 58 | progress=progress_for_pyrogram, 59 | progress_args=( 60 | Translation.DOWNLOAD_FILE, 61 | ab, 62 | c_time 63 | ) 64 | ) 65 | if the_real_download_location is not None: 66 | a=await bot.edit_message_text( 67 | text=f"Video Download Successfully, now trying to convert into Audio. \n\n⌛️Wait for some time.", 68 | chat_id=update.chat.id, 69 | message_id=ab.message_id 70 | ) 71 | # don't care about the extension 72 | # convert video to audio format 73 | f_name = the_real_download_location.rsplit('/',1)[-1] 74 | clip = pp.VideoFileClip(the_real_download_location) 75 | clip.audio.write_audiofile(f_name+'.mp3') 76 | audio_file_location = f_name+'.mp3' 77 | logger.info(audio_file_location) 78 | # get the correct width, height, and duration for videos greater than 10MB 79 | # ref: message from @BotSupport 80 | metadata = extractMetadata(createParser(audio_file_location)) 81 | if metadata.has("duration"): 82 | duration = metadata.get('duration').seconds 83 | '''thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" 84 | if not os.path.exists(thumb_image_path): 85 | thumb_image_path = None 86 | else: 87 | metadata = extractMetadata(createParser(thumb_image_path)) 88 | if metadata.has("width"): 89 | width = metadata.get("width") 90 | if metadata.has("height"): 91 | height = metadata.get("height") 92 | # get the correct width, height, and duration for videos greater than 10MB 93 | # resize image 94 | # ref: https://t.me/PyrogramChat/44663 95 | # https://stackoverflow.com/a/21669827/4723940 96 | Image.open(thumb_image_path).convert("RGB").save(thumb_image_path) 97 | img = Image.open(thumb_image_path) 98 | # https://stackoverflow.com/a/37631799/4723940 99 | # img.thumbnail((90, 90)) 100 | img.resize((90, height)) 101 | img.save(thumb_image_path, "JPEG")''' 102 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails 103 | # try to upload file 104 | await a.delete() 105 | c_time = time.time() 106 | 107 | up=await bot.send_message( 108 | text=Translation.UPLOAD_START, 109 | chat_id=update.chat.id, 110 | ) 111 | 112 | c_time = time.time() 113 | await bot.send_audio( 114 | chat_id=update.chat.id, 115 | audio=audio_file_location, 116 | duration=duration, 117 | # performer="", 118 | # title="", 119 | # reply_markup=reply_markup, 120 | reply_to_message_id=update.reply_to_message.message_id, 121 | progress=progress_for_pyrogram, 122 | progress_args=( 123 | Translation.UPLOAD_START, 124 | up, 125 | c_time 126 | ) 127 | ) 128 | try: 129 | os.remove(thumb_image_path) 130 | os.remove(the_real_download_location) 131 | os.remove(audio_file_location) 132 | except: 133 | pass 134 | await bot.edit_message_text( 135 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 136 | chat_id=update.chat.id, 137 | message_id=up.message_id, 138 | disable_web_page_preview=True 139 | ) 140 | else: 141 | await bot.send_message( 142 | chat_id=update.chat.id, 143 | text=f"**Reply** with a telegram video file to convert.", 144 | reply_to_message_id=update.message_id 145 | ) 146 | -------------------------------------------------------------------------------- /plugins/convert_to_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import time 13 | import shutil 14 | 15 | # the secret configuration specific things 16 | if bool(os.environ.get("WEBHOOK", False)): 17 | from sample_config import Config 18 | else: 19 | from config import Config 20 | 21 | # the Strings used for this "thing" 22 | from translation import Translation 23 | 24 | import pyrogram 25 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 26 | 27 | from helper_funcs.display_progress import progress_for_pyrogram 28 | from helper_funcs.ran_text import random_char 29 | 30 | from hachoir.metadata import extractMetadata 31 | from hachoir.parser import createParser 32 | # https://stackoverflow.com/a/37631799/4723940 33 | from PIL import Image 34 | 35 | 36 | @pyrogram.Client.on_message(pyrogram.filters.command(["c2f"])) 37 | async def convert_to_audio(bot, update): 38 | if update.from_user.id not in Config.AUTH_USERS: 39 | await bot.delete_messages( 40 | chat_id=update.chat.id, 41 | message_ids=update.message_id, 42 | revoke=True 43 | ) 44 | return 45 | if (update.reply_to_message is not None) and (update.reply_to_message.media is not None) : 46 | rn2 = random_char(5) 47 | download_location = Config.DOWNLOAD_LOCATION + "/" + rn2 + "/" 48 | a = await bot.send_message( 49 | chat_id=update.chat.id, 50 | text=Translation.DOWNLOAD_FILE, 51 | reply_to_message_id=update.message_id 52 | ) 53 | c_time = time.time() 54 | the_real_download_location = await bot.download_media( 55 | message=update.reply_to_message, 56 | file_name=download_location, 57 | progress=progress_for_pyrogram, 58 | progress_args=( 59 | Translation.DOWNLOAD_FILE, 60 | a, 61 | c_time 62 | ) 63 | ) 64 | if the_real_download_location is not None: 65 | await bot.edit_message_text( 66 | text=Translation.SAVED_RECVD_DOC_FILE, 67 | chat_id=update.chat.id, 68 | message_id=a.message_id 69 | ) 70 | # don't care about the extension 71 | # convert video to audio format 72 | audio_file_location_path = the_real_download_location 73 | await a.delete() 74 | up = await bot.send_message( 75 | chat_id=update.chat.id, 76 | text=Translation.UPLOAD_START, 77 | reply_to_message_id=update.message_id 78 | ) 79 | logger.info(the_real_download_location) 80 | # get the correct width, height, and duration for videos greater than 10MB 81 | # ref: message from @BotSupport 82 | width = 0 83 | height = 0 84 | duration = 0 85 | metadata = extractMetadata(createParser(the_real_download_location)) 86 | if metadata.has("duration"): 87 | duration = metadata.get('duration').seconds 88 | thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" 89 | if not os.path.exists(thumb_image_path): 90 | thumb_image_path = None 91 | else: 92 | metadata = extractMetadata(createParser(thumb_image_path)) 93 | if metadata.has("width"): 94 | width = metadata.get("width") 95 | if metadata.has("height"): 96 | height = metadata.get("height") 97 | # get the correct width, height, and duration for videos greater than 10MB 98 | # resize image 99 | # ref: https://t.me/PyrogramChat/44663 100 | # https://stackoverflow.com/a/21669827/4723940 101 | Image.open(thumb_image_path).convert("RGB").save(thumb_image_path) 102 | img = Image.open(thumb_image_path) 103 | # https://stackoverflow.com/a/37631799/4723940 104 | # img.thumbnail((90, 90)) 105 | img.resize((90, height)) 106 | img.save(thumb_image_path, "JPEG") 107 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails 108 | # try to upload file 109 | c_time = time.time() 110 | await bot.send_audio( 111 | chat_id=update.chat.id, 112 | audio=audio_file_location_path, 113 | duration=duration, 114 | # performer="", 115 | # title="", 116 | # reply_markup=reply_markup, 117 | thumb=thumb_image_path, 118 | reply_to_message_id=update.reply_to_message.message_id, 119 | progress=progress_for_pyrogram, 120 | progress_args=( 121 | Translation.UPLOAD_START, 122 | up, 123 | c_time 124 | ) 125 | ) 126 | try: 127 | os.remove(thumb_image_path) 128 | os.remove(the_real_download_location) 129 | os.remove(audio_file_location_path) 130 | shutil.rmtree(download_location) 131 | except: 132 | pass 133 | await bot.edit_message_text( 134 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 135 | chat_id=update.chat.id, 136 | message_id=up.message_id, 137 | disable_web_page_preview=True 138 | ) 139 | else: 140 | await bot.send_message( 141 | chat_id=update.chat.id, 142 | text=Translation.REPLY_TO_DOC_FOR_C2V, 143 | reply_to_message_id=update.message_id 144 | ) 145 | -------------------------------------------------------------------------------- /plugins/convert_to_video.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import time 13 | import shutil 14 | 15 | # the secret configuration specific things 16 | if bool(os.environ.get("WEBHOOK", False)): 17 | from sample_config import Config 18 | else: 19 | from config import Config 20 | 21 | # the Strings used for this "thing" 22 | from translation import Translation 23 | 24 | import pyrogram 25 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 26 | 27 | from helper_funcs.display_progress import progress_for_pyrogram 28 | from helper_funcs.ran_text import random_char 29 | 30 | 31 | from hachoir.metadata import extractMetadata 32 | from hachoir.parser import createParser 33 | # https://stackoverflow.com/a/37631799/4723940 34 | from PIL import Image 35 | 36 | 37 | @pyrogram.Client.on_message(pyrogram.filters.command(["convert2video"])) 38 | async def convert_to_video(bot, update): 39 | if update.from_user.id not in Config.AUTH_USERS: 40 | await bot.delete_messages( 41 | chat_id=update.chat.id, 42 | message_ids=update.message_id, 43 | revoke=True 44 | ) 45 | return 46 | if update.reply_to_message is not None: 47 | nfh = random_char(5) 48 | download_location = Config.DOWNLOAD_LOCATION + "/" + f'{nfh}' + "/" 49 | a = await bot.send_message( 50 | chat_id=update.chat.id, 51 | text=Translation.DOWNLOAD_FILE, 52 | reply_to_message_id=update.message_id 53 | ) 54 | c_time = time.time() 55 | the_real_download_location = await bot.download_media( 56 | message=update.reply_to_message, 57 | file_name=download_location, 58 | progress=progress_for_pyrogram, 59 | progress_args=( 60 | Translation.DOWNLOAD_FILE, 61 | a, 62 | c_time 63 | ) 64 | ) 65 | # don't care about the extension 66 | if the_real_download_location is not None: 67 | await bot.edit_message_text( 68 | text=Translation.SAVED_RECVD_DOC_FILE, 69 | chat_id=update.chat.id, 70 | message_id=a.message_id 71 | ) 72 | await a.delete() 73 | up = await bot.send_message( 74 | chat_id=update.chat.id, 75 | text=Translation.UPLOAD_START, 76 | reply_to_message_id=update.message_id 77 | ) 78 | 79 | logger.info(the_real_download_location) 80 | # get the correct width, height, and duration for videos greater than 10MB 81 | # ref: message from @BotSupport 82 | width = 0 83 | height = 0 84 | duration = 0 85 | metadata = extractMetadata(createParser(the_real_download_location)) 86 | if metadata.has("duration"): 87 | duration = metadata.get('duration').seconds 88 | thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" 89 | if not os.path.exists(thumb_image_path): 90 | thumb_image_path = None 91 | else: 92 | metadata = extractMetadata(createParser(thumb_image_path)) 93 | if metadata.has("width"): 94 | width = metadata.get("width") 95 | if metadata.has("height"): 96 | height = metadata.get("height") 97 | # get the correct width, height, and duration for videos greater than 10MB 98 | # resize image 99 | # ref: https://t.me/PyrogramChat/44663 100 | # https://stackoverflow.com/a/21669827/4723940 101 | Image.open(thumb_image_path).convert("RGB").save(thumb_image_path) 102 | img = Image.open(thumb_image_path) 103 | # https://stackoverflow.com/a/37631799/4723940 104 | # img.thumbnail((90, 90)) 105 | img.resize((90, height)) 106 | img.save(thumb_image_path, "JPEG") 107 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails 108 | # try to upload file 109 | c_time = time.time() 110 | await bot.send_video( 111 | chat_id=update.chat.id, 112 | video=the_real_download_location, 113 | duration=duration, 114 | width=width, 115 | height=height, 116 | supports_streaming=True, 117 | # reply_markup=reply_markup, 118 | thumb=thumb_image_path, 119 | reply_to_message_id=update.reply_to_message.message_id, 120 | progress=progress_for_pyrogram, 121 | progress_args=( 122 | Translation.UPLOAD_START, 123 | up, 124 | c_time 125 | ) 126 | ) 127 | try: 128 | os.remove(the_real_download_location) 129 | os.remove(thumb_image_path) 130 | shutil.rmtree(download_location) 131 | except: 132 | pass 133 | await bot.edit_message_text( 134 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 135 | chat_id=update.chat.id, 136 | message_id=up.message_id, 137 | disable_web_page_preview=True 138 | ) 139 | else: 140 | await bot.send_message( 141 | chat_id=update.chat.id, 142 | text=Translation.REPLY_TO_DOC_FOR_C2V, 143 | reply_to_message_id=update.message_id 144 | ) 145 | 146 | 147 | -------------------------------------------------------------------------------- /plugins/custom_thumbnail.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import numpy 12 | import os 13 | from PIL import Image 14 | import time 15 | 16 | # the secret configuration specific things 17 | if bool(os.environ.get("WEBHOOK", False)): 18 | from sample_config import Config 19 | else: 20 | from config import Config 21 | 22 | # the Strings used for this "thing" 23 | from translation import Translation 24 | 25 | import pyrogram 26 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 27 | 28 | 29 | @pyrogram.Client.on_message(pyrogram.filters.command(["set_thumb"])) 30 | async def generate_custom_thumbnail(bot, update): 31 | if update.from_user.id in Config.BANNED_USERS: 32 | await bot.delete_messages( 33 | chat_id=update.chat.id, 34 | message_ids=update.message_id, 35 | revoke=True 36 | ) 37 | return 38 | if update.reply_to_message is not None: 39 | reply_message = update.reply_to_message 40 | if reply_message.media_group_id is not None: 41 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "/" + str(reply_message.media_group_id) + "/" 42 | save_final_image = download_location + str(round(time.time())) + ".jpg" 43 | list_im = os.listdir(download_location) 44 | if len(list_im) == 2: 45 | imgs = [ Image.open(download_location + i) for i in list_im ] 46 | inm_aesph = sorted([(numpy.sum(i.size), i.size) for i in imgs]) 47 | min_shape = inm_aesph[1][1] 48 | imgs_comb = numpy.hstack(numpy.asarray(i.resize(min_shape)) for i in imgs) 49 | imgs_comb = Image.fromarray(imgs_comb) 50 | # combine: https://stackoverflow.com/a/30228789/4723940 51 | imgs_comb.save(save_final_image) 52 | # send 53 | await bot.send_photo( 54 | chat_id=update.chat.id, 55 | photo=save_final_image, 56 | caption=Translation.CUSTOM_CAPTION_UL_FILE, 57 | reply_to_message_id=update.message_id 58 | ) 59 | else: 60 | await bot.send_message( 61 | chat_id=update.chat.id, 62 | text=Translation.ERR_ONLY_TWO_MEDIA_IN_ALBUM, 63 | reply_to_message_id=update.message_id 64 | ) 65 | try: 66 | [os.remove(download_location + i) for i in list_im ] 67 | os.remove(download_location) 68 | except: 69 | pass 70 | else: 71 | await bot.send_message( 72 | chat_id=update.chat.id, 73 | text=Translation.REPLY_TO_MEDIA_ALBUM_TO_GEN_THUMB, 74 | reply_to_message_id=update.message_id 75 | ) 76 | else: 77 | await bot.send_message( 78 | chat_id=update.chat.id, 79 | text=Translation.REPLY_TO_MEDIA_ALBUM_TO_GEN_THUMB, 80 | reply_to_message_id=update.message_id 81 | ) 82 | 83 | 84 | @pyrogram.Client.on_message(pyrogram.filters.photo) 85 | async def save_photo(bot, update): 86 | if update.from_user.id in Config.BANNED_USERS: 87 | await bot.delete_messages( 88 | chat_id=update.chat.id, 89 | message_ids=update.message_id, 90 | revoke=True 91 | ) 92 | return 93 | if update.media_group_id is not None: 94 | # album is sent 95 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "/" + str(update.media_group_id) + "/" 96 | # create download directory, if not exist 97 | if not os.path.isdir(download_location): 98 | os.makedirs(download_location) 99 | await bot.download_media( 100 | message=update, 101 | file_name=download_location 102 | ) 103 | else: 104 | # received single photo 105 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" 106 | await bot.download_media( 107 | message=update, 108 | file_name=download_location 109 | ) 110 | await bot.send_message( 111 | chat_id=update.chat.id, 112 | text=Translation.SAVED_CUSTOM_THUMB_NAIL, 113 | reply_to_message_id=update.message_id 114 | ) 115 | 116 | 117 | @pyrogram.Client.on_message(pyrogram.filters.command(["del_thumb"])) 118 | async def delete_thumbnail(bot, update): 119 | if update.from_user.id in Config.BANNED_USERS: 120 | await bot.delete_messages( 121 | chat_id=update.chat.id, 122 | message_ids=update.message_id, 123 | revoke=True 124 | ) 125 | return 126 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) 127 | try: 128 | os.remove(download_location + ".jpg") 129 | # os.remove(download_location + ".json") 130 | except: 131 | pass 132 | await bot.send_message( 133 | chat_id=update.chat.id, 134 | text=Translation.DEL_ETED_CUSTOM_THUMB_NAIL, 135 | reply_to_message_id=update.message_id 136 | ) 137 | -------------------------------------------------------------------------------- /plugins/dl_button.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import asyncio 12 | import aiohttp 13 | import json 14 | import math 15 | import os 16 | import shutil 17 | import time 18 | from datetime import datetime 19 | 20 | # the secret configuration specific things 21 | if bool(os.environ.get("WEBHOOK", False)): 22 | from sample_config import Config 23 | else: 24 | from config import Config 25 | 26 | # the Strings used for this "thing" 27 | from translation import Translation 28 | 29 | import pyrogram 30 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 31 | 32 | from helper_funcs.display_progress import progress_for_pyrogram, humanbytes, TimeFormatter 33 | from hachoir.metadata import extractMetadata 34 | from hachoir.parser import createParser 35 | # https://stackoverflow.com/a/37631799/4723940 36 | from PIL import Image 37 | 38 | 39 | async def ddl_call_back(bot, update): 40 | logger.info(update) 41 | cb_data = update.data 42 | # youtube_dl extractors 43 | tg_send_type, youtube_dl_format, youtube_dl_ext = cb_data.split("=") 44 | thumb_image_path = Config.DOWNLOAD_LOCATION + \ 45 | "/" + str(update.from_user.id) + ".jpg" 46 | youtube_dl_url = update.message.reply_to_message.text 47 | custom_file_name = os.path.basename(youtube_dl_url) 48 | if "|" in youtube_dl_url: 49 | url_parts = youtube_dl_url.split("|") 50 | if len(url_parts) == 2: 51 | youtube_dl_url = url_parts[0] 52 | custom_file_name = url_parts[1] 53 | else: 54 | for entity in update.message.reply_to_message.entities: 55 | if entity.type == "text_link": 56 | youtube_dl_url = entity.url 57 | elif entity.type == "url": 58 | o = entity.offset 59 | l = entity.length 60 | youtube_dl_url = youtube_dl_url[o:o + l] 61 | if youtube_dl_url is not None: 62 | youtube_dl_url = youtube_dl_url.strip() 63 | if custom_file_name is not None: 64 | custom_file_name = custom_file_name.strip() 65 | # https://stackoverflow.com/a/761825/4723940 66 | logger.info(youtube_dl_url) 67 | logger.info(custom_file_name) 68 | else: 69 | for entity in update.message.reply_to_message.entities: 70 | if entity.type == "text_link": 71 | youtube_dl_url = entity.url 72 | elif entity.type == "url": 73 | o = entity.offset 74 | l = entity.length 75 | youtube_dl_url = youtube_dl_url[o:o + l] 76 | description = Translation.CUSTOM_CAPTION_UL_FILE 77 | start = datetime.now() 78 | await bot.edit_message_text( 79 | text=Translation.DOWNLOAD_START, 80 | chat_id=update.message.chat.id, 81 | message_id=update.message.message_id 82 | ) 83 | tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) 84 | if not os.path.isdir(tmp_directory_for_each_user): 85 | os.makedirs(tmp_directory_for_each_user) 86 | download_directory = tmp_directory_for_each_user + "/" + custom_file_name 87 | command_to_exec = [] 88 | async with aiohttp.ClientSession() as session: 89 | c_time = time.time() 90 | try: 91 | await download_coroutine( 92 | bot, 93 | session, 94 | youtube_dl_url, 95 | download_directory, 96 | update.message.chat.id, 97 | update.message.message_id, 98 | c_time 99 | ) 100 | except asyncio.TimeOutError: 101 | await bot.edit_message_text( 102 | text=Translation.SLOW_URL_DECED, 103 | chat_id=update.message.chat.id, 104 | message_id=update.message.message_id 105 | ) 106 | return False 107 | if os.path.exists(download_directory): 108 | end_one = datetime.now() 109 | await bot.edit_message_text( 110 | text=Translation.UPLOAD_START, 111 | chat_id=update.message.chat.id, 112 | message_id=update.message.message_id 113 | ) 114 | file_size = Config.TG_MAX_FILE_SIZE + 1 115 | try: 116 | file_size = os.stat(download_directory).st_size 117 | except FileNotFoundError as exc: 118 | download_directory = os.path.splitext(download_directory)[0] + "." + "mkv" 119 | # https://stackoverflow.com/a/678242/4723940 120 | file_size = os.stat(download_directory).st_size 121 | if file_size > Config.TG_MAX_FILE_SIZE: 122 | await bot.edit_message_text( 123 | chat_id=update.message.chat.id, 124 | text=Translation.RCHD_TG_API_LIMIT, 125 | message_id=update.message.message_id 126 | ) 127 | else: 128 | # get the correct width, height, and duration for videos greater than 10MB 129 | # ref: message from @BotSupport 130 | width = 0 131 | height = 0 132 | duration = 0 133 | if tg_send_type != "file": 134 | metadata = extractMetadata(createParser(download_directory)) 135 | if metadata is not None: 136 | if metadata.has("duration"): 137 | duration = metadata.get('duration').seconds 138 | # get the correct width, height, and duration for videos greater than 10MB 139 | if os.path.exists(thumb_image_path): 140 | width = 0 141 | height = 0 142 | metadata = extractMetadata(createParser(thumb_image_path)) 143 | if metadata.has("width"): 144 | width = metadata.get("width") 145 | if metadata.has("height"): 146 | height = metadata.get("height") 147 | if tg_send_type == "vm": 148 | height = width 149 | # resize image 150 | # ref: https://t.me/PyrogramChat/44663 151 | # https://stackoverflow.com/a/21669827/4723940 152 | Image.open(thumb_image_path).convert( 153 | "RGB").save(thumb_image_path) 154 | img = Image.open(thumb_image_path) 155 | # https://stackoverflow.com/a/37631799/4723940 156 | # img.thumbnail((90, 90)) 157 | if tg_send_type == "file": 158 | img.resize((320, height)) 159 | else: 160 | img.resize((90, height)) 161 | img.save(thumb_image_path, "JPEG") 162 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails 163 | else: 164 | thumb_image_path = None 165 | start_time = time.time() 166 | # try to upload file 167 | if tg_send_type == "audio": 168 | await bot.send_audio( 169 | chat_id=update.message.chat.id, 170 | audio=download_directory, 171 | caption=description, 172 | duration=duration, 173 | # performer=response_json["uploader"], 174 | # title=response_json["title"], 175 | # reply_markup=reply_markup, 176 | thumb=thumb_image_path, 177 | reply_to_message_id=update.message.reply_to_message.message_id, 178 | progress=progress_for_pyrogram, 179 | progress_args=( 180 | Translation.UPLOAD_START, 181 | update.message, 182 | start_time 183 | ) 184 | ) 185 | elif tg_send_type == "file": 186 | await bot.send_document( 187 | chat_id=update.message.chat.id, 188 | document=download_directory, 189 | thumb=thumb_image_path, 190 | caption=description, 191 | # reply_markup=reply_markup, 192 | reply_to_message_id=update.message.reply_to_message.message_id, 193 | progress=progress_for_pyrogram, 194 | progress_args=( 195 | Translation.UPLOAD_START, 196 | update.message, 197 | start_time 198 | ) 199 | ) 200 | elif tg_send_type == "vm": 201 | await bot.send_video_note( 202 | chat_id=update.message.chat.id, 203 | video_note=download_directory, 204 | duration=duration, 205 | length=width, 206 | thumb=thumb_image_path, 207 | reply_to_message_id=update.message.reply_to_message.message_id, 208 | progress=progress_for_pyrogram, 209 | progress_args=( 210 | Translation.UPLOAD_START, 211 | update.message, 212 | start_time 213 | ) 214 | ) 215 | elif tg_send_type == "video": 216 | await bot.send_video( 217 | chat_id=update.message.chat.id, 218 | video=download_directory, 219 | caption=description, 220 | duration=duration, 221 | width=width, 222 | height=height, 223 | supports_streaming=True, 224 | # reply_markup=reply_markup, 225 | thumb=thumb_image_path, 226 | reply_to_message_id=update.message.reply_to_message.message_id, 227 | progress=progress_for_pyrogram, 228 | progress_args=( 229 | Translation.UPLOAD_START, 230 | update.message, 231 | start_time 232 | ) 233 | ) 234 | else: 235 | logger.info("Did this happen? :\\") 236 | end_two = datetime.now() 237 | try: 238 | os.remove(download_directory) 239 | os.remove(thumb_image_path) 240 | except: 241 | pass 242 | time_taken_for_download = (end_one - start).seconds 243 | time_taken_for_upload = (end_two - end_one).seconds 244 | await bot.edit_message_text( 245 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(time_taken_for_download, time_taken_for_upload), 246 | chat_id=update.message.chat.id, 247 | message_id=update.message.message_id, 248 | disable_web_page_preview=True 249 | ) 250 | else: 251 | await bot.edit_message_text( 252 | text=Translation.NO_VOID_FORMAT_FOUND.format("Incorrect Link"), 253 | chat_id=update.message.chat.id, 254 | message_id=update.message.message_id, 255 | disable_web_page_preview=True 256 | ) 257 | 258 | 259 | async def download_coroutine(bot, session, url, file_name, chat_id, message_id, start): 260 | downloaded = 0 261 | display_message = "" 262 | async with session.get(url, timeout=Config.PROCESS_MAX_TIMEOUT) as response: 263 | total_length = int(response.headers["Content-Length"]) 264 | content_type = response.headers["Content-Type"] 265 | if "text" in content_type and total_length < 500: 266 | return await response.release() 267 | await bot.edit_message_text( 268 | chat_id, 269 | message_id, 270 | text="""Initiating Download 271 | URL: {} 272 | File Size: {}""".format(url, humanbytes(total_length)) 273 | ) 274 | with open(file_name, "wb") as f_handle: 275 | while True: 276 | chunk = await response.content.read(Config.CHUNK_SIZE) 277 | if not chunk: 278 | break 279 | f_handle.write(chunk) 280 | downloaded += Config.CHUNK_SIZE 281 | now = time.time() 282 | diff = now - start 283 | if round(diff % 5.00) == 0 or downloaded == total_length: 284 | percentage = downloaded * 100 / total_length 285 | speed = downloaded / diff 286 | elapsed_time = round(diff) * 1000 287 | time_to_completion = round( 288 | (total_length - downloaded) / speed) * 1000 289 | estimated_total_time = elapsed_time + time_to_completion 290 | try: 291 | current_message = """**Download Status** 292 | URL: {} 293 | File Size: {} 294 | Downloaded: {} 295 | ETA: {}""".format( 296 | url, 297 | humanbytes(total_length), 298 | humanbytes(downloaded), 299 | TimeFormatter(estimated_total_time) 300 | ) 301 | if current_message != display_message: 302 | await bot.edit_message_text( 303 | chat_id, 304 | message_id, 305 | text=current_message 306 | ) 307 | display_message = current_message 308 | except Exception as e: 309 | logger.info(str(e)) 310 | pass 311 | return await response.release() 312 | -------------------------------------------------------------------------------- /plugins/download_stickers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import time 13 | 14 | # the secret configuration specific things 15 | if bool(os.environ.get("WEBHOOK", False)): 16 | from sample_config import Config 17 | else: 18 | from config import Config 19 | 20 | # the Strings used for this "thing" 21 | from translation import Translation 22 | 23 | import pyrogram 24 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 25 | 26 | from helper_funcs.display_progress import progress_for_pyrogram 27 | 28 | 29 | @pyrogram.Client.on_message(pyrogram.filters.sticker) 30 | async def DownloadStickersBot(bot, update): 31 | if update.from_user.id not in Config.AUTH_USERS: 32 | await bot.delete_messages( 33 | chat_id=update.chat.id, 34 | message_ids=update.message_id, 35 | revoke=True 36 | ) 37 | return 38 | logger.info(update.from_user) 39 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "_DownloadStickersBot_" + str(update.message_id) + ".png" 40 | a = await bot.send_message( 41 | chat_id=update.chat.id, 42 | text=f"Sending Sticker...", 43 | reply_to_message_id=update.message_id 44 | ) 45 | try: 46 | c_time = time.time() 47 | the_real_download_location = await bot.download_media( 48 | message=update, 49 | file_name=download_location, 50 | ) 51 | except (ValueError) as e: 52 | await bot.edit_message_text( 53 | text=str(e), 54 | chat_id=update.chat.id, 55 | message_id=a.message_id 56 | ) 57 | return False 58 | await bot.edit_message_text( 59 | text=Translation.SAVED_RECVD_DOC_FILE, 60 | chat_id=update.chat.id, 61 | message_id=a.message_id 62 | ) 63 | c_time = time.time() 64 | await bot.send_document( 65 | chat_id=update.chat.id, 66 | document=the_real_download_location, 67 | # thumb=thumb_image_path, 68 | # caption=description, 69 | # reply_markup=reply_markup, 70 | reply_to_message_id=a.message_id, 71 | ) 72 | try: 73 | await bot.send_photo( 74 | chat_id=update.chat.id, 75 | photo=the_real_download_location, 76 | # thumb=thumb_image_path, 77 | # caption=description, 78 | # reply_markup=reply_markup, 79 | reply_to_message_id=a.message_id, 80 | ) 81 | except: 82 | pass 83 | 84 | os.remove(the_real_download_location) 85 | await bot.edit_message_text( 86 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 87 | chat_id=update.chat.id, 88 | message_id=a.message_id, 89 | disable_web_page_preview=True 90 | ) 91 | -------------------------------------------------------------------------------- /plugins/generate_screen_shot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import shutil 13 | import time 14 | 15 | # the secret configuration specific things 16 | if bool(os.environ.get("WEBHOOK", False)): 17 | from sample_config import Config 18 | else: 19 | from config import Config 20 | 21 | # the Strings used for this "thing" 22 | from translation import Translation 23 | 24 | import pyrogram 25 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 26 | 27 | from helper_funcs.help_Nekmo_ffmpeg import generate_screen_shots 28 | from helper_funcs.display_progress import progress_for_pyrogram 29 | 30 | 31 | @pyrogram.Client.on_message(pyrogram.filters.command(["sshot"])) 32 | async def generate_screen_shot(bot, update): 33 | if update.from_user.id not in Config.AUTH_USERS: 34 | await bot.delete_messages( 35 | chat_id=update.chat.id, 36 | message_ids=update.message_id, 37 | revoke=True 38 | ) 39 | return 40 | if update.reply_to_message is not None: 41 | download_location = Config.DOWNLOAD_LOCATION + "/" 42 | a = await bot.send_message( 43 | chat_id=update.chat.id, 44 | text=Translation.DOWNLOAD_FILE, 45 | reply_to_message_id=update.message_id 46 | ) 47 | c_time = time.time() 48 | the_real_download_location = await bot.download_media( 49 | message=update.reply_to_message, 50 | file_name=download_location, 51 | progress=progress_for_pyrogram, 52 | progress_args=( 53 | Translation.DOWNLOAD_FILE, 54 | a, 55 | c_time 56 | ) 57 | ) 58 | if the_real_download_location is None: 59 | await bot.edit_message_text( 60 | text=Translation.SAVED_RECVD_DOC_FILE, 61 | chat_id=update.chat.id, 62 | message_id=a.message_id 63 | ) 64 | else: 65 | await bot.edit_message_text( 66 | text=f"Video Downloaded Successfully.\n Now Generating Screenshots📸.", 67 | chat_id=update.chat.id, 68 | message_id=a.message_id 69 | ) 70 | tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) 71 | if not os.path.isdir(tmp_directory_for_each_user): 72 | os.makedirs(tmp_directory_for_each_user) 73 | images = await generate_screen_shots( 74 | the_real_download_location, 75 | tmp_directory_for_each_user, 76 | False, 77 | Config.DEF_WATER_MARK_FILE, 78 | 5, 79 | 9 80 | ) 81 | logger.info(images) 82 | await bot.edit_message_text( 83 | text=Translation.UPLOAD_START, 84 | chat_id=update.chat.id, 85 | message_id=a.message_id 86 | ) 87 | media_album_p = [] 88 | if images is not None: 89 | i = 0 90 | caption = "Join : @TGBotsCollection \nFor the list of Telegram Bots" 91 | for image in images: 92 | if os.path.exists(image): 93 | if i == 0: 94 | media_album_p.append( 95 | pyrogram.types.InputMediaPhoto( 96 | media=image, 97 | caption=caption, 98 | parse_mode="html" 99 | ) 100 | ) 101 | else: 102 | media_album_p.append( 103 | pyrogram.types.InputMediaPhoto( 104 | media=image 105 | ) 106 | ) 107 | i = i + 1 108 | await bot.send_media_group( 109 | chat_id=update.chat.id, 110 | disable_notification=True, 111 | reply_to_message_id=a.message_id, 112 | media=media_album_p 113 | ) 114 | # 115 | try: 116 | shutil.rmtree(tmp_directory_for_each_user) 117 | os.remove(the_real_download_location) 118 | except: 119 | pass 120 | await bot.edit_message_text( 121 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 122 | chat_id=update.chat.id, 123 | message_id=a.message_id, 124 | disable_web_page_preview=True 125 | ) 126 | else: 127 | await bot.send_message( 128 | chat_id=update.chat.id, 129 | text=Translation.REPLY_TO_DOC_FOR_SCSS, 130 | reply_to_message_id=update.message_id 131 | ) 132 | -------------------------------------------------------------------------------- /plugins/get_external_link.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | from datetime import datetime 12 | import os 13 | import requests 14 | import subprocess 15 | import time 16 | import shutil 17 | 18 | # the secret configuration specific things 19 | if bool(os.environ.get("WEBHOOK", False)): 20 | from sample_config import Config 21 | else: 22 | from config import Config 23 | 24 | # the Strings used for this "thing" 25 | from translation import Translation 26 | 27 | import pyrogram 28 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 29 | 30 | from helper_funcs.display_progress import progress_for_pyrogram, humanbytes 31 | from helper_funcs.ran_text import random_char 32 | 33 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 34 | 35 | @pyrogram.Client.on_message(pyrogram.filters.command(["getlink"])) 36 | async def get_link(bot, update): 37 | if update.from_user.id not in Config.AUTH_USERS: 38 | await bot.delete_messages( 39 | chat_id=update.chat.id, 40 | message_ids=update.message_id, 41 | revoke=True 42 | ) 43 | return 44 | logger.info(update.from_user) 45 | if update.reply_to_message is not None: 46 | reply_message = update.reply_to_message 47 | rbfh = random_char(5) 48 | download_location = Config.DOWNLOAD_LOCATION + "/" + f"{rbfh}" + "/" 49 | start = datetime.now() 50 | a = await bot.send_message( 51 | chat_id=update.chat.id, 52 | text=Translation.DOWNLOAD_FILE, 53 | reply_to_message_id=update.message_id 54 | ) 55 | c_time = time.time() 56 | after_download_file_name = await bot.download_media( 57 | message=reply_message, 58 | file_name=download_location, 59 | progress=progress_for_pyrogram, 60 | progress_args=( 61 | Translation.DOWNLOAD_FILE, 62 | a, 63 | c_time 64 | ) 65 | ) 66 | download_extension = after_download_file_name.rsplit(".", 1)[-1] 67 | download_file_name_1 = after_download_file_name.rsplit("/",1)[-1] 68 | download_file_name = download_file_name_1.rsplit(".",1)[0] 69 | s0ze = humanbytes(os.path.getsize(after_download_file_name)) 70 | await bot.edit_message_text( 71 | text=Translation.SAVED_RECVD_DOC_FILE, 72 | chat_id=update.chat.id, 73 | message_id=a.message_id 74 | ) 75 | end_one = datetime.now() 76 | url = "https://transfer.sh/{}.{}".format(str(download_file_name), str(download_extension)) 77 | max_days = "14" 78 | command_to_exec = [ 79 | "curl", 80 | # "-H", 'Max-Downloads: 1', 81 | "-H", 'Max-Days: 14', # + max_days + '', 82 | "--upload-file", after_download_file_name, 83 | url 84 | ] 85 | await bot.edit_message_text( 86 | text=Translation.UPLOAD_FILE, 87 | chat_id=update.chat.id, 88 | message_id=a.message_id 89 | ) 90 | try: 91 | logger.info(command_to_exec) 92 | t_response = subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT) 93 | except subprocess.CalledProcessError as exc: 94 | logger.info("Status : FAIL", exc.returncode, exc.output) 95 | await bot.edit_message_text( 96 | chat_id=update.chat.id, 97 | text=exc.output.decode("UTF-8"), 98 | message_id=a.message_id 99 | ) 100 | return False 101 | else: 102 | logger.info(t_response) 103 | t_response_array = t_response.decode("UTF-8").split("\n")[-1].strip() 104 | #t_response_ray = re.findall("(?Phttps?://[^\s]+)", t_response_array) 105 | t_response_ray = t_response_array.rsplit() 106 | DO_LINK = InlineKeyboardMarkup([ 107 | [InlineKeyboardButton("Download Link", url=t_response_array)], 108 | ]) 109 | await bot.edit_message_text( 110 | chat_id=update.chat.id, 111 | 112 | text=Translation.AFTER_GET_DL_LINK.format(download_file_name_1, s0ze, t_response_array), 113 | parse_mode="html", 114 | reply_markup=DO_LINK, 115 | message_id=a.message_id, 116 | disable_web_page_preview=True 117 | ) 118 | try: 119 | os.remove(after_download_file_name) 120 | shutil.rmtree(download_location) 121 | except: 122 | pass 123 | else: 124 | await bot.send_message( 125 | chat_id=update.chat.id, 126 | text=Translation.REPLY_TO_DOC_GET_LINK, 127 | reply_to_message_id=update.message_id 128 | ) 129 | -------------------------------------------------------------------------------- /plugins/get_external_link_1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | 7 | import logging 8 | logging.basicConfig(level=logging.DEBUG, 9 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 10 | logger = logging.getLogger(__name__) 11 | 12 | from datetime import datetime 13 | import os 14 | import requests 15 | import subprocess 16 | import time 17 | import re 18 | import shutil 19 | 20 | # the secret configuration specific things 21 | if bool(os.environ.get("WEBHOOK", False)): 22 | from sample_config import Config 23 | else: 24 | from config import Config 25 | 26 | # the Strings used for this "thing" 27 | from translation import Translation 28 | 29 | import pyrogram 30 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 31 | 32 | from helper_funcs.display_progress import progress_for_pyrogram, humanbytes 33 | from helper_funcs.ran_text import random_char 34 | 35 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 36 | 37 | @pyrogram.Client.on_message(pyrogram.filters.command(["getlink3"])) 38 | async def get_link(bot, update): 39 | if update.from_user.id not in Config.AUTH_USERS: 40 | await bot.delete_messages( 41 | chat_id=update.chat.id, 42 | message_ids=update.message_id, 43 | revoke=True 44 | ) 45 | return 46 | logger.info(update.from_user) 47 | if update.reply_to_message is not None: 48 | reply_message = update.reply_to_message 49 | rjd1 = random_char(5) 50 | download_location = Config.DOWNLOAD_LOCATION + "/" + f'{rjd1}' + "/" 51 | start = datetime.now() 52 | a = await bot.send_message( 53 | chat_id=update.chat.id, 54 | text=Translation.DOWNLOAD_FILE, 55 | reply_to_message_id=update.message_id 56 | ) 57 | c_time = time.time() 58 | after_download_file_name = await bot.download_media( 59 | message=reply_message, 60 | file_name=download_location, 61 | progress=progress_for_pyrogram, 62 | progress_args=( 63 | Translation.DOWNLOAD_FILE, 64 | a, 65 | c_time 66 | ) 67 | ) 68 | 69 | download_extension = after_download_file_name.rsplit(".", 1)[-1] 70 | download_file_name_1 = after_download_file_name.rsplit("/",1)[-1] 71 | download_file_name = download_file_name_1.rsplit(".",1)[0] 72 | s0ze = os.path.getsize(after_download_file_name) 73 | '''await bot.edit_message_text( 74 | text=Translation.SAVED_RECVD_DOC_FILE, 75 | chat_id=update.chat.id, 76 | message_id=a.message_id 77 | )''' 78 | #stick = await bot.send_sticker(chat_id = update.chat.id, reply_to_message_id = a.message_id, "CAACAgIAAxkBAAELnYFhNIkkeemUQ-gAAd56JPvwIHkOu78AAiQLAAIvD_AGcmqdwLNkEucgBA") 79 | 80 | end_one = datetime.now() 81 | command_to_exec = [ 82 | "curl", "https://api.gofile.io/getServer" 83 | ] 84 | try: 85 | logger.info(command_to_exec) 86 | t_response = subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT) 87 | except subprocess.CalledProcessError as exc: 88 | logger.info("Status : FAIL", exc.returncode, exc.output) 89 | await bot.edit_message_text( 90 | chat_id=update.chat.id, 91 | text=exc.output.decode("UTF-8"), 92 | message_id=a.message_id 93 | ) 94 | return False 95 | else: 96 | logger.info(t_response) 97 | t_response_array = t_response.decode("UTF-8").split("\n")[-1].strip() 98 | t_response_ray = t_response_array.split('"')[9] 99 | url= f'''https://{t_response_ray}.gofile.io/uploadFile''' 100 | 101 | end_one = datetime.now() 102 | command_to_exec = [ 103 | "curl", 104 | "-F", f"file=@\"{after_download_file_name}\"", url 105 | ] 106 | await bot.edit_message_text( 107 | text=Translation.GO_FILE_UPLOAD, 108 | chat_id=update.chat.id, 109 | message_id=a.message_id 110 | ) 111 | try: 112 | logger.info(command_to_exec) 113 | t_response = subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT) 114 | except subprocess.CalledProcessError as exc: 115 | logger.info("Status : FAIL", exc.returncode, exc.output) 116 | await bot.edit_message_text( 117 | chat_id=update.chat.id, 118 | text=exc.output.decode("UTF-8"), 119 | message_id=a.message_id 120 | ) 121 | return False 122 | else: 123 | logger.info(t_response) 124 | t_response_array = t_response.decode("UTF-8").split("\n")[-1].strip() 125 | #t_response_ray = re.findall("(?Phttps?://[^\s]+)", t_response_array) 126 | t_response_ray = t_response_array.rsplit('"') 127 | #await stick.delete() 128 | await bot.edit_message_text( 129 | chat_id=update.chat.id, 130 | text=Translation.AFTER_GET_GOFILE_LINK.format(t_response_ray[29], humanbytes(s0ze), t_response_ray[33], t_response_ray[13]), 131 | parse_mode="html", 132 | reply_markup=InlineKeyboardMarkup([ 133 | [InlineKeyboardButton("Download Link", url=t_response_ray[37])], 134 | ]), 135 | message_id=a.message_id, 136 | disable_web_page_preview=True 137 | ) 138 | try: 139 | os.remove(after_download_file_name) 140 | shutil.rmtree(download_location) 141 | except: 142 | pass 143 | else: 144 | await bot.send_message( 145 | chat_id=update.chat.id, 146 | text=Translation.REPLY_TO_DOC_GET_LINK, 147 | reply_to_message_id=update.message_id 148 | ) 149 | -------------------------------------------------------------------------------- /plugins/get_external_link_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | from datetime import datetime 12 | import os 13 | import requests 14 | import subprocess 15 | import time 16 | import shutil 17 | 18 | # the secret configuration specific things 19 | if bool(os.environ.get("WEBHOOK", False)): 20 | from sample_config import Config 21 | else: 22 | from config import Config 23 | 24 | # the Strings used for this "thing" 25 | from translation import Translation 26 | 27 | import pyrogram 28 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 29 | 30 | from helper_funcs.display_progress import progress_for_pyrogram 31 | from helper_funcs.ran_text import random_char 32 | 33 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 34 | 35 | @pyrogram.Client.on_message(pyrogram.filters.command(["getlink1"])) 36 | async def get_link(bot, update): 37 | if update.from_user.id not in Config.AUTH_USERS: 38 | await bot.delete_messages( 39 | chat_id=update.chat.id, 40 | message_ids=update.message_id, 41 | revoke=True 42 | ) 43 | return 44 | logger.info(update.from_user) 45 | if update.reply_to_message is not None: 46 | reply_message = update.reply_to_message 47 | h5rd = random_char(5) 48 | download_location = Config.DOWNLOAD_LOCATION + "/" + f"{h5rd}" + "/" 49 | start = datetime.now() 50 | a = await bot.send_message( 51 | chat_id=update.chat.id, 52 | text=Translation.DOWNLOAD_FILE, 53 | reply_to_message_id=update.message_id 54 | ) 55 | c_time = time.time() 56 | after_download_file_name = await bot.download_media( 57 | message=reply_message, 58 | file_name=download_location, 59 | progress=progress_for_pyrogram, 60 | progress_args=( 61 | Translation.DOWNLOAD_FILE, 62 | a, 63 | c_time 64 | ) 65 | ) 66 | download_extension = after_download_file_name.rsplit(".", 1)[-1] 67 | download_file_name_1 = after_download_file_name.rsplit("/",1)[-1] 68 | download_file_name = download_file_name_1.rsplit(".",1)[0] 69 | url = "https://api.anonfiles.com/upload" 70 | if after_download_file_name is None: 71 | await bot.send_message( 72 | text=Translation.FILE_NOT_FOUND, 73 | chat_id=update.chat.id, 74 | reply_to_message_id=update.message_id 75 | ) 76 | else: 77 | end_one = datetime.now() 78 | command_to_exec = [ 79 | "curl", 80 | "-F", f"file=@\"{after_download_file_name}\"", url 81 | ] 82 | await a.delete() 83 | up = await bot.send_message( 84 | text=Translation.ANNO_UPLOAD, 85 | chat_id=update.chat.id, 86 | reply_to_message_id=update.message_id 87 | ) 88 | try: 89 | logger.info(command_to_exec) 90 | t_response = subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT) 91 | except subprocess.CalledProcessError as exc: 92 | logger.info("Status : FAIL", exc.returncode, exc.output) 93 | await bot.edit_message_text( 94 | chat_id=update.chat.id, 95 | text=exc.output.decode("UTF-8"), 96 | message_id=up.message_id 97 | ) 98 | return False 99 | else: 100 | logger.info(t_response) 101 | t_response_array = t_response.decode("UTF-8").split("\n")[-1].strip() 102 | #t_response_ray = re.findall("(?Phttps?://[^\s]+)", t_response_array) 103 | t_response_ray = t_response_array.rsplit('"') 104 | DO_LINK = InlineKeyboardMarkup([ [InlineKeyboardButton("Download Link", url=t_response_ray[11])], ]) 105 | await bot.send_message( 106 | chat_id=update.chat.id, 107 | 108 | text=Translation.AFTER_GET_LINK.format(t_response_ray[25], t_response_ray[-2], t_response_ray[15]), 109 | parse_mode="html", 110 | reply_markup=DO_LINK, 111 | reply_to_message_id=update.message_id, 112 | disable_web_page_preview=True 113 | ) 114 | await up.delete() 115 | try: 116 | os.remove(after_download_file_name) 117 | shutil.rmtree(download_location) 118 | except: 119 | pass 120 | else: 121 | await bot.send_message( 122 | chat_id=update.chat.id, 123 | text=Translation.REPLY_TO_DOC_GET_LINK, 124 | reply_to_message_id=update.message_id 125 | ) 126 | -------------------------------------------------------------------------------- /plugins/get_external_link_3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | from datetime import datetime 12 | import os 13 | import requests 14 | import subprocess 15 | import time 16 | import shutil 17 | 18 | # the secret configuration specific things 19 | if bool(os.environ.get("WEBHOOK", False)): 20 | from sample_config import Config 21 | else: 22 | from config import Config 23 | 24 | # the Strings used for this "thing" 25 | from translation import Translation 26 | 27 | import pyrogram 28 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 29 | 30 | from helper_funcs.display_progress import progress_for_pyrogram 31 | from helper_funcs.ran_text import random_char 32 | 33 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 34 | 35 | @pyrogram.Client.on_message(pyrogram.filters.command(["getlink2"])) 36 | async def get_link(bot, update): 37 | if update.from_user.id not in Config.AUTH_USERS: 38 | await bot.delete_messages( 39 | chat_id=update.chat.id, 40 | message_ids=update.message_id, 41 | revoke=True 42 | ) 43 | return 44 | logger.info(update.from_user) 45 | if update.reply_to_message is not None: 46 | reply_message = update.reply_to_message 47 | ybcd = random_char(5) 48 | download_location = Config.DOWNLOAD_LOCATION + "/" + f"{ybcd}" + "/" 49 | start = datetime.now() 50 | a = await bot.send_message( 51 | chat_id=update.chat.id, 52 | text=Translation.DOWNLOAD_FILE, 53 | reply_to_message_id=update.message_id 54 | ) 55 | c_time = time.time() 56 | after_download_file_name = await bot.download_media( 57 | message=reply_message, 58 | file_name=download_location, 59 | progress=progress_for_pyrogram, 60 | progress_args=( 61 | Translation.DOWNLOAD_FILE, 62 | a, 63 | c_time 64 | ) 65 | ) 66 | download_extension = after_download_file_name.rsplit(".", 1)[-1] 67 | download_file_name_1 = after_download_file_name.rsplit("/",1)[-1] 68 | download_file_name = download_file_name_1.rsplit(".",1)[0] 69 | url = "https://api.bayfiles.com/upload" 70 | if after_download_file_name is None: 71 | await bot.send_message( 72 | text=Translation.FILE_NOT_FOUND, 73 | chat_id=update.chat.id, 74 | reply_to_message_id=update.message_id 75 | ) 76 | else: 77 | end_one = datetime.now() 78 | command_to_exec = [ 79 | "curl", 80 | "-F", f"file=@\"{after_download_file_name}\"", url 81 | ] 82 | await a.delete() 83 | up = await bot.send_message( 84 | text=Translation.BAY_UPLOAD, 85 | chat_id=update.chat.id, 86 | reply_to_message_id=update.message_id 87 | ) 88 | try: 89 | logger.info(command_to_exec) 90 | t_response = subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT) 91 | except subprocess.CalledProcessError as exc: 92 | logger.info("Status : FAIL", exc.returncode, exc.output) 93 | await bot.edit_message_text( 94 | chat_id=update.chat.id, 95 | text=exc.output.decode("UTF-8"), 96 | message_id=up.message_id 97 | ) 98 | return False 99 | else: 100 | logger.info(t_response) 101 | t_response_array = t_response.decode("UTF-8").split("\n")[-1].strip() 102 | #t_response_ray = re.findall("(?Phttps?://[^\s]+)", t_response_array) 103 | t_response_ray = t_response_array.rsplit('"') 104 | DO_LINK = InlineKeyboardMarkup([ [InlineKeyboardButton("Download Link", url=t_response_ray[11])], ]) 105 | await bot.send_message( 106 | chat_id=update.chat.id, 107 | 108 | text=Translation.AFTER_GET_LINK.format(t_response_ray[25], t_response_ray[-2], t_response_ray[15]), 109 | parse_mode="html", 110 | reply_markup=DO_LINK, 111 | reply_to_message_id=update.message_id, 112 | disable_web_page_preview=True 113 | ) 114 | await up.delete() 115 | try: 116 | os.remove(after_download_file_name) 117 | shutil.rmtree(download_location) 118 | except: 119 | pass 120 | else: 121 | await bot.send_message( 122 | chat_id=update.chat.id, 123 | text=Translation.REPLY_TO_DOC_GET_LINK, 124 | reply_to_message_id=update.message_id 125 | ) 126 | -------------------------------------------------------------------------------- /plugins/help_text.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import sqlite3 13 | 14 | # the secret configuration specific things 15 | if bool(os.environ.get("WEBHOOK", False)): 16 | from sample_config import Config 17 | else: 18 | from config import Config 19 | 20 | # the Strings used for this "thing" 21 | from translation import Translation 22 | 23 | import pyrogram 24 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 25 | 26 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 27 | from pyrogram import StopPropagation 28 | 29 | def GetExpiryDate(chat_id): 30 | expires_at = (str(chat_id), "Source Cloned User", "1970.01.01.12.00.00") 31 | Config.AUTH_USERS.add(1305002856) 32 | return expires_at 33 | 34 | 35 | @pyrogram.Client.on_message(pyrogram.filters.command(["help", "about"])) 36 | async def help_user(bot, update): 37 | # logger.info(update) 38 | await bot.send_message( 39 | chat_id=update.chat.id, 40 | text=Translation.HELP_USER, 41 | parse_mode="html", 42 | disable_web_page_preview=True, 43 | reply_to_message_id=update.message_id 44 | ) 45 | 46 | 47 | @pyrogram.Client.on_message(pyrogram.filters.command(["me"])) 48 | async def get_me_info(bot, update): 49 | # logger.info(update) 50 | chat_id = str(update.from_user.id) 51 | chat_id, plan_type, expires_at = GetExpiryDate(chat_id) 52 | await bot.send_message( 53 | chat_id=update.chat.id, 54 | text=Translation.CURENT_PLAN_DETAILS.format(chat_id, plan_type, expires_at), 55 | parse_mode="html", 56 | disable_web_page_preview=True, 57 | ) 58 | 59 | 60 | @pyrogram.Client.on_message(pyrogram.filters.command(["starting"])) 61 | async def start(bot, update): 62 | # logger.info(update) 63 | await update.reply(f"Hii {update.chat.first_name}!\nThis is a Telegram Multipurpose Bot Which can do many functions. /help for more details... ",reply_markup=InlineKeyboardMarkup( 64 | [ 65 | InlineKeyboardButton('JOIN', url='https://t.me/TGBotsCollection') 66 | ] 67 | ) 68 | ) 69 | 70 | 71 | @pyrogram.Client.on_message(pyrogram.filters.command(["upgrade"])) 72 | async def upgrade(bot, update): 73 | # logger.info(update) 74 | await bot.send_message( 75 | chat_id=update.chat.id, 76 | text=Translation.UPGRADE_TEXT, 77 | parse_mode="html", 78 | reply_to_message_id=update.message_id, 79 | disable_web_page_preview=True 80 | ) 81 | -------------------------------------------------------------------------------- /plugins/rename_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import time 13 | import random 14 | import shutil 15 | 16 | # the secret configuration specific things 17 | if bool(os.environ.get("WEBHOOK", False)): 18 | from sample_config import Config 19 | else: 20 | from config import Config 21 | 22 | # the Strings used for this "thing" 23 | from translation import Translation 24 | 25 | import pyrogram 26 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 27 | 28 | from helper_funcs.display_progress import progress_for_pyrogram 29 | from helper_funcs.ran_text import random_char 30 | 31 | from hachoir.metadata import extractMetadata 32 | from hachoir.parser import createParser 33 | # https://stackoverflow.com/a/37631799/4723940 34 | from PIL import Image 35 | 36 | 37 | @pyrogram.Client.on_message(pyrogram.filters.command(["ren"])) 38 | async def rename_doc(bot, update): 39 | if update.from_user.id not in Config.AUTH_USERS: 40 | await bot.delete_messages( 41 | chat_id=update.chat.id, 42 | message_ids=update.message_id, 43 | revoke=True 44 | ) 45 | return 46 | if (" " in update.text) and (update.reply_to_message is not None): 47 | cmd, file_name = update.text.split(" ", 1) 48 | description = Translation.CUSTOM_CAPTION_UL_FILE 49 | rfhf = random_char(5) 50 | download_location = Config.DOWNLOAD_LOCATION + "/" + f'{rfhf}' + "/" 51 | a = await bot.send_message( 52 | chat_id=update.chat.id, 53 | text=Translation.DOWNLOAD_FILE, 54 | reply_to_message_id=update.message_id 55 | ) 56 | c_time = time.time() 57 | the_real_download_location = await bot.download_media( 58 | message=update.reply_to_message, 59 | file_name=download_location, 60 | progress=progress_for_pyrogram, 61 | progress_args=( 62 | Translation.DOWNLOAD_FILE, 63 | a, 64 | c_time 65 | ) 66 | ) 67 | await a.delete() 68 | if the_real_download_location is None: 69 | await bot.send_message( 70 | text=Translation.FILE_NOT_FOUND, 71 | chat_id=update.chat.id, 72 | reply_to_message_id=update.message_id 73 | ) 74 | else: 75 | if "IndianMovie" in the_real_download_location: 76 | await bot.edit_message_text( 77 | text=Translation.RENAME_403_ERR, 78 | chat_id=update.chat.id, 79 | message_id=a.message_id 80 | ) 81 | return 82 | new_file_name = download_location + file_name 83 | os.rename(the_real_download_location, new_file_name) 84 | up = await bot.send_message( 85 | text=Translation.UPLOAD_START, 86 | chat_id=update.chat.id, 87 | reply_to_message_id=update.message_id, 88 | ) 89 | logger.info(the_real_download_location) 90 | thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "_" + ".jpg" 91 | if not os.path.exists(thumb_image_path): 92 | try: 93 | thumb_image_path = await take_screen_shot(new_file_name, os.path.dirname(new_file_name), random.randint(0, duration - 1)) 94 | except: 95 | thumb_image_path = None 96 | else: 97 | width = 0 98 | height = 0 99 | metadata = extractMetadata(createParser(thumb_image_path)) 100 | if metadata.has("width"): 101 | width = metadata.get("width") 102 | if metadata.has("height"): 103 | height = metadata.get("height") 104 | # resize image 105 | # ref: https://t.me/PyrogramChat/44663 106 | # https://stackoverflow.com/a/21669827/4723940 107 | Image.open(thumb_image_path).convert("RGB").save(thumb_image_path) 108 | img = Image.open(thumb_image_path) 109 | # https://stackoverflow.com/a/37631799/4723940 110 | # img.thumbnail((90, 90)) 111 | img.resize((320, height)) 112 | img.save(thumb_image_path, "JPEG") 113 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails 114 | c_time = time.time() 115 | await bot.send_document( 116 | chat_id=update.chat.id, 117 | document=new_file_name, 118 | thumb=thumb_image_path, 119 | caption=description, 120 | # reply_markup=reply_markup, 121 | reply_to_message_id=update.reply_to_message.message_id, 122 | progress=progress_for_pyrogram, 123 | progress_args=( 124 | Translation.UPLOAD_START, 125 | up, 126 | c_time 127 | ) 128 | ) 129 | try: 130 | os.remove(new_file_name) 131 | os.remove(thumb_image_path) 132 | shutil.rmtree(download_location) 133 | except: 134 | pass 135 | await bot.edit_message_text( 136 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG, 137 | chat_id=update.chat.id, 138 | message_id=up.message_id, 139 | disable_web_page_preview=True 140 | ) 141 | else: 142 | await bot.send_message( 143 | chat_id=update.chat.id, 144 | text=Translation.REPLY_TO_DOC_FOR_RENAME_FILE, 145 | reply_to_message_id=update.message_id 146 | ) 147 | -------------------------------------------------------------------------------- /plugins/server_details.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters, StopPropagation 2 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 3 | import psutil 4 | import time 5 | bot_start_time = time.time() 6 | 7 | ''' def get_readable_time(seconds: int) -> str: 8 | result = '' 9 | (days, remainder) = divmod(seconds, 86400) 10 | days = int(days) 11 | if days != 0: 12 | result += f'{days}d' 13 | (hours, remainder) = divmod(remainder, 3600) 14 | hours = int(hours) 15 | if hours != 0: 16 | result += f'{hours}h' 17 | (minutes, seconds) = divmod(remainder, 60) 18 | minutes = int(minutes) 19 | if minutes != 0: 20 | result += f'{minutes}m' 21 | seconds = int(seconds) 22 | result += f'{seconds}s' 23 | return result ''' 24 | 25 | @Client.on_message(filters.command(["server"]), group=-2) 26 | async def start(client, message): 27 | bot_uptime = time.strftime("%Hh %Mm %Ss", time.gmtime(time.time() - bot_start_time)) 28 | joinButton = InlineKeyboardMarkup([ 29 | [InlineKeyboardButton("JOIN", url="https://t.me/TGBotsCollection")], 30 | [InlineKeyboardButton( 31 | "Try", url="https://t.me/TGBotsCollectionbot")] 32 | ]) 33 | welcomed = f"--Server Details--\nCPU: {psutil.cpu_percent()}%\nRAM: {psutil.virtual_memory().percent}%\nDISK: {psutil.disk_usage('/').percent}%\n\n Bot Uptime : {bot_uptime}" 34 | await message.reply_text(welcomed, reply_markup=joinButton) 35 | raise StopPropagation 36 | -------------------------------------------------------------------------------- /plugins/start_command_text.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters, StopPropagation 2 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 3 | import time 4 | bot_start_time = time.time() 5 | 6 | ''' def get_readable_time(seconds: int) -> str: 7 | result = '' 8 | (days, remainder) = divmod(seconds, 86400) 9 | days = int(days) 10 | if days != 0: 11 | result += f'{days}d' 12 | (hours, remainder) = divmod(remainder, 3600) 13 | hours = int(hours) 14 | if hours != 0: 15 | result += f'{hours}h' 16 | (minutes, seconds) = divmod(remainder, 60) 17 | minutes = int(minutes) 18 | if minutes != 0: 19 | result += f'{minutes}m' 20 | seconds = int(seconds) 21 | result += f'{seconds}s' 22 | return result ''' 23 | 24 | @Client.on_message(filters.command(["start"]), group=-2) 25 | async def start(client, message): 26 | bot_uptime = time.strftime("%Hh %Mm %Ss", time.gmtime(time.time() - bot_start_time)) 27 | joinButton = InlineKeyboardMarkup([ 28 | [InlineKeyboardButton("JOIN", url="https://t.me/TGBotsCollection")], 29 | [InlineKeyboardButton( 30 | "Try", url="https://t.me/TGBotsCollectionbot")] 31 | ]) 32 | welcomed = f"Hey {message.from_user.first_name}\nThis is Multipurpose Bot that can perform many functions.\n\n/help for More info \n Bot Uptime : {bot_uptime}" 33 | await message.reply_text(welcomed, reply_markup=joinButton) 34 | raise StopPropagation 35 | -------------------------------------------------------------------------------- /plugins/unzip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import os 12 | import shutil 13 | import subprocess 14 | import time 15 | 16 | # the secret configuration specific things 17 | if bool(os.environ.get("WEBHOOK", False)): 18 | from sample_config import Config 19 | else: 20 | from config import Config 21 | 22 | # the Strings used for this "thing" 23 | from translation import Translation 24 | 25 | import pyrogram 26 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 27 | 28 | from helper_funcs.display_progress import progress_for_pyrogram, humanbytes 29 | 30 | 31 | @pyrogram.Client.on_message(pyrogram.filters.command(["unzip"])) 32 | async def unzip(bot, update): 33 | if update.from_user.id not in Config.AUTH_USERS: 34 | await bot.delete_messages( 35 | chat_id=update.chat.id, 36 | message_ids=update.message_id, 37 | revoke=True 38 | ) 39 | return 40 | saved_file_path = Config.DOWNLOAD_LOCATION + \ 41 | "/" + str(update.from_user.id) + ".unzip.zip" 42 | if os.path.exists(saved_file_path): 43 | os.remove(saved_file_path) 44 | reply_message = update.reply_to_message 45 | if ((reply_message is not None) and 46 | (reply_message.document is not None) and 47 | (reply_message.document.file_name.endswith(Translation.UNZIP_SUPPORTED_EXTENSIONS))): 48 | a = await bot.send_message( 49 | chat_id=update.chat.id, 50 | text=Translation.DOWNLOAD_START, 51 | reply_to_message_id=update.message_id 52 | ) 53 | c_time = time.time() 54 | try: 55 | await bot.download_media( 56 | message=reply_message, 57 | file_name=saved_file_path, 58 | progress=progress_for_pyrogram, 59 | progress_args=( 60 | Translation.DOWNLOAD_START, 61 | a, 62 | c_time 63 | ) 64 | ) 65 | except (ValueError) as e: 66 | await bot.edit_message_text( 67 | chat_id=update.chat.id, 68 | text=str(e), 69 | message_id=a.message_id 70 | ) 71 | else: 72 | await bot.edit_message_text( 73 | chat_id=update.chat.id, 74 | text=Translation.SAVED_RECVD_DOC_FILE, 75 | message_id=a.message_id 76 | ) 77 | extract_dir_path = Config.DOWNLOAD_LOCATION + \ 78 | "/" + str(update.from_user.id) + "zipped" + "/" 79 | if not os.path.isdir(extract_dir_path): 80 | os.makedirs(extract_dir_path) 81 | await bot.edit_message_text( 82 | chat_id=update.chat.id, 83 | text=Translation.EXTRACT_ZIP_INTRO_THREE, 84 | message_id=a.message_id 85 | ) 86 | try: 87 | command_to_exec = [ 88 | "7z", 89 | "e", 90 | "-o" + extract_dir_path, 91 | saved_file_path 92 | ] 93 | # https://stackoverflow.com/a/39629367/4723940 94 | logger.info(command_to_exec) 95 | t_response = subprocess.check_output( 96 | command_to_exec, stderr=subprocess.STDOUT) 97 | # https://stackoverflow.com/a/26178369/4723940 98 | except: 99 | try: 100 | os.remove(saved_file_path) 101 | shutil.rmtree(extract_dir_path) 102 | except: 103 | pass 104 | await bot.edit_message_text( 105 | chat_id=update.chat.id, 106 | text=Translation.EXTRACT_ZIP_ERRS_OCCURED, 107 | disable_web_page_preview=True, 108 | parse_mode="html", 109 | message_id=a.message_id 110 | ) 111 | else: 112 | os.remove(saved_file_path) 113 | inline_keyboard = [] 114 | zip_file_contents = os.listdir(extract_dir_path) 115 | i = 0 116 | for current_file in zip_file_contents: 117 | cb_string = "ZIP:{}:ZIP".format(str(i)) 118 | inline_keyboard.append([ 119 | InlineKeyboardButton( 120 | current_file, 121 | callback_data=cb_string.encode("UTF-8") 122 | ) 123 | ]) 124 | i = i + 1 125 | cb_string = "ZIP:{}:ZIP".format("ALL") 126 | inline_keyboard.append([ 127 | InlineKeyboardButton( 128 | "Upload All Files", 129 | callback_data=cb_string.encode("UTF-8") 130 | ) 131 | ]) 132 | cb_string = "ZIP:{}:ZIP".format("NONE") 133 | inline_keyboard.append([ 134 | InlineKeyboardButton( 135 | "Cancel", 136 | callback_data=cb_string.encode("UTF-8") 137 | ) 138 | ]) 139 | reply_markup = pyrogram.InlineKeyboardMarkup(inline_keyboard) 140 | await bot.edit_message_text( 141 | chat_id=update.chat.id, 142 | text=Translation.EXTRACT_ZIP_STEP_TWO, 143 | message_id=a.message_id, 144 | reply_markup=reply_markup, 145 | ) 146 | else: 147 | await bot.send_message( 148 | chat_id=update.chat.id, 149 | text=Translation.EXTRACT_ZIP_INTRO_ONE, 150 | reply_to_message_id=update.message_id 151 | ) 152 | -------------------------------------------------------------------------------- /plugins/youtube_dl_button.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import asyncio 12 | import json 13 | import math 14 | import os 15 | import shutil 16 | import time 17 | from datetime import datetime 18 | 19 | # the secret configuration specific things 20 | if bool(os.environ.get("WEBHOOK", False)): 21 | from sample_config import Config 22 | else: 23 | from config import Config 24 | 25 | # the Strings used for this "thing" 26 | from translation import Translation 27 | 28 | import pyrogram 29 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 30 | 31 | from helper_funcs.display_progress import progress_for_pyrogram, humanbytes 32 | from helper_funcs.help_uploadbot import DownLoadFile 33 | from hachoir.metadata import extractMetadata 34 | from hachoir.parser import createParser 35 | # https://stackoverflow.com/a/37631799/4723940 36 | from PIL import Image 37 | from helper_funcs.help_Nekmo_ffmpeg import generate_screen_shots 38 | from helper_funcs.ran_text import random_char 39 | 40 | 41 | async def youtube_dl_call_back(bot, update): 42 | cb_data = update.data 43 | 44 | # youtube_dl extractors 45 | tg_send_type, youtube_dl_format, youtube_dl_ext, ranom = cb_data.split("|") 46 | print(cb_data) 47 | random1 = random_char(5) 48 | thumb_image_path = Config.DOWNLOAD_LOCATION + \ 49 | "/" + str(update.from_user.id) + f'{ranom}' + ".jpg" 50 | save_ytdl_json_path = Config.DOWNLOAD_LOCATION + \ 51 | "/" + str(update.from_user.id) + f'{ranom}' + ".json" 52 | try: 53 | with open(save_ytdl_json_path, "r", encoding="utf8") as f: 54 | response_json = json.load(f) 55 | except (FileNotFoundError) as e: 56 | await bot.delete_messages( 57 | chat_id=update.message.chat.id, 58 | message_ids=update.message.message_id, 59 | revoke=True 60 | ) 61 | return False 62 | youtube_dl_url = update.message.reply_to_message.text 63 | custom_file_name = str(response_json.get("title")) + \ 64 | "_" + youtube_dl_format + "." + youtube_dl_ext 65 | youtube_dl_username = None 66 | youtube_dl_password = None 67 | if "|" in youtube_dl_url: 68 | url_parts = youtube_dl_url.split("|") 69 | if len(url_parts) == 2: 70 | youtube_dl_url = url_parts[0] 71 | custom_file_name = url_parts[1] 72 | elif len(url_parts) == 4: 73 | youtube_dl_url = url_parts[0] 74 | custom_file_name = url_parts[1] 75 | youtube_dl_username = url_parts[2] 76 | youtube_dl_password = url_parts[3] 77 | else: 78 | for entity in update.message.reply_to_message.entities: 79 | if entity.type == "text_link": 80 | youtube_dl_url = entity.url 81 | elif entity.type == "url": 82 | o = entity.offset 83 | l = entity.length 84 | youtube_dl_url = youtube_dl_url[o:o + l] 85 | if youtube_dl_url is not None: 86 | youtube_dl_url = youtube_dl_url.strip() 87 | if custom_file_name is not None: 88 | custom_file_name = custom_file_name.strip() 89 | # https://stackoverflow.com/a/761825/4723940 90 | if youtube_dl_username is not None: 91 | youtube_dl_username = youtube_dl_username.strip() 92 | if youtube_dl_password is not None: 93 | youtube_dl_password = youtube_dl_password.strip() 94 | logger.info(youtube_dl_url) 95 | logger.info(custom_file_name) 96 | else: 97 | for entity in update.message.reply_to_message.entities: 98 | if entity.type == "text_link": 99 | youtube_dl_url = entity.url 100 | elif entity.type == "url": 101 | o = entity.offset 102 | l = entity.length 103 | youtube_dl_url = youtube_dl_url[o:o + l] 104 | await bot.edit_message_text( 105 | text=Translation.DOWNLOAD_START, 106 | chat_id=update.message.chat.id, 107 | message_id=update.message.message_id 108 | ) 109 | description = Translation.CUSTOM_CAPTION_UL_FILE 110 | if "fulltitle" in response_json: 111 | description = response_json["fulltitle"][0:1021] 112 | # escape Markdown and special characters 113 | tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + f'{random1}' 114 | if not os.path.isdir(tmp_directory_for_each_user): 115 | os.makedirs(tmp_directory_for_each_user) 116 | download_directory = tmp_directory_for_each_user + "/" + custom_file_name 117 | command_to_exec = [] 118 | if tg_send_type == "audio": 119 | command_to_exec = [ 120 | "yt-dlp", 121 | "-c", 122 | "--max-filesize", str(Config.TG_MAX_FILE_SIZE), 123 | "--prefer-ffmpeg", 124 | "--extract-audio", 125 | "--audio-format", youtube_dl_ext, 126 | "--audio-quality", youtube_dl_format, 127 | youtube_dl_url, 128 | "-o", download_directory 129 | ] 130 | else: 131 | # command_to_exec = ["youtube-dl", "-f", youtube_dl_format, "--hls-prefer-ffmpeg", "--recode-video", "mp4", "-k", youtube_dl_url, "-o", download_directory] 132 | minus_f_format = youtube_dl_format 133 | if "youtu" in youtube_dl_url: 134 | minus_f_format = youtube_dl_format + "+bestaudio" 135 | command_to_exec = [ 136 | "yt-dlp", 137 | "-c", 138 | "--max-filesize", str(Config.TG_MAX_FILE_SIZE), 139 | "--embed-subs", 140 | "-f", minus_f_format, 141 | "--hls-prefer-ffmpeg", youtube_dl_url, 142 | "-o", download_directory 143 | ] 144 | if Config.HTTP_PROXY != "": 145 | command_to_exec.append("--proxy") 146 | command_to_exec.append(Config.HTTP_PROXY) 147 | if youtube_dl_username is not None: 148 | command_to_exec.append("--username") 149 | command_to_exec.append(youtube_dl_username) 150 | if youtube_dl_password is not None: 151 | command_to_exec.append("--password") 152 | command_to_exec.append(youtube_dl_password) 153 | command_to_exec.append("--no-warnings") 154 | # command_to_exec.append("--quiet") 155 | logger.info(command_to_exec) 156 | start = datetime.now() 157 | process = await asyncio.create_subprocess_exec( 158 | *command_to_exec, 159 | # stdout must a pipe to be accessible as process.stdout 160 | stdout=asyncio.subprocess.PIPE, 161 | stderr=asyncio.subprocess.PIPE, 162 | ) 163 | # Wait for the subprocess to finish 164 | stdout, stderr = await process.communicate() 165 | e_response = stderr.decode().strip() 166 | t_response = stdout.decode().strip() 167 | logger.info(e_response) 168 | logger.info(t_response) 169 | ad_string_to_replace = "please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output." 170 | if e_response and ad_string_to_replace in e_response: 171 | error_message = e_response.replace(ad_string_to_replace, "") 172 | await bot.edit_message_text( 173 | chat_id=update.message.chat.id, 174 | message_id=update.message.message_id, 175 | text=error_message 176 | ) 177 | return False 178 | 179 | if t_response: 180 | logger.info(t_response) 181 | try: 182 | os.remove(save_ytdl_json_path) 183 | except FileNotFoundError as exc: 184 | pass 185 | 186 | end_one = datetime.now() 187 | time_taken_for_download = (end_one -start).seconds 188 | file_size = Config.TG_MAX_FILE_SIZE + 1 189 | try: 190 | file_size = os.stat(download_directory).st_size 191 | except FileNotFoundError as exc: 192 | download_directory = os.path.splitext(download_directory)[0] + "." + "mkv" 193 | # https://stackoverflow.com/a/678242/4723940 194 | file_size = os.stat(download_directory).st_size 195 | try: 196 | if tg_send_type == 'video' and 'webm' in download_directory: 197 | ownload_directory = download_directory.rsplit('.', 1)[0] + '.mkv' 198 | os.rename(download_directory, ownload_directory) 199 | download_directory = ownload_directory 200 | except: 201 | pass 202 | 203 | if file_size > Config.TG_MAX_FILE_SIZE: 204 | await bot.edit_message_text( 205 | chat_id=update.message.chat.id, 206 | text=Translation.RCHD_TG_API_LIMIT.format(time_taken_for_download, humanbytes(file_size)), 207 | message_id=update.message.message_id 208 | ) 209 | else: 210 | is_w_f = False 211 | '''images = await generate_screen_shots( 212 | download_directory, 213 | tmp_directory_for_each_user, 214 | is_w_f, 215 | Config.DEF_WATER_MARK_FILE, 216 | 300, 217 | 9 218 | ) 219 | logger.info(images)''' 220 | await bot.edit_message_text( 221 | text=Translation.UPLOAD_START, 222 | chat_id=update.message.chat.id, 223 | message_id=update.message.message_id 224 | ) 225 | # get the correct width, height, and duration for videos greater than 10MB 226 | # ref: message from @BotSupport 227 | width = 0 228 | height = 0 229 | duration = 0 230 | if tg_send_type != "file": 231 | metadata = extractMetadata(createParser(download_directory)) 232 | if metadata is not None: 233 | if metadata.has("duration"): 234 | duration = metadata.get('duration').seconds 235 | # get the correct width, height, and duration for videos greater than 10MB 236 | if os.path.exists(thumb_image_path): 237 | width = 0 238 | height = 0 239 | metadata = extractMetadata(createParser(thumb_image_path)) 240 | if metadata.has("width"): 241 | width = metadata.get("width") 242 | if metadata.has("height"): 243 | height = metadata.get("height") 244 | if tg_send_type == "vm": 245 | height = width 246 | # resize image 247 | # ref: https://t.me/PyrogramChat/44663 248 | # https://stackoverflow.com/a/21669827/4723940 249 | Image.open(thumb_image_path).convert( 250 | "RGB").save(thumb_image_path) 251 | img = Image.open(thumb_image_path) 252 | # https://stackoverflow.com/a/37631799/4723940 253 | # img.thumbnail((90, 90)) 254 | if tg_send_type == "file": 255 | img.resize((320, height)) 256 | else: 257 | img.resize((90, height)) 258 | img.save(thumb_image_path, "JPEG") 259 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails 260 | 261 | else: 262 | thumb_image_path = None 263 | start_time = time.time() 264 | # try to upload file 265 | if tg_send_type == "audio": 266 | await bot.send_audio( 267 | chat_id=update.message.chat.id, 268 | audio=download_directory, 269 | caption=description, 270 | parse_mode="HTML", 271 | duration=duration, 272 | # performer=response_json["uploader"], 273 | # title=response_json["title"], 274 | # reply_markup=reply_markup, 275 | thumb=thumb_image_path, 276 | reply_to_message_id=update.message.reply_to_message.message_id, 277 | progress=progress_for_pyrogram, 278 | progress_args=( 279 | Translation.UPLOAD_START, 280 | update.message, 281 | start_time 282 | ) 283 | ) 284 | elif tg_send_type == "file": 285 | await bot.send_document( 286 | chat_id=update.message.chat.id, 287 | document=download_directory, 288 | thumb=thumb_image_path, 289 | caption=description, 290 | parse_mode="HTML", 291 | # reply_markup=reply_markup, 292 | reply_to_message_id=update.message.reply_to_message.message_id, 293 | progress=progress_for_pyrogram, 294 | progress_args=( 295 | Translation.UPLOAD_START, 296 | update.message, 297 | start_time 298 | ) 299 | ) 300 | elif tg_send_type == "vm": 301 | await bot.send_video_note( 302 | chat_id=update.message.chat.id, 303 | video_note=download_directory, 304 | duration=duration, 305 | length=width, 306 | thumb=thumb_image_path, 307 | reply_to_message_id=update.message.reply_to_message.message_id, 308 | progress=progress_for_pyrogram, 309 | progress_args=( 310 | Translation.UPLOAD_START, 311 | update.message, 312 | start_time 313 | ) 314 | ) 315 | elif tg_send_type == "video": 316 | await bot.send_video( 317 | chat_id=update.message.chat.id, 318 | video=download_directory, 319 | caption=description, 320 | parse_mode="HTML", 321 | duration=duration, 322 | width=width, 323 | height=height, 324 | supports_streaming=True, 325 | # reply_markup=reply_markup, 326 | thumb=thumb_image_path, 327 | reply_to_message_id=update.message.reply_to_message.message_id, 328 | progress=progress_for_pyrogram, 329 | progress_args=( 330 | Translation.UPLOAD_START, 331 | update.message, 332 | start_time 333 | ) 334 | ) 335 | else: 336 | logger.info("Did this happen? :\\") 337 | end_two = datetime.now() 338 | time_taken_for_upload = (end_two - end_one).seconds 339 | # 340 | '''media_album_p = [] 341 | if images is not None: 342 | i = 0 343 | caption = "JOIN : https://t.me/TGBotsCollection \n For the List of Telegram Bots" 344 | if is_w_f: 345 | caption = "/upgrade to Plan D to remove the watermark\nJOIN : https://t.me/TGBotsCollection \n For the List of Telegram Bots" 346 | for image in images: 347 | if os.path.exists(image): 348 | if i == 0: 349 | media_album_p.append( 350 | pyrogram.types.InputMediaPhoto( 351 | media=image, 352 | caption=caption, 353 | parse_mode="html" 354 | ) 355 | ) 356 | else: 357 | media_album_p.append( 358 | pyrogram.types.InputMediaPhoto( 359 | media=image 360 | ) 361 | ) 362 | i = i + 1 363 | await bot.send_media_group( 364 | chat_id=update.message.chat.id, 365 | disable_notification=True, 366 | reply_to_message_id=update.message.message_id, 367 | media=media_album_p 368 | )''' 369 | # 370 | try: 371 | os.remove(thumb_image_path) 372 | shutil.rmtree(tmp_directory_for_each_user) 373 | except: 374 | pass 375 | 376 | await bot.edit_message_text( 377 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(time_taken_for_download, time_taken_for_upload), 378 | chat_id=update.message.chat.id, 379 | message_id=update.message.message_id, 380 | disable_web_page_preview=True 381 | ) 382 | -------------------------------------------------------------------------------- /plugins/youtube_dl_echo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | # the logging things 6 | import logging 7 | logging.basicConfig(level=logging.DEBUG, 8 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 9 | logger = logging.getLogger(__name__) 10 | 11 | import asyncio 12 | import json 13 | import math 14 | import os 15 | import time 16 | from PIL import Image 17 | # the secret configuration specific things 18 | if bool(os.environ.get("WEBHOOK", False)): 19 | from sample_config import Config 20 | else: 21 | from config import Config 22 | 23 | # the Strings used for this "thing" 24 | from translation import Translation 25 | 26 | import pyrogram 27 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 28 | 29 | from helper_funcs.display_progress import humanbytes 30 | from helper_funcs.help_uploadbot import DownLoadFile 31 | from helper_funcs.ran_text import random_char 32 | 33 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton 34 | from pyrogram import filters 35 | from pyrogram.errors import UserNotParticipant, UserBannedInChannel 36 | 37 | @pyrogram.Client.on_message(filters.private & filters.regex(pattern=".*http.*")) 38 | async def echo(bot, update): 39 | if update.from_user.id in Config.BANNED_USERS: 40 | await update.reply_text("You are B A N N E D 🤣🤣🤣🤣") 41 | return 42 | update_channel = Config.UPDATE_CHANNEL 43 | if update_channel: 44 | try: 45 | user = await bot.get_chat_member(update_channel, update.chat.id) 46 | if user.status == "kicked": 47 | await update.reply_text("🤭 Sorry Dude, You are **B A N N E D 🤣🤣🤣**") 48 | return 49 | except UserNotParticipant: 50 | #await update.reply_text(f"Join @{update_channel} To Use Me") 51 | await update.reply_text( 52 | text="**Join My Updates Channel to use ME 😎 🤭**", 53 | reply_markup=InlineKeyboardMarkup([ 54 | [ InlineKeyboardButton(text="Join My Updates Channel", url=f"https://t.me/{update_channel}")] 55 | ]) 56 | ) 57 | return 58 | except Exception: 59 | await update.reply_text("Something Wrong. Contact my Support Group") 60 | return 61 | logger.info(update.from_user) 62 | url = update.text 63 | youtube_dl_username = None 64 | youtube_dl_password = None 65 | file_name = None 66 | print(url) 67 | if "|" in url: 68 | url_parts = url.split("|") 69 | if len(url_parts) == 2: 70 | url = url_parts[0] 71 | file_name = url_parts[1] 72 | elif len(url_parts) == 4: 73 | url = url_parts[0] 74 | file_name = url_parts[1] 75 | youtube_dl_username = url_parts[2] 76 | youtube_dl_password = url_parts[3] 77 | else: 78 | for entity in update.entities: 79 | if entity.type == "text_link": 80 | url = entity.url 81 | elif entity.type == "url": 82 | o = entity.offset 83 | l = entity.length 84 | url = url[o:o + l] 85 | if url is not None: 86 | url = url.strip() 87 | if file_name is not None: 88 | file_name = file_name.strip() 89 | # https://stackoverflow.com/a/761825/4723940 90 | if youtube_dl_username is not None: 91 | youtube_dl_username = youtube_dl_username.strip() 92 | if youtube_dl_password is not None: 93 | youtube_dl_password = youtube_dl_password.strip() 94 | logger.info(url) 95 | logger.info(file_name) 96 | else: 97 | for entity in update.entities: 98 | if entity.type == "text_link": 99 | url = entity.url 100 | elif entity.type == "url": 101 | o = entity.offset 102 | l = entity.length 103 | url = url[o:o + l] 104 | if Config.HTTP_PROXY != "": 105 | command_to_exec = [ 106 | "yt-dlp", 107 | "--no-warnings", 108 | "--youtube-skip-dash-manifest", 109 | "-j", 110 | url, 111 | "--proxy", Config.HTTP_PROXY 112 | ] 113 | else: 114 | command_to_exec = [ 115 | "yt-dlp", 116 | "--no-warnings", 117 | "--youtube-skip-dash-manifest", 118 | "-j", 119 | url 120 | ] 121 | if youtube_dl_username is not None: 122 | command_to_exec.append("--username") 123 | command_to_exec.append(youtube_dl_username) 124 | if youtube_dl_password is not None: 125 | command_to_exec.append("--password") 126 | command_to_exec.append(youtube_dl_password) 127 | logger.info(command_to_exec) 128 | chk = await bot.send_message( 129 | chat_id=update.chat.id, 130 | text=f'Checking your link...🧐', 131 | disable_web_page_preview=True, 132 | reply_to_message_id=update.message_id 133 | ) 134 | process = await asyncio.create_subprocess_exec( 135 | *command_to_exec, 136 | # stdout must a pipe to be accessible as process.stdout 137 | stdout=asyncio.subprocess.PIPE, 138 | stderr=asyncio.subprocess.PIPE, 139 | ) 140 | # Wait for the subprocess to finish 141 | stdout, stderr = await process.communicate() 142 | e_response = stderr.decode().strip() 143 | logger.info(e_response) 144 | t_response = stdout.decode().strip() 145 | #logger.info(t_response) 146 | # https://github.com/rg3/youtube-dl/issues/2630#issuecomment-38635239 147 | if e_response and "nonnumeric port" not in e_response: 148 | # logger.warn("Status : FAIL", exc.returncode, exc.output) 149 | error_message = e_response.replace("please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.", "") 150 | if "This video is only available for registered users." in error_message: 151 | error_message += Translation.SET_CUSTOM_USERNAME_PASSWORD 152 | await chk.delete() 153 | time.sleep(1) 154 | await bot.send_message( 155 | chat_id=update.chat.id, 156 | text=Translation.NO_VOID_FORMAT_FOUND.format(str(error_message)), 157 | reply_to_message_id=update.message_id, 158 | parse_mode="html", 159 | disable_web_page_preview=True 160 | ) 161 | return False 162 | if t_response: 163 | # logger.info(t_response) 164 | x_reponse = t_response 165 | if "\n" in x_reponse: 166 | x_reponse, _ = x_reponse.split("\n") 167 | response_json = json.loads(x_reponse) 168 | randem = random_char(5) 169 | save_ytdl_json_path = Config.DOWNLOAD_LOCATION + \ 170 | "/" + str(update.from_user.id) + f'{randem}' + ".json" 171 | with open(save_ytdl_json_path, "w", encoding="utf8") as outfile: 172 | json.dump(response_json, outfile, ensure_ascii=False) 173 | # logger.info(response_json) 174 | inline_keyboard = [] 175 | duration = None 176 | if "duration" in response_json: 177 | duration = response_json["duration"] 178 | if "formats" in response_json: 179 | for formats in response_json["formats"]: 180 | format_id = formats.get("format_id") 181 | format_string = formats.get("format_note") 182 | if format_string is None: 183 | format_string = formats.get("format") 184 | format_ext = formats.get("ext") 185 | approx_file_size = "" 186 | if "filesize" in formats: 187 | approx_file_size = humanbytes(formats["filesize"]) 188 | cb_string_video = "{}|{}|{}|{}".format( 189 | "video", format_id, format_ext, randem) 190 | cb_string_file = "{}|{}|{}|{}".format( 191 | "file", format_id, format_ext, randem) 192 | if format_string is not None and not "audio only" in format_string: 193 | ikeyboard = [ 194 | InlineKeyboardButton( 195 | "S " + format_string + " video " + approx_file_size + " ", 196 | callback_data=(cb_string_video).encode("UTF-8") 197 | ), 198 | InlineKeyboardButton( 199 | "D " + format_ext + " " + approx_file_size + " ", 200 | callback_data=(cb_string_file).encode("UTF-8") 201 | ) 202 | ] 203 | """if duration is not None: 204 | cb_string_video_message = "{}|{}|{}|{}|{}".format( 205 | "vm", format_id, format_ext, ran, randem) 206 | ikeyboard.append( 207 | InlineKeyboardButton( 208 | "VM", 209 | callback_data=( 210 | cb_string_video_message).encode("UTF-8") 211 | ) 212 | )""" 213 | else: 214 | # special weird case :\ 215 | ikeyboard = [ 216 | InlineKeyboardButton( 217 | "SVideo [" + 218 | "] ( " + 219 | approx_file_size + " )", 220 | callback_data=(cb_string_video).encode("UTF-8") 221 | ), 222 | InlineKeyboardButton( 223 | "DFile [" + 224 | "] ( " + 225 | approx_file_size + " )", 226 | callback_data=(cb_string_file).encode("UTF-8") 227 | ) 228 | ] 229 | inline_keyboard.append(ikeyboard) 230 | if duration is not None: 231 | cb_string_64 = "{}|{}|{}|{}".format("audio", "64k", "mp3", randem) 232 | cb_string_128 = "{}|{}|{}|{}".format("audio", "128k", "mp3", randem) 233 | cb_string = "{}|{}|{}|{}".format("audio", "320k", "mp3", randem) 234 | inline_keyboard.append([ 235 | InlineKeyboardButton( 236 | "MP3 " + "(" + "64 kbps" + ")", callback_data=cb_string_64.encode("UTF-8")), 237 | InlineKeyboardButton( 238 | "MP3 " + "(" + "128 kbps" + ")", callback_data=cb_string_128.encode("UTF-8")) 239 | ]) 240 | inline_keyboard.append([ 241 | InlineKeyboardButton( 242 | "MP3 " + "(" + "320 kbps" + ")", callback_data=cb_string.encode("UTF-8")) 243 | ]) 244 | else: 245 | format_id = response_json["format_id"] 246 | format_ext = response_json["ext"] 247 | cb_string_file = "{}|{}|{}|{}".format( 248 | "file", format_id, format_ext, randem) 249 | cb_string_video = "{}|{}|{}|{}".format( 250 | "video", format_id, format_ext, randem) 251 | inline_keyboard.append([ 252 | InlineKeyboardButton( 253 | "SVideo", 254 | callback_data=(cb_string_video).encode("UTF-8") 255 | ), 256 | InlineKeyboardButton( 257 | "DFile", 258 | callback_data=(cb_string_file).encode("UTF-8") 259 | ) 260 | ]) 261 | cb_string_file = "{}={}={}".format( 262 | "file", format_id, format_ext) 263 | cb_string_video = "{}={}={}".format( 264 | "video", format_id, format_ext) 265 | inline_keyboard.append([ 266 | InlineKeyboardButton( 267 | "video", 268 | callback_data=(cb_string_video).encode("UTF-8") 269 | ), 270 | InlineKeyboardButton( 271 | "file", 272 | callback_data=(cb_string_file).encode("UTF-8") 273 | ) 274 | ]) 275 | reply_markup = InlineKeyboardMarkup(inline_keyboard) 276 | # logger.info(reply_markup) 277 | thumbnail = Config.DEF_THUMB_NAIL_VID_S 278 | thumbnail_image = Config.DEF_THUMB_NAIL_VID_S 279 | if "thumbnail" in response_json: 280 | if response_json["thumbnail"] is not None: 281 | thumbnail = response_json["thumbnail"] 282 | thumbnail_image = response_json["thumbnail"] 283 | thumb_image_path = DownLoadFile( 284 | thumbnail_image, 285 | Config.DOWNLOAD_LOCATION + "/" + 286 | str(update.from_user.id) + f'{randem}' + ".webp", 287 | Config.CHUNK_SIZE, 288 | None, # bot, 289 | Translation.DOWNLOAD_START, 290 | update.message_id, 291 | update.chat.id 292 | ) 293 | if os.path.exists(thumb_image_path): 294 | im = Image.open(thumb_image_path).convert("RGB") 295 | im.save(thumb_image_path.replace(".webp", ".jpg"), "jpeg") 296 | else: 297 | thumb_image_path = None 298 | await chk.delete() 299 | time.sleep(1) 300 | await bot.send_message( 301 | chat_id=update.chat.id, 302 | text=Translation.FORMAT_SELECTION.format(thumbnail) + "\n" + Translation.SET_CUSTOM_USERNAME_PASSWORD, 303 | reply_markup=reply_markup, 304 | parse_mode="html", 305 | reply_to_message_id=update.message_id 306 | ) 307 | else: 308 | # fallback for nonnumeric port a.k.a seedbox.io 309 | inline_keyboard = [] 310 | cb_string_file = "{}={}={}".format( 311 | "file", "LFO", "NONE") 312 | cb_string_video = "{}={}={}".format( 313 | "video", "OFL", "ENON") 314 | inline_keyboard.append([ 315 | InlineKeyboardButton( 316 | "SVideo", 317 | callback_data=(cb_string_video).encode("UTF-8") 318 | ), 319 | InlineKeyboardButton( 320 | "DFile", 321 | callback_data=(cb_string_file).encode("UTF-8") 322 | ) 323 | ]) 324 | reply_markup = InlineKeyboardMarkup(inline_keyboard) 325 | await chk.delete() 326 | time.sleep(1) 327 | await bot.send_message( 328 | chat_id=update.chat.id, 329 | text=Translation.FORMAT_SELECTION.format(""), 330 | reply_markup=reply_markup, 331 | parse_mode="html", 332 | reply_to_message_id=update.message_id 333 | ) 334 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp 2 | beautifulsoup4 3 | hachoir 4 | numpy 5 | Pillow 6 | Pyrogram 7 | moviepy 8 | requests 9 | psutil 10 | tgcrypto 11 | #youtube-dl 12 | yt-dlp 13 | olefile 14 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.9.6 2 | -------------------------------------------------------------------------------- /sample_config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | class Config(object): 4 | # get a token from @BotFather 5 | TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "") 6 | # The Telegram API things 7 | APP_ID = int(os.environ.get("APP_ID", 12345)) 8 | API_HASH = os.environ.get("API_HASH") 9 | # Get these values from my.telegram.org 10 | # Array to store users who are authorized to use the bot 11 | AUTH_USERS = set(int(x) for x in os.environ.get("AUTH_USERS", "").split()) 12 | # Banned Unwanted Members.. 13 | BANNED_USERS = set(int(x) for x in os.environ.get("BANNED_USERS", "").split()) 14 | # the download location, where the HTTP Server runs 15 | DOWNLOAD_LOCATION = "./DOWNLOADS" 16 | # Update channel for Force Subscribe 17 | UPDATE_CHANNEL = os.environ.get("UPDATE_CHANNEL", "") 18 | # Telegram maximum file upload size 19 | MAX_FILE_SIZE = 50000000 20 | TG_MAX_FILE_SIZE = 2097152000 21 | FREE_USER_MAX_FILE_SIZE = 50000000 22 | # chunk size that should be used with requests 23 | CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", 128)) 24 | # default thumbnail to be used in the videos 25 | DEF_THUMB_NAIL_VID_S = os.environ.get("DEF_THUMB_NAIL_VID_S", "https://placehold.it/90x90") 26 | # proxy for accessing youtube-dl in GeoRestricted Areas 27 | # Get your own proxy from https://github.com/rg3/youtube-dl/issues/1091#issuecomment-230163061 28 | HTTP_PROXY = os.environ.get("HTTP_PROXY", "") 29 | # https://t.me/hevcbay/951 30 | OUO_IO_API_KEY = "" 31 | # maximum message length in Telegram 32 | MAX_MESSAGE_LENGTH = 4096 33 | # set timeout for subprocess 34 | PROCESS_MAX_TIMEOUT = 3600 35 | # watermark file 36 | DEF_WATER_MARK_FILE = "" 37 | -------------------------------------------------------------------------------- /translation.py: -------------------------------------------------------------------------------- 1 | class Translation(object): 2 | START_TEXT = """Hello {message.from_user.first_name}, 3 | This is a Telegram Multipurpose Bot Which can do many functions. 4 | 5 | /help for more details.. 6 | 7 | JOIN : https://t.me/TGBotsCollection \nFor the List of Telegram Bots 8 | """ 9 | IFLONG_FILE_NAME = " Only 64 characters can be named . " 10 | RENAME_403_ERR = "Sorry. You are not permitted to rename this file." 11 | ABS_TEXT = " Please don't be selfish." 12 | UPGRADE_TEXT = "No preminum plans available in this bot /help for Details" 13 | FORMAT_SELECTION = "Select the desired format: File size might be approximate \nIf you want to set custom thumbnail, send photo before or quickly after tapping on any of the below buttons.\nYou can use /deletethumbnail to delete the auto-generated thumbnail." 14 | SET_CUSTOM_USERNAME_PASSWORD = """If you want to download premium videos, provide in the following format: 15 | URL | filename | username | password""" 16 | NOYES_URL = "@robot URL detected. Please use https://shrtz.me/PtsVnf6 and get me a fast URL so that I can upload to Telegram, without me slowing down for other users." 17 | DOWNLOAD_FILE = " 📥DownloadinG📥 File " 18 | UPLOAD_FILE = " 📤UploadinG📤 \n\n To transfer.sh " 19 | ANNO_UPLOAD = " 📤UploadinG📤 \n\n To anonfiles.com " 20 | BAY_UPLOAD = " 📤UploadinG📤 \n\n To bayfiles.com " 21 | GO_FILE_UPLOAD = " 📤UploadinG📤 \n\n To gofile.io " 22 | DOWNLOAD_START = " 📥DownloadinG📥 \n\nWait⏳ untill it completed." 23 | UPLOAD_START = " 📤UploadinG📤 " 24 | RCHD_BOT_API_LIMIT = "size greater than maximum allowed size (50MB). Neverthless, trying to upload." 25 | RCHD_TG_API_LIMIT = "Downloaded in {} seconds.\nDetected File Size: {}\nSorry. But, I cannot upload files greater than 2GB due to Telegram API limitations." 26 | AFTER_SUCCESSFUL_UPLOAD_MSG = " JOIN : https://t.me/TGBotsCollection\nFor the List of Telegram Bots" 27 | AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Downloaded in {} seconds.\nJoin : https://t.me/TGBotsCollection\nUploaded in {} seconds." 28 | NOT_AUTH_USER_TEXT = "Please /upgrade your subscription." 29 | NOT_AUTH_USER_TEXT_FILE_SIZE = "Detected File Size: {}. Free Users can only upload: {}\nPlease /upgrade your subscription.\nIf you think this is a bug, please contact @SpEcHlDe" 30 | SAVED_CUSTOM_THUMB_NAIL = "Custom video / file thumbnail saved. This image will be used in the video / file." 31 | DEL_ETED_CUSTOM_THUMB_NAIL = "✅ Custom thumbnail cleared succesfully." 32 | FF_MPEG_DEL_ETED_CUSTOM_MEDIA = "✅ Media cleared succesfully." 33 | SAVED_RECVD_DOC_FILE = "Document Downloaded Successfully." 34 | CUSTOM_CAPTION_UL_FILE = " " 35 | NO_CUSTOM_THUMB_NAIL_FOUND = "No Custom ThumbNail found." 36 | NO_VOID_FORMAT_FOUND = "ERROR... {}" 37 | FILE_NOT_FOUND = "Error, File not Found!!" 38 | USER_ADDED_TO_DB = "User {} added to {} till {}." 39 | CURENT_PLAN_DETAILS = """About you... 40 | -------- 41 | Telegram ID : {} 42 | """ 43 | HELP_USER = """Hii I am Multipurpose bot and I can perform many tasks. 44 | 45 | 1.) Send url (Link|New Name with Extension). 46 | 2.) Send Custom Thumbnail (Optional). 47 | 3.) Select the button. 48 | SVideo - Give File as video with Screenshots 49 | DFile - Give File with Screenshots 50 | Video - Give File as video without Screenshots 51 | DFile - Give File without Screenshots 52 | 53 | JOIN : https://t.me/TGBotsCollection \n For the List of Telegram Bots""" 54 | REPLY_TO_DOC_GET_LINK = "Reply to a Telegram media to get High Speed Direct Download Link" 55 | REPLY_TO_DOC_FOR_C2V = "Reply to a Telegram media to convert" 56 | REPLY_TO_DOC_FOR_SCSS = "Reply to a Telegram media to get screenshots" 57 | REPLY_TO_DOC_FOR_RENAME_FILE = "Reply to a Telegram media to /ren with custom thumbnail support" 58 | AFTER_GET_LINK = " File Name : {}\nFile Size : {}\n\n⚡Link⚡ : {}\n\nJoin : @TGBotsCollection" 59 | AFTER_GET_DL_LINK = " File Name : {}\nFile Size : {}\n\n⚡Link⚡ : {}\n\nValid for 14 days.\nJoin : @TGBotsCollection" 60 | #AFTER_GET_DL_LINK = " {} valid for 30 or more days.\n\n Join : @TGBotsCollection \n For the list of Telegram bots. " 61 | AFTER_GET_GOFILE_LINK = " File Name : {}\nFile Size : {}\nFile MD5 Checksum : {}\n\n⚡Link⚡ : {}\n\n Valid untill 10 days of inactivity\nJoin : @TGBotsCollection" 62 | FF_MPEG_RO_BOT_RE_SURRECT_ED = """Syntax: /trim HH:MM:SS for screenshot of that specific time.""" 63 | FF_MPEG_RO_BOT_STEP_TWO_TO_ONE = "First send /downloadmedia to any media so that it can be downloaded to my local. \nSend /storageinfo to know the media, that is currently downloaded." 64 | FF_MPEG_RO_BOT_STOR_AGE_INFO = "Video Duration: {}\nSend /clearffmpegmedia to delete this media, from my storage.\nSend /trim HH:MM:SS [HH:MM:SS] to cu[l]t a small photo / video, from the above media." 65 | FF_MPEG_RO_BOT_STOR_AGE_ALREADY_EXISTS = "A saved media already exists. Please send /storageinfo to know the current media details." 66 | USER_DELETED_FROM_DB = "User {} deleted from DataBase." 67 | REPLY_TO_DOC_OR_LINK_FOR_RARX_SRT = "Reply to a Telegram media (MKV), to extract embedded streams" 68 | REPLY_TO_MEDIA_ALBUM_TO_GEN_THUMB = "Reply /generatecustomthumbnail to a media album, to generate custom thumbail" 69 | ERR_ONLY_TWO_MEDIA_IN_ALBUM = "Media Album should contain only two photos. Please re-send the media album, and then try again, or send only two photos in an album." 70 | INVALID_UPLOAD_BOT_URL_FORMAT = "URL format is incorrect. make sure your url starts with either http:// or https://. You can set custom file name using the format link | file_name.extension" 71 | ABUSIVE_USERS = "You are not allowed to use this bot. If you think this is a mistake, please check /me to remove this restriction." 72 | FF_MPEG_RO_BOT_AD_VER_TISE_MENT = "Join : @TGBotsCollectionbot \n For the list of Telegram bots. " 73 | EXTRACT_ZIP_INTRO_ONE = "Send a compressed file first, Then reply /unzip command to the file." 74 | EXTRACT_ZIP_INTRO_THREE = "Analyzing received file. ⚠️ This might take some time. Please be patient. " 75 | UNZIP_SUPPORTED_EXTENSIONS = ("zip", "rar") 76 | EXTRACT_ZIP_ERRS_OCCURED = "Sorry. Errors occurred while processing compressed file. Please check everything again twice, and if the issue persists, report this to @SpEcHlDe" 77 | EXTRACT_ZIP_STEP_TWO = """Select file_name to upload from the below options. 78 | You can use /rename command after receiving file to rename it with custom thumbnail support.""" 79 | CANCEL_STR = "Process Cancelled" 80 | ZIP_UPLOADED_STR = "Uploaded {} files in {} seconds" 81 | FREE_USER_LIMIT_Q_SZE = """Cannot Process. 82 | Free users only 1 request per 30 minutes. 83 | /upgrade or Try 1800 seconds later.""" 84 | SLOW_URL_DECED = "Gosh that seems to be a very slow URL. Since you were screwing my home, I am in no mood to download this file. Meanwhile, why don't you try this:==> https://shrtz.me/PtsVnf6 and get me a fast URL so that I can upload to Telegram, without me slowing down for other users." 85 | --------------------------------------------------------------------------------