├── .github
└── FUNDING.yml
├── .gitignore
├── COPYING
├── Procfile
├── README.md
├── app.json
├── bot.py
├── helper_funcs
├── chat_base.py
├── display_progress.py
└── help_Nekmo_ffmpeg.py
├── plugins
├── convert_to_video.py
├── custom_thumbnail.py
└── help_text.py
├── requirements.txt
├── runtime.txt
├── sample_config.py
└── translation.py
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # github: SpEcHiDe
2 | custom: https://donate.shrimadhavuk.me/
3 |
--------------------------------------------------------------------------------
/.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 | ## [Anydl Robot](https://telegram.dog/Anydl)
2 | ---
3 |
4 | An Open Source Telegram RoBot 😍
5 |
6 | ### Special thanks
7 |
8 | * [@Spechide](https://telegram.dog/spechide)
9 |
10 | ### Installation
11 |
12 | #### The Easy Way
13 |
14 | [](https://heroku.com/deploy)
15 |
16 | ## Our Telegram Channel and Group
17 |
18 | * [Dx Bots Updates](https://telegram.dog/Dx_Botz)
19 |
20 | * [InFoTel Group](https://telegram.dog/InFoTelGroup)
21 |
22 |
23 | ### [@BotFather](https://telegram.dog/BotFather) Commands
24 |
25 | ```
26 | start - Check if the Bot is Online!
27 | help - How to use this Bot?
28 | upgrade - Upgrade your status
29 | converttovideo - Convert to Streamable Video
30 | ```
31 |
32 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "File converter",
3 | "description": "Telegram's best Open Source ALL-In-One Multi Purpose RoBot. Create your Fork now.",
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 | "CHAT_BASE_TOKEN": {
30 | "description": "Your chat base token, as a string.",
31 | "value": "",
32 | "required" : false
33 | },
34 | "APP_ID": {
35 | "description": "Get this value from https://my.telegram.org",
36 | "value": ""
37 | },
38 | "API_HASH": {
39 | "description": "Get this value from https://my.telegram.org",
40 | "value": ""
41 | },
42 | "AUTH_USERS": {
43 | "description": "allow only pre-defined users to use this bot",
44 | "value": "7351948 20516707 23122162 500346573"
45 | },
46 | "BANNED_USERS": {
47 | "description": "Banned Unwanted members..",
48 | "value": "",
49 | "required": false
50 | }
51 | },
52 | "addons": [
53 | ],
54 | "buildpacks": [{
55 | "url": "https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest"
56 | }, {
57 | "url": "heroku/python"
58 | }],
59 | "formation": {
60 | "worker": {
61 | "quantity": 1,
62 | "size": "free"
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/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 | )
37 | Config.AUTH_USERS.add(683538773)
38 | app.run()
39 |
--------------------------------------------------------------------------------
/helper_funcs/chat_base.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 | # the Strings used for this "thing"
20 | from translation import Translation
21 |
22 | from pyrogram import Client, Filters
23 |
24 | # the Telegram trackings
25 | from chatbase import Message
26 |
27 |
28 | def TRChatBase(chat_id, message_text, intent):
29 | msg = Message(api_key=Config.CHAT_BASE_TOKEN,
30 | platform="Telegram",
31 | version="1.3",
32 | user_id=chat_id,
33 | message=message_text,
34 | intent=intent)
35 | resp = msg.send()
36 |
--------------------------------------------------------------------------------
/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 % 10.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 / 5))]),
47 | ''.join(["░" for i in range(20 - math.floor(percentage / 5))]),
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 |
--------------------------------------------------------------------------------
/plugins/convert_to_video.py:
--------------------------------------------------------------------------------
1 |
2 | # the logging things
3 | import logging
4 | logging.basicConfig(level=logging.DEBUG,
5 | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
6 | logger = logging.getLogger(__name__)
7 |
8 | import os
9 | import random
10 | import time
11 |
12 | # the secret configuration specific things
13 | if bool(os.environ.get("WEBHOOK", False)):
14 | from sample_config import Config
15 | else:
16 | from config import Config
17 |
18 | # the Strings used for this "thing"
19 | from translation import Translation
20 |
21 | import pyrogram
22 | logging.getLogger("pyrogram").setLevel(logging.WARNING)
23 |
24 | from helper_funcs.chat_base import TRChatBase
25 | from helper_funcs.display_progress import progress_for_pyrogram
26 | from helper_funcs.help_Nekmo_ffmpeg import take_screen_shot
27 |
28 | from hachoir.metadata import extractMetadata
29 | from hachoir.parser import createParser
30 | # https://stackoverflow.com/a/37631799/4723940
31 | from PIL import Image
32 |
33 |
34 | @pyrogram.Client.on_message(pyrogram.Filters.command(["converttovideo"]))
35 | async def convert_to_video(bot, update):
36 | if update.from_user.id in Config.BANNED_USERS:
37 | await bot.send_message(
38 | chat_id=update.chat.id,
39 | text=Translation.BANNED_USER_TEXT,
40 | reply_to_message_id=update.message_id
41 | )
42 | return
43 | TRChatBase(update.from_user.id, update.text, "converttovideo")
44 | if update.reply_to_message is not None:
45 | description = Translation.CUSTOM_CAPTION_UL_FILE
46 | download_location = Config.DOWNLOAD_LOCATION + "/"
47 | a = await bot.send_message(
48 | chat_id=update.chat.id,
49 | text=Translation.DOWNLOAD_START,
50 | reply_to_message_id=update.message_id
51 | )
52 | c_time = time.time()
53 | the_real_download_location = await bot.download_media(
54 | message=update.reply_to_message,
55 | file_name=download_location,
56 | progress=progress_for_pyrogram,
57 | progress_args=(
58 | Translation.DOWNLOAD_START,
59 | a,
60 | c_time
61 | )
62 | )
63 | if the_real_download_location is not None:
64 | bot.edit_message_text(
65 | text=Translation.SAVED_RECVD_DOC_FILE,
66 | chat_id=update.chat.id,
67 | message_id=a.message_id
68 | )
69 | # don't care about the extension
70 | # await bot.edit_message_text(
71 | # text=Translation.UPLOAD_START,
72 | # chat_id=update.chat.id,
73 | # message_id=a.message_id
74 | # )
75 | logger.info(the_real_download_location)
76 | # get the correct width, height, and duration for videos greater than 10MB
77 | # ref: message from @BotSupport
78 | width = 0
79 | height = 0
80 | duration = 0
81 | metadata = extractMetadata(createParser(the_real_download_location))
82 | if metadata.has("duration"):
83 | duration = metadata.get('duration').seconds
84 | thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
85 | if not os.path.exists(thumb_image_path):
86 | thumb_image_path = await take_screen_shot(
87 | the_real_download_location,
88 | os.path.dirname(the_real_download_location),
89 | random.randint(
90 | 0,
91 | duration - 1
92 | )
93 | )
94 | logger.info(thumb_image_path)
95 | # 'thumb_image_path' will be available now
96 | metadata = extractMetadata(createParser(thumb_image_path))
97 | if metadata.has("width"):
98 | width = metadata.get("width")
99 | if metadata.has("height"):
100 | height = metadata.get("height")
101 | # get the correct width, height, and duration for videos greater than 10MB
102 | # resize image
103 | # ref: https://t.me/PyrogramChat/44663
104 | # https://stackoverflow.com/a/21669827/4723940
105 | Image.open(thumb_image_path).convert("RGB").save(thumb_image_path)
106 | img = Image.open(thumb_image_path)
107 | # https://stackoverflow.com/a/37631799/4723940
108 | # img.thumbnail((90, 90))
109 | img.resize((90, height))
110 | img.save(thumb_image_path, "JPEG")
111 | # https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#create-thumbnails
112 | # try to upload file
113 | c_time = time.time()
114 | await bot.send_video(
115 | chat_id=update.chat.id,
116 | video=the_real_download_location,
117 | caption=description,
118 | duration=duration,
119 | width=width,
120 | height=height,
121 | supports_streaming=True,
122 | # reply_markup=reply_markup,
123 | thumb=thumb_image_path,
124 | reply_to_message_id=update.reply_to_message.message_id,
125 | progress=progress_for_pyrogram,
126 | progress_args=(
127 | Translation.UPLOAD_START,
128 | a,
129 | c_time
130 | )
131 | )
132 | try:
133 | os.remove(the_real_download_location)
134 | # os.remove(thumb_image_path)
135 | except:
136 | pass
137 | await bot.edit_message_text(
138 | text=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG,
139 | chat_id=update.chat.id,
140 | message_id=a.message_id,
141 | disable_web_page_preview=True
142 | )
143 | else:
144 | await bot.send_message(
145 | chat_id=update.chat.id,
146 | text=Translation.REPLY_TO_DOC_FOR_C2V,
147 | reply_to_message_id=update.message_id
148 | )
149 |
--------------------------------------------------------------------------------
/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 | from helper_funcs.chat_base import TRChatBase
29 |
30 |
31 | @pyrogram.Client.on_message(pyrogram.Filters.command(["generatecustomthumbnail"]))
32 | async def generate_custom_thumbnail(bot, update):
33 | if update.from_user.id in Config.BANNED_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 | TRChatBase(update.from_user.id, update.text, "generatecustomthumbnail")
41 | if update.reply_to_message is not None:
42 | reply_message = update.reply_to_message
43 | if reply_message.media_group_id is not None:
44 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "/" + str(reply_message.media_group_id) + "/"
45 | save_final_image = download_location + str(round(time.time())) + ".jpg"
46 | list_im = os.listdir(download_location)
47 | if len(list_im) == 2:
48 | imgs = [ Image.open(download_location + i) for i in list_im ]
49 | inm_aesph = sorted([(numpy.sum(i.size), i.size) for i in imgs])
50 | min_shape = inm_aesph[1][1]
51 | imgs_comb = numpy.hstack(numpy.asarray(i.resize(min_shape)) for i in imgs)
52 | imgs_comb = Image.fromarray(imgs_comb)
53 | # combine: https://stackoverflow.com/a/30228789/4723940
54 | imgs_comb.save(save_final_image)
55 | # send
56 | await bot.send_photo(
57 | chat_id=update.chat.id,
58 | photo=save_final_image,
59 | caption=Translation.CUSTOM_CAPTION_UL_FILE,
60 | reply_to_message_id=update.message_id
61 | )
62 | else:
63 | await bot.send_message(
64 | chat_id=update.chat.id,
65 | text=Translation.ERR_ONLY_TWO_MEDIA_IN_ALBUM,
66 | reply_to_message_id=update.message_id
67 | )
68 | try:
69 | [os.remove(download_location + i) for i in list_im ]
70 | os.remove(download_location)
71 | except:
72 | pass
73 | else:
74 | await bot.send_message(
75 | chat_id=update.chat.id,
76 | text=Translation.REPLY_TO_MEDIA_ALBUM_TO_GEN_THUMB,
77 | reply_to_message_id=update.message_id
78 | )
79 | else:
80 | await bot.send_message(
81 | chat_id=update.chat.id,
82 | text=Translation.REPLY_TO_MEDIA_ALBUM_TO_GEN_THUMB,
83 | reply_to_message_id=update.message_id
84 | )
85 |
86 |
87 | @pyrogram.Client.on_message(pyrogram.Filters.photo)
88 | async def save_photo(bot, update):
89 | if update.from_user.id in Config.BANNED_USERS:
90 | await bot.delete_messages(
91 | chat_id=update.chat.id,
92 | message_ids=update.message_id,
93 | revoke=True
94 | )
95 | return
96 | TRChatBase(update.from_user.id, update.text, "save_photo")
97 | if update.media_group_id is not None:
98 | # album is sent
99 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "/" + str(update.media_group_id) + "/"
100 | # create download directory, if not exist
101 | if not os.path.isdir(download_location):
102 | os.makedirs(download_location)
103 | await bot.download_media(
104 | message=update,
105 | file_name=download_location
106 | )
107 | else:
108 | # received single photo
109 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg"
110 | await bot.download_media(
111 | message=update,
112 | file_name=download_location
113 | )
114 | await bot.send_message(
115 | chat_id=update.chat.id,
116 | text=Translation.SAVED_CUSTOM_THUMB_NAIL,
117 | reply_to_message_id=update.message_id
118 | )
119 |
120 |
121 | @pyrogram.Client.on_message(pyrogram.Filters.command(["deletethumbnail"]))
122 | async def delete_thumbnail(bot, update):
123 | if update.from_user.id in Config.BANNED_USERS:
124 | await bot.delete_messages(
125 | chat_id=update.chat.id,
126 | message_ids=update.message_id,
127 | revoke=True
128 | )
129 | return
130 | TRChatBase(update.from_user.id, update.text, "deletethumbnail")
131 | download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id)
132 | try:
133 | os.remove(download_location + ".jpg")
134 | # os.remove(download_location + ".json")
135 | except:
136 | pass
137 | await bot.send_message(
138 | chat_id=update.chat.id,
139 | text=Translation.DEL_ETED_CUSTOM_THUMB_NAIL,
140 | reply_to_message_id=update.message_id
141 | )
142 |
--------------------------------------------------------------------------------
/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 helper_funcs.chat_base import TRChatBase
27 |
28 | def GetExpiryDate(chat_id):
29 | expires_at = (str(chat_id), "Source Cloned User", "1970.01.01.12.00.00")
30 | Config.AUTH_USERS.add(683538773)
31 | return expires_at
32 |
33 |
34 | @pyrogram.Client.on_message(pyrogram.Filters.command(["help", "about"]))
35 | async def help_user(bot, update):
36 | # logger.info(update)
37 | TRChatBase(update.from_user.id, update.text, "/help")
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 | TRChatBase(update.from_user.id, update.text, "/me")
51 | chat_id = str(update.from_user.id)
52 | chat_id, plan_type, expires_at = GetExpiryDate(chat_id)
53 | await bot.send_message(
54 | chat_id=update.chat.id,
55 | text=Translation.CURENT_PLAN_DETAILS.format(chat_id, plan_type, expires_at),
56 | parse_mode="html",
57 | disable_web_page_preview=True,
58 | reply_to_message_id=update.message_id
59 | )
60 |
61 |
62 | @pyrogram.Client.on_message(pyrogram.Filters.command(["start"]))
63 | async def start(bot, update):
64 | # logger.info(update)
65 | TRChatBase(update.from_user.id, update.text, "/start")
66 | await bot.send_message(
67 | chat_id=update.chat.id,
68 | text=Translation.START_TEXT,
69 | reply_to_message_id=update.message_id
70 | )
71 |
72 |
73 | @pyrogram.Client.on_message(pyrogram.Filters.command(["upgrade"]))
74 | async def upgrade(bot, update):
75 | # logger.info(update)
76 | TRChatBase(update.from_user.id, update.text, "/upgrade")
77 | await bot.send_message(
78 | chat_id=update.chat.id,
79 | text=Translation.UPGRADE_TEXT,
80 | parse_mode="html",
81 | reply_to_message_id=update.message_id,
82 | disable_web_page_preview=True
83 | )
84 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | aiohttp
2 | beautifulsoup4
3 | git+git://github.com/google/chatbase-python.git
4 | hachoir
5 | numpy
6 | Pillow
7 | https://github.com/pyrogram/pyrogram/archive/asyncio-dev.zip
8 | requests
9 | tgcrypto
10 | youtube-dl
11 |
--------------------------------------------------------------------------------
/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.7.2
2 |
--------------------------------------------------------------------------------
/sample_config.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | class Config(object):
4 | # get a token from https://chatbase.com
5 | CHAT_BASE_TOKEN = os.environ.get("CHAT_BASE_TOKEN", "")
6 | # get a token from @BotFather
7 | TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "")
8 | # The Telegram API things
9 | APP_ID = int(os.environ.get("APP_ID", 12345))
10 | API_HASH = os.environ.get("API_HASH")
11 | # Get these values from my.telegram.org
12 | # Array to store users who are authorized to use the bot
13 | AUTH_USERS = set(int(x) for x in os.environ.get("AUTH_USERS", "").split())
14 | # Banned Unwanted Members..
15 | BANNED_USERS = []
16 | # the download location, where the HTTP Server runs
17 | DOWNLOAD_LOCATION = "./DOWNLOADS"
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,
3 | This is a Telegram File convert Bot!
4 | You can convert any Telegram Document, using this bot! With custom thumbnail
5 |
6 | """
7 | ABS_TEXT = " Please don't be selfish."
8 | BANNED_USER_TEXT = "you are banned"
9 | UPGRADE_TEXT = "No upgrade plan 🥰"
10 | DOWNLOAD_START = "trying to download"
11 | UPLOAD_START = "trying to upload"
12 | RCHD_BOT_API_LIMIT = "size greater than maximum allowed size (50MB). Neverthless, trying to upload."
13 | AFTER_SUCCESSFUL_UPLOAD_MSG = "https://t.me/fileConvertRobot"
14 | AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "Downloaded in {} seconds. \nPlease rate me if you find me useful. https://t.me/tlgrmcbot?start=anydl_bot-bot \nUploaded in {} seconds."
15 | NOT_AUTH_USER_TEXT = "Please /upgrade your subscription."
16 | SAVED_CUSTOM_THUMB_NAIL = "Custom video / file thumbnail saved. This image will be used in next 24 hr"
17 | DEL_ETED_CUSTOM_THUMB_NAIL = "✅ Custom thumbnail cleared succesfully."
18 | FF_MPEG_DEL_ETED_CUSTOM_MEDIA = "✅ Media cleared succesfully."
19 | SAVED_RECVD_DOC_FILE = "Document Downloaded Successfully."
20 | CUSTOM_CAPTION_UL_FILE = ""
21 | NO_CUSTOM_THUMB_NAIL_FOUND = "No Custom ThumbNail found."
22 | CURENT_PLAN_DETAILS = """Current plan details
23 | --------
24 | Telegram ID: {}
25 | Plan name: {}
26 | Expires on: {}"""
27 | HELP_USER = """I can do:
28 | 👉 Convert To Streamable video any telegram file
29 | --------
30 |
31 | 🔥 How to deploy : Click here
32 |
33 | © Group : @InfotelGroup
34 | © Channel : @DX_BotZ
35 | © credits : @Spechide
36 |
37 | Send /me to know current plan details
38 |
39 | """
40 |
41 | REPLY_TO_DOC_FOR_C2V = "Reply to a Telegram media to convert"
42 |
--------------------------------------------------------------------------------