JamesBond531 commited on
Commit
e7f5d94
1 Parent(s): b84f6aa

First Commit to Add Files

Browse files
.gitignore ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Personal files
2
+ *.session
3
+ *.session-journal
4
+ .vscode
5
+ *test*.py
6
+ setup.cfg
7
+
8
+ # Byte-compiled / optimized / DLL files
9
+ __pycache__/
10
+ *.py[cod]
11
+ *$py.class
12
+
13
+ # C extensions
14
+ *.so
15
+
16
+ # Distribution / packaging
17
+ .Python
18
+ build/
19
+ develop-eggs/
20
+ dist/
21
+ downloads/
22
+ eggs/
23
+ .eggs/
24
+ lib/
25
+ lib64/
26
+ parts/
27
+ sdist/
28
+ var/
29
+ wheels/
30
+ share/python-wheels/
31
+ *.egg-info/
32
+ .installed.cfg
33
+ *.egg
34
+ MANIFEST
35
+
36
+ # PyInstaller
37
+ # Usually these files are written by a python script from a template
38
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
39
+ *.manifest
40
+ *.spec
41
+
42
+ # Installer logs
43
+ pip-log.txt
44
+ pip-delete-this-directory.txt
45
+
46
+ # Unit test / coverage reports
47
+ htmlcov/
48
+ .tox/
49
+ .nox/
50
+ .coverage
51
+ .coverage.*
52
+ .cache
53
+ nosetests.xml
54
+ coverage.xml
55
+ *.cover
56
+ *.py,cover
57
+ .hypothesis/
58
+ .pytest_cache/
59
+ cover/
60
+
61
+ # Translations
62
+ *.mo
63
+ *.pot
64
+
65
+ # Django stuff:
66
+ *.log
67
+ local_settings.py
68
+ db.sqlite3
69
+ db.sqlite3-journal
70
+
71
+ # Flask stuff:
72
+ instance/
73
+ .webassets-cache
74
+
75
+ # Scrapy stuff:
76
+ .scrapy
77
+
78
+ # Sphinx documentation
79
+ docs/_build/
80
+
81
+ # PyBuilder
82
+ .pybuilder/
83
+ target/
84
+
85
+ # Jupyter Notebook
86
+ .ipynb_checkpoints
87
+
88
+ # IPython
89
+ profile_default/
90
+ ipython_config.py
91
+
92
+ # pyenv
93
+ # For a library or package, you might want to ignore these files since the code is
94
+ # intended to run in multiple environments; otherwise, check them in:
95
+ # .python-version
96
+
97
+ # pipenv
98
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
99
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
100
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
101
+ # install all needed dependencies.
102
+ #Pipfile.lock
103
+
104
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
105
+ __pypackages__/
106
+
107
+ # Celery stuff
108
+ celerybeat-schedule
109
+ celerybeat.pid
110
+
111
+ # SageMath parsed files
112
+ *.sage.py
113
+
114
+ # Environments
115
+ .env
116
+ .venv
117
+ env/
118
+ venv/
119
+ ENV/
120
+ env.bak/
121
+ venv.bak/
122
+
123
+ # Spyder project settings
124
+ .spyderproject
125
+ .spyproject
126
+
127
+ # Rope project settings
128
+ .ropeproject
129
+
130
+ # mkdocs documentation
131
+ /site
132
+
133
+ # mypy
134
+ .mypy_cache/
135
+ .dmypy.json
136
+ dmypy.json
137
+
138
+ # Pyre type checker
139
+ .pyre/
140
+
141
+ # pytype static type analyzer
142
+ .pytype/
143
+
144
+ # Cython debug symbols
145
+ cython_debug/
146
+ config.py
147
+ .goutputstream-VAFWB1
148
+ result.json
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10.8-slim-buster
2
+
3
+ RUN apt update && apt upgrade -y
4
+ RUN apt install git -y
5
+ COPY requirements.txt /requirements.txt
6
+
7
+ RUN cd /
8
+ RUN pip3 install -U pip && pip3 install -U -r requirements.txt
9
+ RUN mkdir /ben-url-filter-bot
10
+ WORKDIR /ben-url-filter-bot
11
+ COPY start.sh /start.sh
12
+ CMD ["/bin/bash", "/start.sh"]
LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: python3 bot.py
README.md CHANGED
@@ -1,10 +1,130 @@
1
- ---
2
- title: Benfilterbot
3
- emoji: 📈
4
- colorFrom: pink
5
- colorTo: blue
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="https://telegra.ph/file/7f5f7906440c8eaa5afc6.jpg" alt="Ben-filter-Bot Logo">
3
+ </p>
4
+ <h1 align="center">
5
+ BEN-FILTER-BOT
6
+ </h1>
7
+
8
+ ![Typing SVG](https://readme-typing-svg.herokuapp.com/?lines=𝑊𝑒𝑙𝑐𝑜𝑚𝑒+𝑇𝑜+TT-Bot;𝐴+𝑠𝑖𝑚𝑝𝑙𝑒+𝑎𝑛𝑑+𝑝𝑜𝑤𝑒𝑟𝑓𝑢𝑙+𝐵𝑜𝑡!;𝐼𝑛𝑑𝑒𝑥𝑒𝑠+𝐹𝑖𝑙𝑒𝑠+𝑎𝑏𝑜𝑣𝑒+2𝐺𝐵;𝐴+𝐵𝑜𝑡+𝑤𝑖𝑡ℎ+𝑑𝑜𝑢𝑏𝑙𝑒+𝑏𝑢𝑡𝑡𝑜𝑛!;𝑆𝑡𝑎𝑟𝑡+𝑚𝑒𝑠𝑠𝑎𝑔𝑒+𝑤𝑖𝑡ℎ+𝑝𝑖𝑐!;𝐴𝑛𝑑+𝑚𝑜𝑟𝑒+𝑓𝑒𝑎𝑡𝑢𝑟𝑒𝑠!)
9
+ </p>
10
+
11
+ ## 𝐹𝑒𝑎𝑡𝑢𝑟𝑒𝑠
12
+ - [x] 𝐼𝑀𝐷𝐵 𝑇𝑒𝑚𝑝𝑙𝑎𝑡𝑒 𝑆𝑒𝑡
13
+ - [x] 𝐼𝑛𝑑𝑒𝑥𝑒𝑠 𝐹𝑖𝑙𝑒𝑠 𝑎𝑏𝑜𝑣𝑒 2𝐺𝐵
14
+ - [x] 𝑃𝑟𝑒𝐷𝑉𝐷 𝑎𝑛𝑑 𝐶𝑎𝑚𝑅𝑖𝑝 𝐷𝑒𝑙𝑒𝑡𝑒 𝑀𝑜𝑑𝑒
15
+ - [x] 𝑀𝑢𝑙𝑡𝑖𝑝𝑙𝑒 𝐹𝑖𝑙𝑒 𝐷𝑒𝑙𝑒𝑡𝑖𝑜𝑛
16
+ - [x] 𝑆𝑒𝑡𝑡𝑖𝑛𝑔𝑠 𝑀𝑒𝑛𝑢
17
+ - [x] 𝐹𝑜𝑟𝑐𝑒 𝑆𝑢𝑏𝑠𝑐𝑟𝑖𝑝𝑡𝑖𝑜𝑛
18
+ - [x] 𝑊𝑒𝑙𝑐𝑜𝑚𝑒 𝑀𝑒𝑠𝑠𝑎𝑔𝑒
19
+ - [x] 𝐴𝑢𝑡𝑜𝑚𝑎𝑡𝑖𝑐 𝐹𝑖𝑙𝑒 𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑛𝑔
20
+ - [x] 𝐷𝑜𝑢𝑏𝑙𝑒 𝐹𝑖𝑙𝑡𝑒𝑟 𝐵𝑢𝑡𝑡𝑜𝑛
21
+ - [x] 𝑆𝑖𝑛𝑔𝑙𝑒 𝐹𝑖𝑙𝑡𝑒𝑟 𝐵𝑢𝑡𝑡𝑜𝑛
22
+ - [x] 𝐵𝑜𝑡 𝑃𝑀 𝐹𝑖𝑙𝑒 𝑆𝑒𝑛𝑑 𝑀𝑜𝑑𝑒
23
+ - [x] 𝐴𝑢𝑡𝑜 𝐹𝑖𝑙𝑒 𝑆𝑒𝑛𝑑
24
+ - [x] 𝐹𝑜𝑟𝑤𝑎𝑟𝑑 𝑅𝑒𝑠𝑡𝑟𝑖𝑐𝑡𝑖𝑜𝑛
25
+ - [x] 𝐹𝑖𝑙𝑒 𝑃𝑟𝑜𝑡𝑒𝑐𝑡
26
+ - [x] 𝑀𝑎𝑛𝑢𝑎𝑙 𝐹𝑖𝑙𝑒 𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑛𝑔
27
+ - [x] 𝐺𝑙𝑜𝑏𝑎𝑙 𝐹𝑖𝑙𝑒 𝐹𝑖𝑙𝑡𝑒𝑟𝑖𝑛𝑔
28
+ - [x] 𝐼𝑀𝐷𝐵
29
+ - [x] 𝐴𝑑𝑚𝑖𝑛 𝐶𝑜𝑚𝑚𝑎𝑛𝑑𝑠
30
+ - [x] 𝑈𝑠𝑒𝑟 𝐵𝑟𝑜𝑎𝑑𝑐𝑎𝑠𝑡
31
+ - [x] 𝐺𝑟𝑜𝑢𝑝 𝐵𝑟𝑜𝑎𝑑𝑐𝑎𝑠𝑡
32
+ - [x] 𝐼𝑛𝑑𝑒𝑥
33
+ - [x] 𝐼𝑀𝐷𝐵 𝑠𝑒𝑎𝑟𝑐ℎ
34
+ - [x] 𝐼𝑛𝑙𝑖𝑛𝑒 𝑆𝑒𝑎𝑟𝑐ℎ
35
+ - [x] 𝑅𝑎𝑛𝑑𝑜𝑚 𝑝𝑖𝑐𝑠
36
+ - [x] 𝑖𝑑𝑠 𝑎𝑛𝑑 𝑈𝑠𝑒𝑟 𝑖𝑛𝑓𝑜
37
+ - [x] 𝑆𝑡𝑎𝑡𝑠
38
+ - [x] 𝑈𝑠𝑒𝑟𝑠
39
+ - [x] 𝐶ℎ𝑎𝑡𝑠
40
+ - [x] 𝑈𝑠𝑒𝑟 𝐵𝑎𝑛
41
+ - [x] 𝑈𝑠𝑒𝑟 𝑈𝑛𝑏𝑎𝑛
42
+ - [x] 𝐶ℎ𝑎𝑡 𝐿𝑒𝑎𝑣𝑒
43
+ - [x] 𝐶ℎ𝑎𝑡 𝐷𝑖𝑠𝑎𝑏𝑙𝑒
44
+ - [x] 𝐶ℎ𝑎𝑛𝑛𝑒𝑙
45
+ - [x] 𝑆𝑝𝑒𝑙𝑙𝑖𝑛𝑔 𝐶ℎ𝑒𝑐𝑘 𝐹𝑒𝑎𝑡𝑢𝑟𝑒
46
+ - [x] 𝐹𝑖𝑙𝑒 𝑆𝑡𝑜𝑟𝑒
47
+ - [x] 𝐴𝑢𝑡𝑜 𝐷𝑒𝑙𝑒𝑡𝑒
48
+ - [x] 𝐴𝑛𝑑 𝑀𝑜𝑟𝑒...
49
+
50
+ <b>𝑇𝑜 𝑘𝑛𝑜𝑤 𝑎𝑏𝑜𝑢𝑡 𝑎𝑙𝑙 𝑓𝑒𝑎𝑡𝑢𝑟𝑒𝑠, 𝐽𝑜𝑖𝑛 𝑜𝑢𝑟 <a href='https://telegram.me/TeamHMT_Bots'>𝑢𝑝𝑑𝑎𝑡𝑒𝑠 𝑐ℎ𝑎𝑛𝑛𝑒𝑙</a>.</b>
51
+
52
+ ## 𝐶𝑜𝑚𝑚𝑎𝑛𝑑𝑠
53
+ ```
54
+ • /invite - 𝑡𝑜 𝑔𝑒𝑡 𝑡ℎ𝑒 𝑖𝑛𝑣𝑖𝑡𝑒 𝑙𝑖𝑛𝑘 𝑜𝑓 𝑎𝑛𝑦 𝑐ℎ𝑎𝑡 𝑤ℎ𝑖𝑐ℎ 𝑡ℎ𝑒 𝑏𝑜𝑡 𝑖𝑠 𝑎𝑑𝑚𝑖𝑛.
55
+ • /logs - 𝑡𝑜 𝑔𝑒𝑡 𝑡ℎ𝑒 𝑟𝑒𝑠𝑐𝑒𝑛𝑡 𝑒𝑟𝑟𝑜𝑟𝑠
56
+ • /stats - 𝑡𝑜 𝑔𝑒𝑡 𝑠𝑡𝑎𝑡𝑢𝑠 𝑜𝑓 𝑓𝑖𝑙𝑒𝑠 𝑖𝑛 𝑑𝑏.
57
+ • /connections - 𝑇𝑜 𝑠𝑒𝑒 𝑎𝑙𝑙 𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑒𝑑 𝑔𝑟𝑜𝑢𝑝𝑠
58
+ • /settings - 𝑇𝑜 𝑜𝑝𝑒𝑛 𝑠𝑒𝑡𝑡𝑖𝑛𝑔𝑠 𝑚𝑒𝑛𝑢
59
+ • /filter - 𝑎𝑑𝑑 𝑚𝑎𝑛𝑢𝑎𝑙 𝑓𝑖𝑙𝑡𝑒𝑟𝑠
60
+ • /filters - 𝑣𝑖𝑒𝑤 𝑓𝑖𝑙𝑡𝑒𝑟𝑠
61
+ • /connect - 𝑐𝑜𝑛𝑛𝑒𝑐𝑡 𝑡𝑜 𝑃𝑀.
62
+ • /disconnect - 𝑑𝑖𝑠𝑐𝑜𝑛𝑛𝑒𝑐𝑡 𝑓𝑟𝑜𝑚 𝑃𝑀
63
+ • /del - 𝑑𝑒𝑙𝑒𝑡𝑒 𝑎 𝑓𝑖𝑙𝑡𝑒𝑟
64
+ • /delall - 𝑑𝑒𝑙𝑒𝑡𝑒 𝑎𝑙𝑙 𝑓𝑖𝑙𝑡𝑒𝑟𝑠
65
+ • /deleteall - 𝑑𝑒𝑙𝑒𝑡𝑒 𝑎𝑙𝑙 𝑖𝑛𝑑𝑒𝑥𝑒𝑑 𝑓𝑖𝑙𝑒𝑠.
66
+ • /delete - 𝑑𝑒𝑙𝑒𝑡𝑒 𝑎 𝑠𝑝𝑒𝑐𝑖𝑓𝑖𝑐 𝑓𝑖𝑙𝑒 𝑓𝑟𝑜𝑚 𝑖𝑛𝑑𝑒𝑥.
67
+ • /info - 𝑔𝑒𝑡 𝑢𝑠𝑒𝑟 𝑖𝑛𝑓𝑜
68
+ • /id - 𝑔𝑒𝑡 𝑡𝑔 𝑖𝑑𝑠.
69
+ • /imdb - 𝑓𝑒𝑡𝑐ℎ 𝑖𝑛𝑓𝑜 𝑓𝑟𝑜𝑚 𝑖𝑚𝑑𝑏.
70
+ • /search - 𝑇𝑜 𝑠𝑒𝑎𝑟𝑐ℎ 𝑓𝑟𝑜𝑚 𝑣𝑎𝑟𝑖𝑜𝑢𝑠 𝑠𝑜𝑢𝑟𝑐𝑒𝑠
71
+ • /start - 𝑇𝑜 𝑠����𝑎𝑟𝑡 𝑡ℎ𝑒 𝑏𝑜𝑡
72
+ • /setskip - 𝑇𝑜 𝑠𝑘𝑖𝑝 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑚𝑒𝑠𝑠𝑎𝑔𝑒𝑠 𝑤ℎ𝑒𝑛 𝑖𝑛𝑑𝑒𝑥𝑖𝑛𝑔 𝑓𝑖𝑙𝑒𝑠
73
+ • /users - 𝑡𝑜 𝑔𝑒𝑡 𝑙𝑖𝑠𝑡 𝑜𝑓 𝑚𝑦 𝑢𝑠𝑒𝑟𝑠 𝑎𝑛𝑑 𝑖𝑑𝑠.
74
+ • /chats - 𝑡𝑜 𝑔𝑒𝑡 𝑙𝑖𝑠𝑡 𝑜𝑓 𝑡ℎ𝑒 𝑚𝑦 𝑐ℎ𝑎𝑡𝑠 𝑎𝑛𝑑 𝑖𝑑𝑠
75
+ • /leave - 𝑡𝑜 𝑙𝑒𝑎𝑣𝑒 𝑓𝑟𝑜𝑚 𝑎 𝑐ℎ𝑎𝑡.
76
+ • /disable - 𝑑𝑜 𝑑𝑖𝑠𝑎𝑏𝑙𝑒 𝑎 𝑐ℎ𝑎𝑡.
77
+ • /enable - 𝑟𝑒-𝑒𝑛𝑎𝑏𝑙𝑒 𝑐ℎ𝑎𝑡.
78
+ • /ban - 𝑡𝑜 𝑏𝑎𝑛 𝑎 𝑢𝑠𝑒𝑟.
79
+ • /unban - 𝑡𝑜 𝑢𝑛𝑏𝑎𝑛 𝑎 𝑢𝑠𝑒𝑟.
80
+ • /channel - 𝑡𝑜 𝑔𝑒𝑡 𝑙𝑖𝑠𝑡 𝑜𝑓 𝑡𝑜𝑡𝑎𝑙 𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑒𝑑 𝑐ℎ𝑎𝑛𝑛𝑒𝑙𝑠
81
+ • /broadcast - 𝑡𝑜 𝑏𝑟𝑜𝑎𝑑𝑐𝑎𝑠𝑡 𝑎 𝑚𝑒𝑠𝑠𝑎𝑔𝑒 𝑡𝑜 𝑎𝑙𝑙 𝑢𝑠𝑒𝑟𝑠
82
+ • /grp_broadcast - 𝑇𝑜 𝑏𝑟𝑜𝑎𝑑𝑐𝑎𝑠𝑡 𝑎 𝑚𝑒𝑠𝑠𝑎𝑔𝑒 𝑡𝑜 𝑎𝑙𝑙 𝑐𝑜𝑛𝑛𝑒𝑐𝑡𝑒𝑑 𝑔𝑟𝑜𝑢𝑝𝑠.
83
+ • /batch - 𝑡𝑜 𝑐𝑟𝑒𝑎𝑡𝑒 𝑙𝑖𝑛𝑘 𝑓𝑜𝑟 𝑚𝑢𝑙𝑡𝑖𝑝𝑙𝑒 𝑝𝑜𝑠𝑡𝑠
84
+ • /link - 𝑡𝑜 𝑐𝑟𝑒𝑎𝑡𝑒 𝑙𝑖𝑛𝑘 𝑓𝑜𝑟 𝑜𝑛𝑒 𝑝𝑜𝑠𝑡
85
+ • /status - 𝑌𝑜𝑢𝑟 𝐻𝑒𝑟𝑜𝑘𝑢 𝐴𝑃𝐼 𝐾𝑒𝑦 𝑡𝑜 𝑐ℎ𝑒𝑐𝑘 𝑑𝑦𝑛𝑜, 𝑏𝑜𝑡 𝑢𝑝𝑡𝑖𝑚𝑒 𝑎𝑛𝑑 𝑏𝑜𝑡 𝑤𝑜𝑟𝑘𝑖𝑛𝑔 𝑑𝑎𝑦 𝑝𝑟𝑒𝑑𝑖𝑐𝑡𝑖𝑜𝑛.
86
+ • /set_template - 𝑇𝑜 𝑠𝑒𝑡 𝑎 𝑐𝑢𝑠𝑡𝑜𝑚 𝐼𝑀𝐷𝑏 𝑡𝑒𝑚𝑝𝑙𝑎𝑡𝑒 𝑓𝑜𝑟 𝑖𝑛𝑑𝑖𝑣𝑖𝑑𝑢𝑎𝑙 𝑔𝑟𝑜𝑢𝑝𝑠
87
+ • /gfilter - 𝑇𝑜 𝑎𝑑𝑑 𝑔𝑙𝑜𝑏𝑎𝑙 𝑓𝑖𝑙𝑡𝑒𝑟𝑠.
88
+ • /gfilters - 𝑇𝑜 𝑣𝑖𝑒𝑤 𝑙𝑖𝑠𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑔𝑙𝑜𝑏𝑎𝑙 𝑓𝑖𝑙𝑡𝑒𝑟𝑠.
89
+ • /delg - 𝑇𝑜 𝑑𝑒𝑙𝑒𝑡𝑒 𝑎 𝑠𝑝𝑒𝑐𝑖𝑓𝑖𝑐 𝑔𝑙𝑜𝑏𝑎𝑙 𝑓𝑖𝑙𝑡𝑒𝑟.
90
+ • /delallg - 𝑇𝑜 𝑑𝑒𝑙𝑒𝑡𝑒 𝑎𝑙𝑙 𝑔𝑙𝑜𝑏𝑎𝑙 𝑓𝑖𝑙𝑡𝑒𝑟𝑠 𝑓𝑟𝑜𝑚 𝑡ℎ𝑒 𝑏𝑜𝑡'𝑠 𝑑𝑎𝑡𝑎𝑏𝑎𝑠𝑒.
91
+ • /deletefiles - 𝑇𝑜 𝑑𝑒𝑙𝑒𝑡𝑒 𝑃𝑟𝑒𝐷𝑉𝐷 𝑎𝑛𝑑 𝐶𝑎𝑚𝑅𝑖𝑝 𝐹𝑖𝑙𝑒𝑠 𝑓𝑟𝑜𝑚 𝑡ℎ𝑒 𝑏𝑜𝑡'𝑠 𝑑𝑎𝑡𝑎𝑏𝑎𝑠𝑒.
92
+ ```
93
+
94
+ ## Variables
95
+
96
+ ### Required Variables
97
+ * `BOT_TOKEN`: Create a bot using [@BotFather](https://telegram.dog/BotFather), and get the Telegram API token.
98
+ * `API_ID`: Get this value from [telegram.org](https://my.telegram.org/apps)
99
+ * `API_HASH`: Get this value from [telegram.org](https://my.telegram.org/apps)
100
+ * `CHANNELS`: Username or ID of channel or group. Separate multiple IDs by space
101
+ * `ADMINS`: Username or ID of Admin. Separate multiple Admins by space
102
+ * `DATABASE_URI`: [mongoDB](https://www.mongodb.com) URI. Get this value from [mongoDB](https://www.mongodb.com). For more help watch this [video](https://youtu.be/1G1XwEOnxxo)
103
+ * `DATABASE_NAME`: Name of the database in [mongoDB](https://www.mongodb.com).
104
+ * `LOG_CHANNEL` : A channel to log the activities of bot. Make sure bot is an admin in the channel.
105
+ ### Optional Variables
106
+ * `PICS`: Telegraph links of images to show in start message.( Multiple images can be used separated by space )
107
+ * `FILE_STORE_CHANNEL`: Channel from were file store links of posts should be made.Separate multiple IDs by space
108
+ * Check [info.py](https://github.com/Moviesbotz/ben-url-filter-bot/blob/master/info.py) for more optional variables
109
+
110
+
111
+ <details><summary>Deploy To Heroku</summary>
112
+ <p>
113
+ <br>
114
+ <a href="https://heroku.com/deploy?template=https://github.com/Moviesbotz/Auto-filter-Urlshortener-All">
115
+ <img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy To Heroku">
116
+ </a>
117
+ </p>
118
+ </details>
119
+
120
+ <details><summary>Deploy To VPS</summary>
121
+ <p>
122
+ <pre>
123
+ git clone https://github.com/Moviesbotz/ben-url-filter-bot
124
+ # Install Packages
125
+ pip3 install -U -r requirements.txt
126
+ Edit info.py with variables as given below then run bot
127
+ python3 bot.py
128
+ </pre>
129
+ </p>
130
+ </details>
Script.py ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class script(object):
2
+ START_TXT = """<b>Hᴇʟʟᴏ {},
3
+ Mʏ Nᴀᴍᴇ Is <a href=https://t.me/{}>{}</a>, I Cᴀɴ Pʀᴏᴠɪᴅᴇ Mᴏᴠɪᴇs, Jᴜsᴛ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ As Aᴅᴍɪɴ Aɴᴅ Eɴᴊᴏʏ 😍</b>"""
4
+
5
+ HELP_TXT = """<b>Hᴇʏ {}
6
+ Hᴇʀᴇ Is Tʜᴇ Hᴇʟᴘ Fᴏʀ Mʏ Cᴏᴍᴍᴀɴᴅs.</b>"""
7
+
8
+ ABOUT_TXT = """<b>✯ Mʏ Nᴀᴍᴇ : {}</b>
9
+ <b>✯ Cʀᴇᴀᴛᴏʀ : <a href=https://t.me/Kgashok04>☢ Owner Of TTBots ☢</a></b>
10
+ <b>✯ Uᴘᴅᴀᴛᴇs : <a href=https://t.me/TeamHMT_Bots>TT Bot Updates 👾</a></b>
11
+ <b>✯ Bᴜɪʟᴅ Sᴛᴀᴛᴜs : ᴠ2.0.62 [Sᴛᴀʙʟᴇ]</b>"""
12
+
13
+ SOURCE_TXT = """
14
+ <b>Hᴇʏ, Tʜɪs ɪs ᴀ Oᴘᴇɴ Sᴏᴜʀᴄᴇ Pʀᴏᴊᴇᴄᴛ.
15
+
16
+ Tʜɪs Bᴏᴛ ʜᴀs Lᴀᴛᴇsᴛ ᴀɴᴅ Aᴅᴠᴀɴᴄᴇᴅ Fᴇᴀᴛᴜʀᴇs⚡️
17
+
18
+ Wᴀɴᴛ ᴛʜɪs Bᴏᴛ Rᴇᴘᴏ? - <a href='https://github.com/TeamHMT/Auto-search-tamil-bot'>ᴄʟɪᴄᴋ ʜᴇʀᴇ</a></b> 🙃</b>
19
+
20
+ Mᴏʀᴇ Iɴғᴏ Aʙᴏᴜᴛ ᴛʜɪs Rᴇᴘᴏ - <a href='https://t.me/TeamHMT_Bots/142'>ᴅᴏᴜʙʟᴇ ᴛᴀᴘ</a></b>
21
+ """
22
+
23
+ MANUELFILTER_TXT = """ʜᴇʟᴘ: <b>ꜰɪʟᴛᴇʀꜱ</b>
24
+ - ꜰɪʟᴛᴇʀ ɪꜱ ᴀ ꜰᴇᴀᴛᴜʀᴇ ᴡᴇʀᴇ ᴜꜱᴇʀꜱ ᴄᴀɴ ꜱᴇᴛ ᴀᴜᴛᴏᴍᴀᴛᴇᴅ ʀᴇᴘʟɪᴇꜱ ꜰᴏʀ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ᴋᴇʏᴡᴏʀᴅ ᴀɴᴅ ɪ ᴡɪʟʟ ʀᴇꜱᴘᴏɴᴅ ᴡʜᴇɴᴇᴠᴇʀ ᴀ ᴋᴇʏᴡᴏʀᴅ ɪꜱ ꜰᴏᴜɴᴅ ɪɴ ᴛʜᴇ ᴍᴇꜱꜱᴀɢᴇ
25
+ <b>ɴᴏᴛᴇ:</b>
26
+ 1. ᴛʜɪꜱ ʙᴏᴛ ꜱʜᴏᴜʟᴅ ʜᴀᴠᴇ ᴀᴅᴍɪɴ ᴘʀɪᴠɪʟᴇɢᴇ.
27
+ 2. ᴏɴʟʏ ᴀᴅᴍɪɴꜱ ᴄᴀɴ ᴀᴅᴅ ꜰɪʟᴛᴇʀꜱ ɪɴ ᴀ ᴄʜᴀᴛ.
28
+ 3. ᴀʟᴇʀᴛ ʙᴜᴛᴛᴏɴꜱ ʜᴀᴠᴇ ᴀ ʟɪᴍɪᴛ ᴏꜰ 64 ᴄʜᴀʀᴀᴄᴛᴇʀꜱ.
29
+ Cᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:
30
+ • /filter - <code>ᴀᴅᴅ ᴀ ꜰɪʟᴛᴇʀ ɪɴ ᴀ ᴄʜᴀᴛ</code>
31
+ • /filters - <code>ʟɪꜱᴛ ᴀʟʟ ᴛʜᴇ ꜰɪʟᴛᴇʀꜱ ᴏꜰ ᴀ ᴄʜᴀᴛ</code>
32
+ • /del - <code>ᴅᴇʟᴇᴛᴇ ᴀ ꜱᴘᴇᴄɪꜰɪᴄ ꜰɪʟᴛᴇʀ ɪɴ ᴀ ᴄʜᴀᴛ</code>
33
+ • /delall - <code>ᴅᴇʟᴇᴛᴇ ᴛʜᴇ ᴡʜᴏʟᴇ ꜰɪʟᴛᴇʀꜱ ɪɴ ᴀ ᴄʜᴀᴛ (ᴄʜᴀᴛ ᴏᴡɴᴇʀ ᴏɴʟʏ)</code>"""
34
+
35
+ BUTTON_TXT = """ʜᴇʟᴘ: <b>ʙᴜᴛᴛᴏɴꜱ</b>
36
+ - ᴛʜɪꜱ ʙᴏᴛ ꜱᴜᴘᴘᴏʀᴛꜱ ʙᴏᴛʜ ᴜʀʟ ᴀɴᴅ ᴀʟᴇʀᴛ ɪɴʟɪɴᴇ ʙᴜᴛᴛᴏɴꜱ.
37
+ <b>ɴᴏᴛᴇ:</b>
38
+ 1. ᴛᴇʟᴇɢʀᴀᴍ ᴡɪʟʟ ɴᴏᴛ ᴀʟʟᴏᴡꜱ ʏᴏᴜ ᴛᴏ ꜱᴇɴᴅ ʙᴜᴛᴛᴏɴꜱ ᴡɪᴛʜᴏᴜᴛ ᴀɴʏ ᴄᴏɴᴛᴇɴᴛ, ꜱᴏ ᴄᴏɴᴛᴇɴᴛ ɪꜱ ᴍᴀɴᴅᴀᴛᴏʀʏ.
39
+ 2. ᴛʜɪꜱ ʙᴏᴛ ꜱᴜᴘᴘᴏʀᴛꜱ ʙᴜᴛᴛᴏɴꜱ ᴡɪᴛʜ ᴀɴʏ ᴛᴇʟᴇɢʀᴀᴍ ᴍᴇᴅɪᴀ ᴛʏᴘᴇ.
40
+ 3. ʙᴜᴛᴛᴏɴꜱ ꜱʜᴏᴜʟᴅ ʙᴇ ᴘʀᴏᴘᴇʀʟʏ ᴘᴀʀꜱᴇᴅ ᴀꜱ ᴍᴀʀᴋᴅᴏᴡɴ ꜰᴏʀᴍᴀᴛ
41
+ <b>ᴜʀʟ ʙᴜᴛᴛᴏɴꜱ:</b>
42
+ <code>[Button Text](buttonurl:https://t.me/TeamHMT_Bots)</code>
43
+ <b>ᴀʟᴇʀᴛ ʙᴜᴛᴛᴏɴꜱ:</b>
44
+ <code>[Button Text](buttonalert:ᴛʜɪꜱ ɪꜱ ᴀɴ ᴀʟᴇʀᴛ ᴍᴇꜱꜱᴀɢᴇ)</code>"""
45
+
46
+ AUTOFILTER_TXT = """ʜᴇʟᴘ: <b>ᴀᴜᴛᴏ ꜰɪʟᴛᴇʀ</b>
47
+ <b>ɴᴏᴛᴇ: Fɪʟᴇ Iɴᴅᴇx</b>
48
+ 1. ᴍᴀᴋᴇ ᴍᴇ ᴛʜᴇ ᴀᴅᴍɪɴ ᴏꜰ ʏᴏᴜʀ ᴄʜᴀɴɴᴇʟ ɪꜰ ɪᴛ'ꜱ ᴘʀɪᴠᴀᴛᴇ.
49
+ 2. ᴍᴀᴋᴇ ꜱᴜʀᴇ ᴛʜᴀᴛ ʏᴏᴜʀ ᴄʜᴀɴɴᴇʟ ᴅᴏᴇꜱ ɴᴏᴛ ᴄᴏɴᴛᴀɪɴꜱ ᴄᴀᴍʀɪᴘꜱ, ᴘᴏʀɴ ᴀɴᴅ ꜰᴀᴋᴇ ꜰɪʟᴇꜱ.
50
+ 3. ꜰᴏʀᴡᴀʀᴅ ᴛʜᴇ ʟᴀꜱᴛ ᴍᴇꜱꜱᴀɢᴇ ᴛᴏ ᴍᴇ ᴡɪᴛʜ Qᴜᴏᴛᴇꜱ. ɪ'ʟʟ ᴀᴅᴅ ᴀʟʟ ᴛʜᴇ ꜰɪʟᴇꜱ ɪɴ ᴛʜᴀᴛ ᴄʜᴀɴɴᴇʟ ᴛᴏ ᴍʏ ᴅʙ.
51
+
52
+ <b>Nᴏᴛᴇ: AᴜᴛᴏFɪʟᴛᴇʀ</b>
53
+ 1. Aᴅᴅ ᴛʜᴇ ʙᴏᴛ ᴀs ᴀᴅᴍɪɴ ᴏɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ.
54
+ 2. Usᴇ /connect ᴀɴᴅ ᴄᴏɴɴᴇᴄᴛ ʏᴏᴜʀ ɢʀᴏᴜᴘ ᴛᴏ ᴛʜᴇ ʙᴏᴛ.
55
+ 3. Usᴇ /settings ᴏɴ ʙᴏᴛ's PM ᴀɴᴅ ᴛᴜʀɴ ᴏɴ AᴜᴛᴏFɪʟᴛᴇʀ ᴏɴ ᴛʜᴇ sᴇᴛᴛɪɴɢs ᴍᴇɴᴜ."""
56
+
57
+ CONNECTION_TXT = """ʜᴇʟᴘ: <b>ᴄᴏɴɴᴇᴄᴛɪᴏɴꜱ</b>
58
+ - ᴜꜱᴇᴅ ᴛᴏ ᴄᴏɴɴᴇᴄᴛ ʙᴏᴛ ᴛᴏ ᴘᴍ ꜰᴏʀ ᴍᴀɴᴀɢɪɴɢ ꜰɪʟᴛᴇʀꜱ
59
+ - ɪᴛ ʜᴇʟᴘꜱ ᴛᴏ ᴀᴠᴏɪᴅ ꜱᴘᴀᴍᴍɪɴɢ ɪɴ ɢʀᴏᴜᴘꜱ.
60
+ <b>ɴᴏᴛᴇ:</b>
61
+ 1. ᴏɴʟʏ ᴀᴅᴍɪɴꜱ ᴄᴀɴ ᴀᴅᴅ ᴀ ᴄᴏɴɴᴇᴄᴛɪᴏɴ.
62
+ 2. ꜱᴇɴᴅ <code>/ᴄᴏɴɴᴇᴄᴛ</code> ꜰᴏʀ ᴄᴏɴɴᴇᴄᴛɪɴɢ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ᴘᴍ
63
+ Cᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:
64
+ • /connect - <code>ᴄᴏɴɴᴇᴄᴛ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ᴄʜᴀᴛ ᴛᴏ ʏᴏᴜʀ ᴘᴍ</code>
65
+ • /disconnect - <code>ᴅɪꜱᴄᴏɴɴᴇᴄᴛ ꜰʀᴏᴍ ᴀ ᴄʜᴀᴛ</code>
66
+ • /connections - <code>ʟɪꜱᴛ ᴀʟʟ ʏᴏᴜʀ ᴄᴏɴɴᴇᴄᴛɪᴏɴꜱ</code>"""
67
+
68
+ EXTRAMOD_TXT = """ʜᴇʟᴘ: Exᴛʀᴀ Mᴏᴅᴜʟᴇs
69
+ <b>ɴᴏᴛᴇ:</b>
70
+ ᴛʜᴇꜱᴇ ᴀʀᴇ ᴛʜᴇ ᴇxᴛʀᴀ ꜰᴇᴀᴛᴜʀᴇꜱ ᴏꜰ ᴛʜɪꜱ ʙᴏᴛ
71
+ Cᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:
72
+ • /id - <code>ɢᴇᴛ ɪᴅ ᴏꜰ ᴀ ꜱᴘᴇᴄɪꜰɪᴇᴅ ᴜꜱᴇʀ.</code>
73
+ • /info - <code>ɢᴇᴛ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ᴀʙᴏᴜᴛ ᴀ ᴜꜱᴇʀ.</code>
74
+ • /imdb - <code>ɢᴇᴛ ᴛʜᴇ ꜰɪʟᴍ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ꜰʀᴏᴍ ɪᴍᴅʙ ꜱᴏᴜʀᴄᴇ.</code>
75
+ • /search - <code>ɢᴇᴛ ᴛʜᴇ ꜰɪʟᴍ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ꜰʀᴏᴍ ᴠᴀʀɪᴏᴜꜱ ꜱᴏᴜʀᴄᴇꜱ.</code>"""
76
+
77
+ ADMIN_TXT = """ʜᴇʟᴘ: Aᴅᴍɪɴ Mᴏᴅs
78
+ <b>ɴᴏᴛᴇ:</b>
79
+ Tʜɪs Mᴏᴅᴜʟᴇ Oɴʟʏ Wᴏʀᴋs Fᴏʀ Mʏ Aᴅᴍɪɴs
80
+ Cᴏᴍᴍᴀɴᴅs Aɴᴅ Usᴀɢᴇ:
81
+ • /logs - <code>ᴛᴏ ɢᴇᴛ ᴛʜᴇ ʀᴇᴄᴇɴᴛ ᴇʀʀᴏʀꜱ</code>
82
+ • /stats - <code>ᴛᴏ ɢᴇᴛ ꜱᴛᴀᴛᴜꜱ ᴏꜰ ꜰɪʟᴇꜱ ɪɴ ᴅʙ. [Tʜɪs Cᴏᴍᴍᴀɴᴅ Cᴀɴ Bᴇ Usᴇᴅ Bʏ Aɴʏᴏɴᴇ]</code>
83
+ • /delete - <code>ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀ ꜱᴘᴇᴄɪꜰɪᴄ ꜰɪʟᴇ ꜰʀᴏᴍ ᴅʙ.</code>
84
+ • /users - <code>ᴛᴏ ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴍʏ ᴜꜱᴇʀꜱ ᴀɴᴅ ɪᴅꜱ.</code>
85
+ • /chats - <code>ᴛᴏ ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴍʏ ᴄʜᴀᴛꜱ ᴀɴᴅ ɪᴅꜱ</code>
86
+ • /leave - <code>ᴛᴏ ʟᴇᴀᴠᴇ ꜰʀᴏᴍ ᴀ ᴄʜᴀᴛ.</code>
87
+ • /disable - <code>ᴛᴏ ᴅɪꜱᴀʙʟᴇ ᴀ ᴄʜᴀᴛ.</code>
88
+ • /ban - <code>ᴛᴏ ʙᴀɴ ᴀ ᴜꜱᴇʀ.</code>
89
+ • /unban - <code>ᴛᴏ ᴜɴʙᴀɴ ᴀ ᴜꜱᴇʀ.</code>
90
+ • /channel - <code>ᴛᴏ ɢᴇᴛ ʟɪꜱᴛ ᴏꜰ ᴛᴏᴛᴀʟ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴄʜᴀɴɴᴇʟꜱ</code>
91
+ • /broadcast - <code>ᴛᴏ ʙʀᴏᴀᴅᴄᴀꜱᴛ ᴀ ᴍᴇꜱꜱᴀɢᴇ ᴛᴏ ᴀʟʟ ᴜꜱᴇʀꜱ</code>
92
+ • /grp_broadcast - <code>Tᴏ ʙʀᴏᴀᴅᴄᴀsᴛ ᴀ ᴍᴇssᴀɢᴇ ᴛᴏ ᴀʟʟ ᴄᴏɴɴᴇᴄᴛᴇᴅ ɢʀᴏᴜᴘs.</code>
93
+ • /gfilter - <code>ᴛᴏ ᴀᴅᴅ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs</code>
94
+ • /gfilters - <code>ᴛᴏ ᴠɪᴇᴡ ʟɪsᴛ ᴏғ ᴀʟʟ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs</code>
95
+ • /delg - <code>ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀ sᴘᴇᴄɪғɪᴄ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ</code>
96
+ • /request - <code>Tᴏ sᴇɴᴅ ᴀ Mᴏᴠɪᴇ/Sᴇʀɪᴇs ʀᴇᴏ̨ᴜᴇsᴛ ᴛᴏ ʙᴏᴛ ᴀᴅᴍɪɴs. Oɴʟʏ ᴡᴏʀᴋs ᴏɴ sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ. [Tʜɪs Cᴏᴍᴍᴀɴᴅ Cᴀɴ Bᴇ Usᴇᴅ Bʏ Aɴʏᴏɴᴇ]</code>
97
+ • /delallg - <code>Tᴏ ᴅᴇʟᴇᴛᴇ ᴀʟʟ Gғɪʟᴛᴇʀs ғʀᴏᴍ ᴛʜᴇ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ.</code>
98
+ • /deletefiles - <code>Tᴏ ᴅᴇʟᴇᴛᴇ CᴀᴍRɪᴘ ᴀɴᴅ PʀᴇDVD Fɪʟᴇs ғʀᴏᴍ ᴛʜᴇ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ.</code>"""
99
+
100
+ STATUS_TXT = """<b>★ Tᴏᴛᴀʟ Fɪʟᴇs: <code>{}</code>
101
+ ★ Tᴏᴛᴀʟ Usᴇʀs: <code>{}</code>
102
+ ★ Tᴏᴛᴀʟ Cʜᴀᴛs: <code>{}</code>
103
+ ★ Usᴇᴅ Sᴛᴏʀᴀɢᴇ: <code>{}</code>
104
+ ★ Fʀᴇᴇ Sᴛᴏʀᴀɢᴇ: <code>{}</code></b>"""
105
+
106
+ LOG_TEXT_G = """#NewGroup
107
+ Gʀᴏᴜᴘ = {}(<code>{}</code>)
108
+ Tᴏᴛᴀʟ Mᴇᴍʙᴇʀs = <code>{}</code>
109
+ Aᴅᴅᴇᴅ Bʏ - {}"""
110
+
111
+ LOG_TEXT_P = """#NewUser
112
+ ID - <code>{}</code>
113
+ Nᴀᴍᴇ - {}"""
114
+
115
+ ALRT_TXT = """ʜᴇʟʟᴏ {},
116
+ ᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇQᴜᴇꜱᴛ,
117
+ ʀᴇQᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ..."""
118
+
119
+ OLD_ALRT_TXT = """ʜᴇʏ {},
120
+ ʏᴏᴜ ᴀʀᴇ ᴜꜱɪɴɢ ᴏɴᴇ ᴏꜰ ᴍʏ ᴏʟᴅ ᴍᴇꜱꜱᴀɢᴇꜱ,
121
+ ᴘʟᴇᴀꜱᴇ ꜱᴇɴᴅ ᴛʜᴇ ʀᴇQᴜᴇꜱᴛ ᴀɢᴀɪɴ."""
122
+
123
+ CUDNT_FND = """ɪ ᴄᴏᴜʟᴅɴ'ᴛ ꜰɪɴᴅ ᴀɴʏᴛʜɪɴɢ ʀᴇʟᴀᴛᴇᴅ ᴛᴏ {}
124
+ ᴅɪᴅ ʏᴏᴜ ᴍᴇᴀɴ ᴀɴʏ ᴏɴᴇ ᴏꜰ ᴛʜᴇꜱᴇ?"""
125
+
126
+ I_CUDNT = """<b>sᴏʀʀʏ ɴᴏ ꜰɪʟᴇs ᴡᴇʀᴇ ꜰᴏᴜɴᴅ ꜰᴏʀ ʏᴏᴜʀ ʀᴇǫᴜᴇꜱᴛ {} 😕
127
+
128
+ ᴄʜᴇᴄᴋ ʏᴏᴜʀ sᴘᴇʟʟɪɴɢ ɪɴ ɢᴏᴏɢʟᴇ ᴀɴᴅ ᴛʀʏ ᴀɢᴀɪɴ 😃
129
+
130
+ ᴍᴏᴠɪᴇ ʀᴇǫᴜᴇꜱᴛ ꜰᴏʀᴍᴀᴛ 👇
131
+
132
+ ᴇxᴀᴍᴘʟᴇ : Uncharted or Uncharted 2022 or Uncharted En
133
+
134
+ ꜱᴇʀɪᴇꜱ ʀᴇǫᴜᴇꜱᴛ ꜰᴏʀᴍᴀᴛ 👇
135
+
136
+ ᴇxᴀᴍᴘʟᴇ : Loki S01 or Loki S01E04 or Lucifer S03E24
137
+
138
+ 🚯 ᴅᴏɴᴛ ᴜꜱᴇ ➠ ':(!,./)</b>"""
139
+
140
+ I_CUD_NT = """ɪ ᴄᴏᴜʟᴅɴ'ᴛ ꜰɪɴᴅ ᴀɴʏ ᴍᴏᴠɪᴇ ʀᴇʟᴀᴛᴇᴅ ᴛᴏ {}.
141
+ ᴘʟᴇᴀꜱᴇ ᴄʜᴇᴄᴋ ᴛʜᴇ ꜱᴘᴇʟʟɪɴɢ ᴏɴ ɢᴏᴏɢʟᴇ ᴏʀ ɪᴍᴅʙ..."""
142
+
143
+ MVE_NT_FND = """ᴍᴏᴠɪᴇ ɴᴏᴛ ꜰᴏᴜɴᴅ ɪɴ ᴅᴀᴛᴀʙᴀꜱᴇ..."""
144
+
145
+ TOP_ALRT_MSG = """Cʜᴇᴄᴋɪɴɢ Fᴏʀ Mᴏᴠɪᴇ Iɴ Dᴀᴛᴀʙᴀsᴇ..."""
146
+
147
+ MELCOW_ENG = """<b>Hᴇʟʟᴏ {} 😍, Aɴᴅ Wᴇʟᴄᴏᴍᴇ Tᴏ {} Gʀᴏᴜᴘ ❤️</b>"""
148
+
149
+ SHORTLINK_INFO = """
150
+ <b>──────「<a href=https://t.me/TeamHMT_Bots/44> Hᴏᴡ ᴛᴏ Eᴀʀɴ Mᴏɴᴇʏ </a> 」──────
151
+
152
+ Yᴏᴜ ᴄᴀɴ Eᴀʀɴ Mᴏɴᴇʏ Fʀᴏᴍ Tʜɪs Bᴏᴛ Uɴᴛɪʟ ᴛʜɪs ʙᴏᴛ ɪs ᴀʟɪᴠᴇ.
153
+
154
+ Wᴀɴᴛ ᴛᴏ Kɴᴏᴡ Hᴏᴡ? Fᴏʟʟᴏᴡ Tʜᴇsᴇ Sᴛᴇᴘs:-
155
+
156
+ sᴛᴇᴘ 𝟷 : ʏᴏᴜ ᴍᴜsᴛ ʜᴀᴠᴇ ᴀᴛʟᴇᴀsᴛ ᴏɴᴇ ɢʀᴏᴜᴘ ᴡɪᴛʜ ᴍɪɴɪᴍᴜᴍ 1𝟶𝟶 ᴍᴇᴍʙᴇʀs.
157
+
158
+ sᴛᴇᴘ 𝟸 : ᴍᴀᴋᴇ ᴀᴄᴄᴏᴜɴᴛ ᴏɴ Aɴʏ <a href=https://mplaylink.com/ref/106324576666323105902>Sʜᴏʀᴛᴇɴᴇʀ Wᴇʙsɪᴛᴇ</a>.
159
+
160
+ sᴛᴇᴘ 𝟹 : ꜰᴏʟʟᴏᴡ ᴛʜᴇsᴇ <a href=https://t.me/TeamHMT_Bots/44> ɪɴꜱᴛʀᴜᴄᴛɪᴏɴꜱ </a>Tᴏ ᴄᴏɴɴᴇᴄᴛ sʜᴏʀᴛᴇɴᴇʀ.
161
+
162
+ ➣ Yᴏᴜ ᴄᴀɴ ᴄᴏɴɴᴇᴄᴛ ᴀs ᴍᴀɴʏ ɢʀᴏᴜᴘ ʏᴏᴜ ʜᴀᴠᴇ.
163
+
164
+ Any Doubts or Not Connecting? Contact Me </b>
165
+ """
166
+
167
+ REQINFO = """
168
+ ⚠ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ⚠
169
+
170
+ ᴀꜰᴛᴇʀ 5 ᴍɪɴᴜᴛᴇꜱ ᴛʜɪꜱ ᴍᴇꜱꜱᴀɢᴇ ᴡɪʟʟ ʙᴇ ᴀᴜᴛᴏᴍᴀᴛɪᴄᴀʟʟʏ ᴅᴇʟᴇᴛᴇᴅ
171
+
172
+ ɪꜰ ʏᴏᴜ ᴅᴏ ɴᴏᴛ ꜱᴇᴇ ᴛʜᴇ ʀᴇǫᴜᴇsᴛᴇᴅ ᴍᴏᴠɪᴇ / sᴇʀɪᴇs ꜰɪʟᴇ, ʟᴏᴏᴋ ᴀᴛ ᴛʜᴇ ɴᴇxᴛ ᴘᴀɢᴇ"""
173
+
174
+ SELECT = """
175
+ MOVIES ➢ Sᴇʟᴇᴄᴛ "Lᴀɴɢᴜᴀɢᴇs"
176
+
177
+ SERIES ➢ Sᴇʟᴇᴄᴛ "Sᴇᴀsᴏɴs"
178
+
179
+ Tɪᴘ: Sᴇʟᴇᴄᴛ "Lᴀɴɢᴜᴀɢᴇs" ᴏʀ "Sᴇᴀsᴏɴs" Bᴜᴛᴛᴏɴ ᴀɴᴅ Cʟɪᴄᴋ "Sᴇɴᴅ Aʟʟ" Tᴏ ɢᴇᴛ Aʟʟ Fɪʟᴇ Lɪɴᴋs ɪɴ ᴀ Sɪɴɢʟᴇ ᴄʟɪᴄᴋ"""
180
+
181
+ SINFO = """
182
+ ⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
183
+ ꜱᴇʀɪᴇꜱ ʀᴇǫᴜᴇꜱᴛ ꜰᴏʀᴍᴀᴛ
184
+ ⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯
185
+
186
+ ɢᴏ ᴛᴏ ɢᴏᴏɢʟᴇ ➠ ᴛʏᴘᴇ ꜱᴇʀɪᴇꜱ ɴᴀᴍᴇ ➠ ᴄᴏᴘʏ ᴄᴏʀʀᴇᴄᴛ ɴᴀᴍᴇ ➠ ᴘᴀꜱᴛᴇ ᴛʜɪꜱ ɢʀᴏᴜᴘ
187
+
188
+ ᴇxᴀᴍᴘʟᴇ : Loki S01E01
189
+
190
+ 🚯 ᴅᴏɴᴛ ᴜꜱᴇ ➠ ':(!,./)"""
191
+
192
+ NORSLTS = """
193
+ ★ #𝗡𝗼𝗥𝗲𝘀𝘂𝗹𝘁𝘀 ★
194
+
195
+ 𝗜𝗗 <b>: {}</b>
196
+
197
+ 𝗡𝗮𝗺𝗲 <b>: {}</b>
198
+
199
+ 𝗠𝗲𝘀𝘀𝗮𝗴𝗲 <b>: {}</b>"""
200
+
201
+ CAPTION = """<b>📂Fɪʟᴇɴᴀᴍᴇ : {file_name}
202
+ ╔════ ᴊᴏɪɴ ᴡɪᴛʜ ᴜs ════╗
203
+ ▫️<a href=https://t.me/+pl4rB-xx8ltlOTE1> ᴍᴏᴠɪᴇ ɢʀᴏᴜᴘ </a>
204
+ ▫️<a href=https://t.me/+ps2An00KwZYwNTRl> ʀᴇǫᴜᴇsᴛ ᴍᴏᴠɪᴇs​ </a>
205
+ ╚════ ᴊᴏɪɴ ᴡɪᴛʜ ᴜs ════╝</b>"""
206
+
207
+ IMDB_TEMPLATE_TXT = """
208
+ <b>Query: {qurey}
209
+
210
+ IMDb Data:
211
+
212
+ 🏷 Title: <a href={url}>{title}</a>
213
+ 🎭 Genres: {genres}
214
+ 📆 Year: <a href={url}/releaseinfo>{year}</a>
215
+ ⏱️ Result Shown in: {remaining_seconds} <i>seconds</i> 🔥
216
+ 🌟 Rating: <a href={url}/ratings>{rating}</a> / 10</b>"""
217
+
218
+ ALL_FILTERS = """
219
+ <b>Hᴇʏ {}, Tʜᴇsᴇ ᴀʀᴇ ᴍʏ ᴛʜʀᴇᴇ ᴛʏᴘᴇs ᴏғ ғɪʟᴛᴇʀs.</b>"""
220
+
221
+ GFILTER_TXT = """
222
+ <b>Wᴇʟᴄᴏᴍᴇ ᴛᴏ Gʟᴏʙᴀʟ Fɪʟᴛᴇʀs. Gʟᴏʙᴀʟ Fɪʟᴛᴇʀs ᴀʀᴇ ᴛʜᴇ ғɪʟᴛᴇʀs sᴇᴛ ʙʏ ʙᴏᴛ ᴀᴅᴍɪɴs ᴡʜɪᴄʜ ᴡɪʟʟ ᴡᴏʀᴋ ᴏɴ ᴀʟʟ ɢʀᴏᴜᴘs.</b>
223
+
224
+ Aᴠᴀɪʟᴀʙʟᴇ ᴄᴏᴍᴍᴀɴᴅs:
225
+ • /gfilter - <code>Tᴏ ᴄʀᴇᴀᴛᴇ ᴀ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ.</code>
226
+ • /gfilters - <code>Tᴏ ᴠɪᴇᴡ ᴀʟʟ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀs.</code>
227
+ • /delg - <code>Tᴏ ᴅᴇʟᴇᴛᴇ ᴀ ᴘᴀʀᴛɪᴄᴜʟᴀʀ ɢʟᴏʙᴀʟ ғɪʟᴛᴇʀ.</code>
228
+ • /delallg - <code>ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀʟʟ ɢʟᴏʙᴀʟ ꜰɪʟᴛᴇʀꜱ.</code>"""
229
+
230
+ FILE_STORE_TXT = """
231
+ <b>Fɪʟᴇ sᴛᴏʀᴇ ɪs ᴛʜᴇ ғᴇᴀᴛᴜʀᴇ ᴡʜɪᴄʜ ᴡɪʟʟ ᴄʀᴇᴀᴛᴇ ᴀ sʜᴀʀᴇᴀʙʟᴇ ʟɪɴᴋ ᴏғ ᴀ sɪɴɢʟᴇ ᴏʀ ᴍᴜʟᴛɪᴘʟᴇ ғɪʟᴇs.</b>
232
+
233
+ Aᴠᴀɪʟᴀʙʟᴇ ᴄᴏᴍᴍᴀɴᴅs:
234
+ • /batch - <code>Tᴏ ᴄʀᴇᴀᴛᴇ ᴀ ʙᴀᴛᴄʜ ʟɪɴᴋ ᴏғ ᴍᴜʟᴛɪᴘʟᴇ ғɪʟᴇs.</code>
235
+ • /link - <code>Tᴏ ᴄʀᴇᴀᴛᴇ ᴀ sɪɴɢʟᴇ ғɪʟᴇ sᴛᴏʀᴇ ʟɪɴᴋ.</code>
236
+ • /pbatch - <code>Jᴜsᴛ ʟɪᴋᴇ /batch, ʙᴜᴛ ᴛʜᴇ ғɪʟᴇs ᴡɪʟʟ ʙᴇ sᴇɴᴅ ᴡɪᴛʜ ғᴏʀᴡᴀʀᴅ ʀᴇsᴛʀɪᴄᴛɪᴏɴs.</code>
237
+ • /plink - <code>Jᴜsᴛ ʟɪᴋᴇ /link, ʙᴜᴛ ᴛʜᴇ ғɪʟᴇ ᴡɪʟʟ ʙᴇ sᴇɴᴅ ᴡɪᴛʜ ғᴏʀᴡᴀʀᴅ ʀᴇsᴛʀɪᴄᴛɪᴏɴ.</code>"""
238
+
239
+ RESTART_TXT = """
240
+ <b>Bᴏᴛ Rᴇsᴛᴀʀᴛᴇᴅ !
241
+
242
+ 📅 Dᴀᴛᴇ : <code>{}</code>
243
+ ⏰ Tɪᴍᴇ : <code>{}</code>
244
+ 🌐 Tɪᴍᴇᴢᴏɴᴇ : <code>Asia/Kolkata</code>
245
+ 🛠️ Bᴜɪʟᴅ Sᴛᴀᴛᴜs: <code>v2.7.1 [ Sᴛᴀʙʟᴇ ]</code></b>"""
246
+
247
+ LOGO = """
248
+
249
+ ████████╗████████╗  ██████╗░░█████╗░████████╗░██████╗
250
+ ╚══██╔══╝╚══██╔══╝  ██╔══██╗██╔══██╗╚══██╔══╝██╔════╝
251
+ ░░░██║░░░���░░██║░░░  ██████╦╝██║░░██║░░░██║░░░╚█████╗░
252
+ ░░░██║░░░░░░██║░░░  ██╔══██╗██║░░██║░░░██║░░░░╚═══██╗
253
+ ░░░██║░░░░░░██║░░░  ██████╦╝╚█████╔╝░░░██║░░░██████╔╝
254
+ ░░░╚═╝░░░░░░╚═╝░░░  ╚═════╝░░╚════╝░░░░╚═╝░░░╚═════╝░"""
app.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Ben-Url-Filter-Bot",
3
+ "description": "When you going to send file on telegram channel this bot will save that in database, So you can search that easily in inline mode",
4
+ "stack": "container",
5
+ "keywords": [
6
+ "telegram",
7
+ "auto-filter",
8
+ "filter",
9
+ "best",
10
+ "indian",
11
+ "pyrogram",
12
+ "media",
13
+ "search",
14
+ "channel",
15
+ "index",
16
+ "inline"
17
+ ],
18
+ "website": "https://github.com/Moviesbotz/ben-url-filter-bot",
19
+ "repository": "https://github.com/Moviesbotz/ben-url-filter-bot",
20
+ "env": {
21
+ "BOT_TOKEN": {
22
+ "description": "Your bot token.",
23
+ "required": true
24
+ },
25
+ "API_ID": {
26
+ "description": "Get this value from https://my.telegram.org",
27
+ "required": true
28
+ },
29
+ "API_HASH": {
30
+ "description": "Get this value from https://my.telegram.org",
31
+ "required": true
32
+ },
33
+ "CHANNELS": {
34
+ "description": "Username or ID of channel or group. Separate multiple IDs by space.",
35
+ "required": false
36
+ },
37
+ "ADMINS": {
38
+ "description": "Username or ID of Admin. Separate multiple Admins by space.",
39
+ "required": true
40
+ },
41
+ "PICS": {
42
+ "description": "Add some telegraph link of pictures .",
43
+ "required": false
44
+ },
45
+ "LOG_CHANNEL": {
46
+ "description": "Bot Logs,Give a channel id with -100xxxxxxx",
47
+ "required": true
48
+ },
49
+ "AUTH_USERS": {
50
+ "description": "Username or ID of users to give access of inline search. Separate multiple users by space.\nLeave it empty if you don't want to restrict bot usage.",
51
+ "required": false
52
+ },
53
+ "AUTH_CHANNEL": {
54
+ "description": "ID of channel.Make sure bot is admin in this channel. Without subscribing this channel users cannot use bot.",
55
+ "required": false
56
+ },
57
+ "DATABASE_URI": {
58
+ "description": "mongoDB URI. Get this value from https://www.mongodb.com. For more help watch this video - https://youtu.be/dsuTn4qV2GA",
59
+ "required": true
60
+ },
61
+ "DATABASE_NAME": {
62
+ "description": "Name of the database in mongoDB. For more help watch this video - https://youtu.be/dsuTn4qV2GA",
63
+ "required": false
64
+ },
65
+ "COLLECTION_NAME": {
66
+ "description": "Name of the collections. Defaults to Telegram_files. If you are using the same database, then use different collection name for each bot",
67
+ "value": "Telegram_files",
68
+ "required": false
69
+ }
70
+ },
71
+ "addons": [],
72
+ "buildpacks": [{
73
+ "url": "heroku/python"
74
+ }],
75
+ "formation": {
76
+ "worker": {
77
+ "quantity": 1,
78
+ "size": "eco"
79
+ }
80
+ }
81
+ }
bot.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import logging.config
3
+
4
+ # Get logging configurations
5
+ logging.config.fileConfig('logging.conf')
6
+ logging.getLogger().setLevel(logging.INFO)
7
+ logging.getLogger("pyrogram").setLevel(logging.ERROR)
8
+ logging.getLogger("imdbpy").setLevel(logging.ERROR)
9
+
10
+ from pyrogram import Client, __version__
11
+ from pyrogram.raw.all import layer
12
+ from database.ia_filterdb import Media
13
+ from database.users_chats_db import db
14
+ from info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_STR, LOG_CHANNEL, PORT
15
+ from utils import temp
16
+ from typing import Union, Optional, AsyncGenerator
17
+ from pyrogram import types
18
+ from Script import script
19
+ from datetime import date, datetime
20
+ import pytz
21
+ from aiohttp import web
22
+ from plugins import web_server
23
+
24
+ class Bot(Client):
25
+
26
+ def __init__(self):
27
+ super().__init__(
28
+ name=SESSION,
29
+ api_id=API_ID,
30
+ api_hash=API_HASH,
31
+ bot_token=BOT_TOKEN,
32
+ workers=50,
33
+ plugins={"root": "plugins"},
34
+ sleep_threshold=5,
35
+ )
36
+
37
+ async def start(self):
38
+ b_users, b_chats = await db.get_banned()
39
+ temp.BANNED_USERS = b_users
40
+ temp.BANNED_CHATS = b_chats
41
+ await super().start()
42
+ await Media.ensure_indexes()
43
+ me = await self.get_me()
44
+ temp.ME = me.id
45
+ temp.U_NAME = me.username
46
+ temp.B_NAME = me.first_name
47
+ self.username = '@' + me.username
48
+ logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.")
49
+ logging.info(LOG_STR)
50
+ logging.info(script.LOGO)
51
+ tz = pytz.timezone('Asia/Kolkata')
52
+ today = date.today()
53
+ now = datetime.now(tz)
54
+ time = now.strftime("%H:%M:%S %p")
55
+ await self.send_message(chat_id=LOG_CHANNEL, text=script.RESTART_TXT.format(today, time))
56
+ app = web.AppRunner(await web_server())
57
+ await app.setup()
58
+ bind_address = "0.0.0.0"
59
+ await web.TCPSite(app, bind_address, PORT).start()
60
+
61
+ async def stop(self, *args):
62
+ await super().stop()
63
+ logging.info("Bot stopped. Bye.")
64
+
65
+ async def iter_messages(
66
+ self,
67
+ chat_id: Union[int, str],
68
+ limit: int,
69
+ offset: int = 0,
70
+ ) -> Optional[AsyncGenerator["types.Message", None]]:
71
+ """Iterate through a chat sequentially.
72
+ This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving
73
+ you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a
74
+ single call.
75
+ Parameters:
76
+ chat_id (``int`` | ``str``):
77
+ Unique identifier (int) or username (str) of the target chat.
78
+ For your personal cloud (Saved Messages) you can simply use "me" or "self".
79
+ For a contact that exists in your Telegram address book you can use his phone number (str).
80
+
81
+ limit (``int``):
82
+ Identifier of the last message to be returned.
83
+
84
+ offset (``int``, *optional*):
85
+ Identifier of the first message to be returned.
86
+ Defaults to 0.
87
+ Returns:
88
+ ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.
89
+ Example:
90
+ .. code-block:: python
91
+ for message in app.iter_messages("pyrogram", 1, 15000):
92
+ print(message.text)
93
+ """
94
+ current = offset
95
+ while True:
96
+ new_diff = min(200, limit - current)
97
+ if new_diff <= 0:
98
+ return
99
+ messages = await self.get_messages(chat_id, list(range(current, current+new_diff+1)))
100
+ for message in messages:
101
+ yield message
102
+ current += 1
103
+
104
+
105
+ app = Bot()
106
+ app.run()
database/connections_mdb.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pymongo
2
+
3
+ from info import DATABASE_URI, DATABASE_NAME
4
+
5
+ import logging
6
+ logger = logging.getLogger(__name__)
7
+ logger.setLevel(logging.ERROR)
8
+
9
+ myclient = pymongo.MongoClient(DATABASE_URI)
10
+ mydb = myclient[DATABASE_NAME]
11
+ mycol = mydb['CONNECTION']
12
+
13
+
14
+ async def add_connection(group_id, user_id):
15
+ query = mycol.find_one(
16
+ { "_id": user_id },
17
+ { "_id": 0, "active_group": 0 }
18
+ )
19
+ if query is not None:
20
+ group_ids = [x["group_id"] for x in query["group_details"]]
21
+ if group_id in group_ids:
22
+ return False
23
+
24
+ group_details = {
25
+ "group_id" : group_id
26
+ }
27
+
28
+ data = {
29
+ '_id': user_id,
30
+ 'group_details' : [group_details],
31
+ 'active_group' : group_id,
32
+ }
33
+
34
+ if mycol.count_documents( {"_id": user_id} ) == 0:
35
+ try:
36
+ mycol.insert_one(data)
37
+ return True
38
+ except:
39
+ logger.exception('Some error occurred!', exc_info=True)
40
+
41
+ else:
42
+ try:
43
+ mycol.update_one(
44
+ {'_id': user_id},
45
+ {
46
+ "$push": {"group_details": group_details},
47
+ "$set": {"active_group" : group_id}
48
+ }
49
+ )
50
+ return True
51
+ except:
52
+ logger.exception('Some error occurred!', exc_info=True)
53
+
54
+
55
+ async def active_connection(user_id):
56
+
57
+ query = mycol.find_one(
58
+ { "_id": user_id },
59
+ { "_id": 0, "group_details": 0 }
60
+ )
61
+ if not query:
62
+ return None
63
+
64
+ group_id = query['active_group']
65
+ return int(group_id) if group_id != None else None
66
+
67
+
68
+ async def all_connections(user_id):
69
+ query = mycol.find_one(
70
+ { "_id": user_id },
71
+ { "_id": 0, "active_group": 0 }
72
+ )
73
+ if query is not None:
74
+ return [x["group_id"] for x in query["group_details"]]
75
+ else:
76
+ return None
77
+
78
+
79
+ async def if_active(user_id, group_id):
80
+ query = mycol.find_one(
81
+ { "_id": user_id },
82
+ { "_id": 0, "group_details": 0 }
83
+ )
84
+ return query is not None and query['active_group'] == group_id
85
+
86
+
87
+ async def make_active(user_id, group_id):
88
+ update = mycol.update_one(
89
+ {'_id': user_id},
90
+ {"$set": {"active_group" : group_id}}
91
+ )
92
+ return update.modified_count != 0
93
+
94
+
95
+ async def make_inactive(user_id):
96
+ update = mycol.update_one(
97
+ {'_id': user_id},
98
+ {"$set": {"active_group" : None}}
99
+ )
100
+ return update.modified_count != 0
101
+
102
+
103
+ async def delete_connection(user_id, group_id):
104
+
105
+ try:
106
+ update = mycol.update_one(
107
+ {"_id": user_id},
108
+ {"$pull" : { "group_details" : {"group_id":group_id} } }
109
+ )
110
+ if update.modified_count == 0:
111
+ return False
112
+ query = mycol.find_one(
113
+ { "_id": user_id },
114
+ { "_id": 0 }
115
+ )
116
+ if len(query["group_details"]) >= 1:
117
+ if query['active_group'] == group_id:
118
+ prvs_group_id = query["group_details"][len(query["group_details"]) - 1]["group_id"]
119
+
120
+ mycol.update_one(
121
+ {'_id': user_id},
122
+ {"$set": {"active_group" : prvs_group_id}}
123
+ )
124
+ else:
125
+ mycol.update_one(
126
+ {'_id': user_id},
127
+ {"$set": {"active_group" : None}}
128
+ )
129
+ return True
130
+ except Exception as e:
131
+ logger.exception(f'Some error occurred! {e}', exc_info=True)
132
+ return False
133
+
database/filters_mdb.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pymongo
2
+ from info import DATABASE_URI, DATABASE_NAME
3
+ from pyrogram import enums
4
+ import logging
5
+ logger = logging.getLogger(__name__)
6
+ logger.setLevel(logging.ERROR)
7
+
8
+ myclient = pymongo.MongoClient(DATABASE_URI)
9
+ mydb = myclient[DATABASE_NAME]
10
+
11
+
12
+
13
+ async def add_filter(grp_id, text, reply_text, btn, file, alert):
14
+ mycol = mydb[str(grp_id)]
15
+ # mycol.create_index([('text', 'text')])
16
+
17
+ data = {
18
+ 'text':str(text),
19
+ 'reply':str(reply_text),
20
+ 'btn':str(btn),
21
+ 'file':str(file),
22
+ 'alert':str(alert)
23
+ }
24
+
25
+ try:
26
+ mycol.update_one({'text': str(text)}, {"$set": data}, upsert=True)
27
+ except:
28
+ logger.exception('Some error occured!', exc_info=True)
29
+
30
+
31
+ async def find_filter(group_id, name):
32
+ mycol = mydb[str(group_id)]
33
+
34
+ query = mycol.find( {"text":name})
35
+ # query = mycol.find( { "$text": {"$search": name}})
36
+ try:
37
+ for file in query:
38
+ reply_text = file['reply']
39
+ btn = file['btn']
40
+ fileid = file['file']
41
+ try:
42
+ alert = file['alert']
43
+ except:
44
+ alert = None
45
+ return reply_text, btn, alert, fileid
46
+ except:
47
+ return None, None, None, None
48
+
49
+
50
+ async def get_filters(group_id):
51
+ mycol = mydb[str(group_id)]
52
+
53
+ texts = []
54
+ query = mycol.find()
55
+ try:
56
+ for file in query:
57
+ text = file['text']
58
+ texts.append(text)
59
+ except:
60
+ pass
61
+ return texts
62
+
63
+
64
+ async def delete_filter(message, text, group_id):
65
+ mycol = mydb[str(group_id)]
66
+
67
+ myquery = {'text':text }
68
+ query = mycol.count_documents(myquery)
69
+ if query == 1:
70
+ mycol.delete_one(myquery)
71
+ await message.reply_text(
72
+ f"'`{text}`' deleted. I'll not respond to that filter anymore.",
73
+ quote=True,
74
+ parse_mode=enums.ParseMode.MARKDOWN
75
+ )
76
+ else:
77
+ await message.reply_text("Couldn't find that filter!", quote=True)
78
+
79
+
80
+ async def del_all(message, group_id, title):
81
+ if str(group_id) not in mydb.list_collection_names():
82
+ await message.edit_text(f"Nothing to remove in {title}!")
83
+ return
84
+
85
+ mycol = mydb[str(group_id)]
86
+ try:
87
+ mycol.drop()
88
+ await message.edit_text(f"All filters from {title} has been removed")
89
+ except:
90
+ await message.edit_text("Couldn't remove all filters from group!")
91
+ return
92
+
93
+
94
+ async def count_filters(group_id):
95
+ mycol = mydb[str(group_id)]
96
+
97
+ count = mycol.count()
98
+ return False if count == 0 else count
99
+
100
+
101
+ async def filter_stats():
102
+ collections = mydb.list_collection_names()
103
+
104
+ if "CONNECTION" in collections:
105
+ collections.remove("CONNECTION")
106
+
107
+ totalcount = 0
108
+ for collection in collections:
109
+ mycol = mydb[collection]
110
+ count = mycol.count()
111
+ totalcount += count
112
+
113
+ totalcollections = len(collections)
114
+
115
+ return totalcollections, totalcount
database/gfilters_mdb.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pymongo
2
+ from info import DATABASE_URI, DATABASE_NAME
3
+ from pyrogram import enums
4
+ import logging
5
+ logger = logging.getLogger(__name__)
6
+ logger.setLevel(logging.ERROR)
7
+
8
+ myclient = pymongo.MongoClient(DATABASE_URI)
9
+ mydb = myclient[DATABASE_NAME]
10
+
11
+
12
+
13
+ async def add_gfilter(gfilters, text, reply_text, btn, file, alert):
14
+ mycol = mydb[str(gfilters)]
15
+ # mycol.create_index([('text', 'text')])
16
+
17
+ data = {
18
+ 'text':str(text),
19
+ 'reply':str(reply_text),
20
+ 'btn':str(btn),
21
+ 'file':str(file),
22
+ 'alert':str(alert)
23
+ }
24
+
25
+ try:
26
+ mycol.update_one({'text': str(text)}, {"$set": data}, upsert=True)
27
+ except:
28
+ logger.exception('Some error occured!', exc_info=True)
29
+
30
+
31
+ async def find_gfilter(gfilters, name):
32
+ mycol = mydb[str(gfilters)]
33
+
34
+ query = mycol.find( {"text":name})
35
+ # query = mycol.find( { "$text": {"$search": name}})
36
+ try:
37
+ for file in query:
38
+ reply_text = file['reply']
39
+ btn = file['btn']
40
+ fileid = file['file']
41
+ try:
42
+ alert = file['alert']
43
+ except:
44
+ alert = None
45
+ return reply_text, btn, alert, fileid
46
+ except:
47
+ return None, None, None, None
48
+
49
+
50
+ async def get_gfilters(gfilters):
51
+ mycol = mydb[str(gfilters)]
52
+
53
+ texts = []
54
+ query = mycol.find()
55
+ try:
56
+ for file in query:
57
+ text = file['text']
58
+ texts.append(text)
59
+ except:
60
+ pass
61
+ return texts
62
+
63
+
64
+ async def delete_gfilter(message, text, gfilters):
65
+ mycol = mydb[str(gfilters)]
66
+
67
+ myquery = {'text':text }
68
+ query = mycol.count_documents(myquery)
69
+ if query == 1:
70
+ mycol.delete_one(myquery)
71
+ await message.reply_text(
72
+ f"'`{text}`' deleted. I'll not respond to that gfilter anymore.",
73
+ quote=True,
74
+ parse_mode=enums.ParseMode.MARKDOWN
75
+ )
76
+ else:
77
+ await message.reply_text("Couldn't find that gfilter!", quote=True)
78
+
79
+ async def del_allg(message, gfilters):
80
+ if str(gfilters) not in mydb.list_collection_names():
81
+ await message.edit_text("Nothing to Remove !")
82
+ return
83
+
84
+ mycol = mydb[str(gfilters)]
85
+ try:
86
+ mycol.drop()
87
+ await message.edit_text(f"All gfilters has been removed !")
88
+ except:
89
+ await message.edit_text("Couldn't remove all gfilters !")
90
+ return
91
+
92
+ async def count_gfilters(gfilters):
93
+ mycol = mydb[str(gfilters)]
94
+
95
+ count = mycol.count()
96
+ return False if count == 0 else count
97
+
98
+
99
+ async def gfilter_stats():
100
+ collections = mydb.list_collection_names()
101
+
102
+ if "CONNECTION" in collections:
103
+ collections.remove("CONNECTION")
104
+
105
+ totalcount = 0
106
+ for collection in collections:
107
+ mycol = mydb[collection]
108
+ count = mycol.count()
109
+ totalcount += count
110
+
111
+ totalcollections = len(collections)
112
+
113
+ return totalcollections, totalcount
database/ia_filterdb.py ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ia_filterdb.py
2
+ import asyncio
3
+ from pyrogram import enums
4
+ from imdb import Cinemagoer
5
+ from pymongo.errors import DuplicateKeyError
6
+ from pyrogram.errors import UserNotParticipant
7
+ from motor.motor_asyncio import AsyncIOMotorClient
8
+ from pyrogram.types import ChatPermissions, InlineKeyboardMarkup, InlineKeyboardButton
9
+ import logging
10
+ from struct import pack
11
+ import re
12
+ import base64
13
+ from pyrogram.file_id import FileId
14
+ from imdb import Cinemagoer
15
+ from umongo import Instance, Document, fields
16
+ from motor.motor_asyncio import AsyncIOMotorClient
17
+ from marshmallow.exceptions import ValidationError
18
+ from info import DATABASE_URI, DATABASE_NAME, COLLECTION_NAME, USE_CAPTION_FILTER, MAX_B_TN
19
+ from utils import get_settings, save_group_settings
20
+
21
+ logger = logging.getLogger(__name__)
22
+ logger.setLevel(logging.INFO)
23
+
24
+
25
+ client = AsyncIOMotorClient(DATABASE_URI)
26
+ db = client[DATABASE_NAME]
27
+ db1 = client["F_SUB_DB"]
28
+ grp_col = db1["GROUPS"]
29
+ user_col = db1["USERS"]
30
+ dlt_col = db1["Auto-Delete"]
31
+
32
+ instance = Instance.from_db(db)
33
+
34
+ ia = Cinemagoer()
35
+
36
+ @instance.register
37
+ class Media(Document):
38
+ file_id = fields.StrField(attribute='_id')
39
+ file_ref = fields.StrField(allow_none=True)
40
+ file_name = fields.StrField(required=True)
41
+ file_size = fields.IntField(required=True)
42
+ file_type = fields.StrField(allow_none=True)
43
+ mime_type = fields.StrField(allow_none=True)
44
+ caption = fields.StrField(allow_none=True)
45
+
46
+ class Meta:
47
+ indexes = ('$file_name', )
48
+ collection_name = COLLECTION_NAME
49
+
50
+
51
+ async def save_file(media):
52
+ """Save file in database"""
53
+
54
+ # TODO: Find better way to get same file_id for same media to avoid duplicates
55
+ file_id, file_ref = unpack_new_file_id(media.file_id)
56
+ file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name))
57
+ try:
58
+ file = Media(
59
+ file_id=file_id,
60
+ file_ref=file_ref,
61
+ file_name=file_name,
62
+ file_size=media.file_size,
63
+ file_type=media.file_type,
64
+ mime_type=media.mime_type,
65
+ caption=media.caption.html if media.caption else None,
66
+ )
67
+ except ValidationError:
68
+ logger.exception('Error occurred while saving file in database')
69
+ return False, 2
70
+ else:
71
+ try:
72
+ await file.commit()
73
+ except DuplicateKeyError:
74
+ logger.warning(
75
+ f'{getattr(media, "file_name", "NO_FILE")} is already saved in database'
76
+ )
77
+
78
+ return False, 0
79
+ else:
80
+ logger.info(f'{getattr(media, "file_name", "NO_FILE")} is saved to database')
81
+ return True, 1
82
+
83
+
84
+
85
+ async def get_search_results(chat_id, query, file_type=None, max_results=10, offset=0, filter=False):
86
+ """For given query return (results, next_offset)"""
87
+ if chat_id is not None:
88
+ settings = await get_settings(int(chat_id))
89
+ try:
90
+ if settings['max_btn']:
91
+ max_results = 10
92
+ else:
93
+ max_results = int(MAX_B_TN)
94
+ except KeyError:
95
+ await save_group_settings(int(chat_id), 'max_btn', False)
96
+ settings = await get_settings(int(chat_id))
97
+ if settings['max_btn']:
98
+ max_results = 10
99
+ else:
100
+ max_results = int(MAX_B_TN)
101
+ query = query.strip()
102
+ #if filter:
103
+ #better ?
104
+ #query = query.replace(' ', r'(\s|\.|\+|\-|_)')
105
+ #raw_pattern = r'(\s|_|\-|\.|\+)' + query + r'(\s|_|\-|\.|\+)'
106
+ if not query:
107
+ raw_pattern = '.'
108
+ elif ' ' not in query:
109
+ raw_pattern = r'(\b|[\.\+\-_])' + query + r'(\b|[\.\+\-_])'
110
+ else:
111
+ raw_pattern = query.replace(' ', r'.*[\s\.\+\-_]')
112
+
113
+ try:
114
+ regex = re.compile(raw_pattern, flags=re.IGNORECASE)
115
+ except:
116
+ return []
117
+
118
+ if USE_CAPTION_FILTER:
119
+ filter = {'$or': [{'file_name': regex}, {'caption': regex}]}
120
+ else:
121
+ filter = {'file_name': regex}
122
+
123
+ if file_type:
124
+ filter['file_type'] = file_type
125
+
126
+ total_results = await Media.count_documents(filter)
127
+ next_offset = offset + max_results
128
+
129
+ if next_offset > total_results:
130
+ next_offset = ''
131
+
132
+ cursor = Media.find(filter)
133
+ # Sort by recent
134
+ cursor.sort('$natural', -1)
135
+ # Slice files according to offset and max results
136
+ cursor.skip(offset).limit(max_results)
137
+ # Get list of files
138
+ files = await cursor.to_list(length=max_results)
139
+
140
+ return files, next_offset, total_results
141
+
142
+ async def get_bad_files(query, file_type=None, filter=False):
143
+ """For given query return (results, next_offset)"""
144
+ query = query.strip()
145
+ #if filter:
146
+ #better ?
147
+ #query = query.replace(' ', r'(\s|\.|\+|\-|_)')
148
+ #raw_pattern = r'(\s|_|\-|\.|\+)' + query + r'(\s|_|\-|\.|\+)'
149
+ if not query:
150
+ raw_pattern = '.'
151
+ elif ' ' not in query:
152
+ raw_pattern = r'(\b|[\.\+\-_])' + query + r'(\b|[\.\+\-_])'
153
+ else:
154
+ raw_pattern = query.replace(' ', r'.*[\s\.\+\-_]')
155
+
156
+ try:
157
+ regex = re.compile(raw_pattern, flags=re.IGNORECASE)
158
+ except:
159
+ return []
160
+
161
+ if USE_CAPTION_FILTER:
162
+ filter = {'$or': [{'file_name': regex}, {'caption': regex}]}
163
+ else:
164
+ filter = {'file_name': regex}
165
+
166
+ if file_type:
167
+ filter['file_type'] = file_type
168
+
169
+ total_results = await Media.count_documents(filter)
170
+
171
+ cursor = Media.find(filter)
172
+ # Sort by recent
173
+ cursor.sort('$natural', -1)
174
+ # Get list of files
175
+ files = await cursor.to_list(length=total_results)
176
+
177
+ return files, total_results
178
+
179
+ async def get_file_details(query):
180
+ filter = {'file_id': query}
181
+ cursor = Media.find(filter)
182
+ filedetails = await cursor.to_list(length=1)
183
+ return filedetails
184
+
185
+
186
+ def encode_file_id(s: bytes) -> str:
187
+ r = b""
188
+ n = 0
189
+
190
+ for i in s + bytes([22]) + bytes([4]):
191
+ if i == 0:
192
+ n += 1
193
+ else:
194
+ if n:
195
+ r += b"\x00" + bytes([n])
196
+ n = 0
197
+
198
+ r += bytes([i])
199
+
200
+ return base64.urlsafe_b64encode(r).decode().rstrip("=")
201
+
202
+
203
+ def encode_file_ref(file_ref: bytes) -> str:
204
+ return base64.urlsafe_b64encode(file_ref).decode().rstrip("=")
205
+
206
+
207
+ def unpack_new_file_id(new_file_id):
208
+ """Return file_id, file_ref"""
209
+ decoded = FileId.decode(new_file_id)
210
+ file_id = encode_file_id(
211
+ pack(
212
+ "<iiqq",
213
+ int(decoded.file_type),
214
+ decoded.dc_id,
215
+ decoded.media_id,
216
+ decoded.access_hash
217
+ )
218
+ )
219
+ file_ref = encode_file_ref(decoded.file_reference)
220
+ return file_id, file_ref
221
+
222
+ async def add_group(group_id, group_name, user_name, user_id, channels, f_sub, verified):
223
+ data = {"_id": group_id, "name":group_name,
224
+ "user_id":user_id, "user_name":user_name,
225
+ "channels":channels, "f_sub":f_sub, "verified":verified}
226
+ try:
227
+ await grp_col.insert_one(data)
228
+ except DuplicateKeyError:
229
+ pass
230
+
231
+ async def get_group(id):
232
+ data = {'_id':id}
233
+ group = await grp_col.find_one(data)
234
+ return dict(group)
235
+
236
+ async def update_group(id, new_data):
237
+ data = {"_id":id}
238
+ new_value = {"$set": new_data}
239
+ await grp_col.update_one(data, new_value)
240
+
241
+ async def delete_group(id):
242
+ data = {"_id":id}
243
+ await grp_col.delete_one(data)
244
+
245
+ async def get_groups():
246
+ count = await grp_col.count_documents({})
247
+ cursor = grp_col.find({})
248
+ list = await cursor.to_list(length=int(count))
249
+ return count, list
250
+
251
+ async def add_user(id, name):
252
+ data = {"_id":id, "name":name}
253
+ try:
254
+ await user_col.insert_one(data)
255
+ except DuplicateKeyError:
256
+ pass
257
+
258
+ async def get_users():
259
+ count = await user_col.count_documents({})
260
+ cursor = user_col.find({})
261
+ list = await cursor.to_list(length=int(count))
262
+ return count, list
263
+
264
+ async def save_dlt_message(message, time):
265
+ data = {"chat_id": message.chat.id,
266
+ "message_id": message.id,
267
+ "time": time}
268
+ await dlt_col.insert_one(data)
269
+
270
+ async def get_all_dlt_data(time):
271
+ data = {"time":{"$lte":time}}
272
+ count = await dlt_col.count_documents(data)
273
+ cursor = dlt_col.find(data)
274
+ all_data = await cursor.to_list(length=int(count))
275
+ return all_data
276
+
277
+ async def delete_all_dlt_data(time):
278
+ data = {"time":{"$lte":time}}
279
+ await dlt_col.delete_many(data)
280
+
281
+ async def search_imdb(query):
282
+ try:
283
+ int(query)
284
+ movie = ia.get_movie(query)
285
+ return movie["title"]
286
+ except:
287
+ movies = ia.search_movie(query, results=10)
288
+ list = []
289
+ for movie in movies:
290
+ title = movie["title"]
291
+ try: year = f" - {movie['year']}"
292
+ except: year = ""
293
+ list.append({"title":title, "year":year, "id":movie.movieID})
294
+ return list
295
+
296
+ async def force_sub(bot, message):
297
+ group = await get_group(message.chat.id)
298
+ f_sub = group["f_sub"]
299
+ admin = group["user_id"]
300
+ if f_sub==False:
301
+ return True
302
+ if message.from_user is None:
303
+ return True
304
+ try:
305
+ f_link = (await bot.get_chat(f_sub)).invite_link
306
+ member = await bot.get_chat_member(f_sub, message.from_user.id)
307
+ if member.status==enums.ChatMemberStatus.BANNED:
308
+ await message.reply(f"Sorry {message.from_user.mention}!\n You are banned in our channel, you will be banned from here within 10 seconds")
309
+ await asyncio.sleep(10)
310
+ await bot.ban_chat_member(message.chat.id, message.from_user.id)
311
+ return False
312
+ except UserNotParticipant:
313
+ try:
314
+ await bot.restrict_chat_member(chat_id=message.chat.id,
315
+ user_id=message.from_user.id,
316
+ permissions=ChatPermissions(can_send_messages=False,
317
+ can_invite_users=True)
318
+ )
319
+ k = await message.reply(f"<b>⚠ Dear User {message.from_user.mention}!\n\nTo Send message here, You have to join our channel </b>", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Join Channel", url=f_link)], [InlineKeyboardButton("Try Again", callback_data=f"checksub_{message.from_user.id}")]]))
320
+ await message.delete()
321
+ await asyncio.sleep(60)
322
+ await bot.restrict_chat_member(chat_id=message.chat.id,
323
+ user_id=message.from_user.id,
324
+ permissions=ChatPermissions(can_send_messages=True,
325
+ can_invite_users=True)
326
+ )
327
+ await k.delete()
328
+ except:
329
+ k = await message.reply(f"<b>⚠ Dear User {message.from_user.mention}!\n\nTo Send message here, You have to join our channel </b>", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Join Channel", url=f_link)], [InlineKeyboardButton("Try Again", callback_data=f"checksub_{message.from_user.id}")]]))
330
+ await message.delete()
331
+ await asyncio.sleep(60)
332
+ await k.delete()
333
+ return False
334
+ except Exception as e:
335
+ await bot.send_message(chat_id=admin, text=f"❌ Error in Fsub:\n`{str(e)}`")
336
+ return False
337
+ else:
338
+ return True
database/join_reqs.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # (c) @AlbertEinsteinTG
4
+
5
+ import motor.motor_asyncio
6
+ from info import REQ_CHANNEL
7
+
8
+ class JoinReqs:
9
+
10
+ def __init__(self):
11
+ from info import JOIN_REQS_DB
12
+ if JOIN_REQS_DB:
13
+ self.client = motor.motor_asyncio.AsyncIOMotorClient(JOIN_REQS_DB)
14
+ self.db = self.client["JoinReqs"]
15
+ self.col = self.db[str(REQ_CHANNEL)]
16
+ else:
17
+ self.client = None
18
+ self.db = None
19
+ self.col = None
20
+
21
+ def isActive(self):
22
+ if self.client is not None:
23
+ return True
24
+ else:
25
+ return False
26
+
27
+ async def add_user(self, user_id, first_name, username, date):
28
+ try:
29
+ await self.col.insert_one({"_id": int(user_id),"user_id": int(user_id), "first_name": first_name, "username": username, "date": date})
30
+ except:
31
+ pass
32
+
33
+ async def get_user(self, user_id):
34
+ return await self.col.find_one({"user_id": int(user_id)})
35
+
36
+ async def get_all_users(self):
37
+ return await self.col.find().to_list(None)
38
+
39
+ async def delete_user(self, user_id):
40
+ await self.col.delete_one({"user_id": int(user_id)})
41
+
42
+ async def delete_all_users(self):
43
+ await self.col.delete_many({})
44
+
45
+ async def get_all_users_count(self):
46
+ return await self.col.count_documents({})
database/users_chats_db.py ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://github.com/odysseusmax/animated-lamp/blob/master/bot/database/database.py
2
+ #Users_Chats_db
3
+ import motor.motor_asyncio
4
+ from info import DATABASE_NAME, DATABASE_URI, IMDB, IMDB_TEMPLATE, MELCOW_NEW_USERS, P_TTI_SHOW_OFF, SINGLE_BUTTON, SPELL_CHECK_REPLY, PROTECT_CONTENT, AUTO_DELETE, MAX_BTN, AUTO_FFILTER, SHORTLINK_API, SHORTLINK_URL, IS_SHORTLINK, TUTORIAL, IS_TUTORIAL
5
+ import datetime
6
+ import pytz
7
+
8
+ class Database:
9
+
10
+ def __init__(self, uri, database_name):
11
+ self._client = motor.motor_asyncio.AsyncIOMotorClient(uri)
12
+ self.db = self._client[database_name]
13
+ self.col = self.db.users
14
+ self.grp = self.db.groups
15
+ self.misc = self.db.misc
16
+ self.verify_id = self.db.verify_id
17
+
18
+ def new_user(self, id, name):
19
+ return dict(
20
+ id = id,
21
+ name = name,
22
+ ban_status=dict(
23
+ is_banned=False,
24
+ ban_reason="",
25
+ ),
26
+ )
27
+
28
+
29
+ def new_group(self, id, title):
30
+ return dict(
31
+ id = id,
32
+ title = title,
33
+ chat_status=dict(
34
+ is_disabled=False,
35
+ reason="",
36
+ ),
37
+ )
38
+
39
+ async def add_user(self, id, name):
40
+ user = self.new_user(id, name)
41
+ await self.col.insert_one(user)
42
+
43
+ async def is_user_exist(self, id):
44
+ user = await self.col.find_one({'id':int(id)})
45
+ return bool(user)
46
+
47
+ async def total_users_count(self):
48
+ count = await self.col.count_documents({})
49
+ return count
50
+
51
+ async def remove_ban(self, id):
52
+ ban_status = dict(
53
+ is_banned=False,
54
+ ban_reason=''
55
+ )
56
+ await self.col.update_one({'id': id}, {'$set': {'ban_status': ban_status}})
57
+
58
+ async def ban_user(self, user_id, ban_reason="No Reason"):
59
+ ban_status = dict(
60
+ is_banned=True,
61
+ ban_reason=ban_reason
62
+ )
63
+ await self.col.update_one({'id': user_id}, {'$set': {'ban_status': ban_status}})
64
+
65
+ async def get_ban_status(self, id):
66
+ default = dict(
67
+ is_banned=False,
68
+ ban_reason=''
69
+ )
70
+ user = await self.col.find_one({'id':int(id)})
71
+ if not user:
72
+ return default
73
+ return user.get('ban_status', default)
74
+
75
+ async def get_all_users(self):
76
+ return self.col.find({})
77
+
78
+
79
+ async def delete_user(self, user_id):
80
+ await self.col.delete_many({'id': int(user_id)})
81
+
82
+
83
+ async def get_banned(self):
84
+ users = self.col.find({'ban_status.is_banned': True})
85
+ chats = self.grp.find({'chat_status.is_disabled': True})
86
+ b_chats = [chat['id'] async for chat in chats]
87
+ b_users = [user['id'] async for user in users]
88
+ return b_users, b_chats
89
+
90
+
91
+
92
+ async def add_chat(self, chat, title):
93
+ chat = self.new_group(chat, title)
94
+ await self.grp.insert_one(chat)
95
+
96
+
97
+ async def get_chat(self, chat):
98
+ chat = await self.grp.find_one({'id':int(chat)})
99
+ return False if not chat else chat.get('chat_status')
100
+
101
+
102
+ async def re_enable_chat(self, id):
103
+ chat_status=dict(
104
+ is_disabled=False,
105
+ reason="",
106
+ )
107
+ await self.grp.update_one({'id': int(id)}, {'$set': {'chat_status': chat_status}})
108
+
109
+ async def update_settings(self, id, settings):
110
+ await self.grp.update_one({'id': int(id)}, {'$set': {'settings': settings}})
111
+
112
+
113
+ async def get_settings(self, id):
114
+ default = {
115
+ 'button': SINGLE_BUTTON,
116
+ 'botpm': P_TTI_SHOW_OFF,
117
+ 'file_secure': PROTECT_CONTENT,
118
+ 'imdb': IMDB,
119
+ 'spell_check': SPELL_CHECK_REPLY,
120
+ 'welcome': MELCOW_NEW_USERS,
121
+ 'auto_delete': AUTO_DELETE,
122
+ 'auto_ffilter': AUTO_FFILTER,
123
+ 'max_btn': MAX_BTN,
124
+ 'template': IMDB_TEMPLATE,
125
+ 'shortlink': SHORTLINK_URL,
126
+ 'shortlink_api': SHORTLINK_API,
127
+ 'is_shortlink': IS_SHORTLINK,
128
+ 'tutorial': TUTORIAL,
129
+ 'is_tutorial': IS_TUTORIAL
130
+ }
131
+ chat = await self.grp.find_one({'id':int(id)})
132
+ if chat:
133
+ return chat.get('settings', default)
134
+ return default
135
+
136
+
137
+ async def disable_chat(self, chat, reason="No Reason"):
138
+ chat_status=dict(
139
+ is_disabled=True,
140
+ reason=reason,
141
+ )
142
+ await self.grp.update_one({'id': int(chat)}, {'$set': {'chat_status': chat_status}})
143
+
144
+
145
+ async def total_chat_count(self):
146
+ count = await self.grp.count_documents({})
147
+ return count
148
+
149
+
150
+ async def get_all_chats(self):
151
+ return self.grp.find({})
152
+
153
+
154
+ async def get_db_size(self):
155
+ return (await self.db.command("dbstats"))['dataSize']
156
+
157
+ async def get_notcopy_user(self, user_id):
158
+ user_id = int(user_id)
159
+
160
+ user = await self.misc.find_one({"user_id": user_id})
161
+ ist_timezone = pytz.timezone('Asia/Kolkata')
162
+
163
+ if not user:
164
+ res = {
165
+ "user_id": user_id,
166
+ "last_verified": datetime.datetime(2020, 5, 17, 0, 0, 0, tzinfo=ist_timezone),
167
+ }
168
+
169
+ user = await self.misc.insert_one(res)
170
+
171
+ return user
172
+
173
+ async def update_notcopy_user(self, user_id, value:dict):
174
+ user_id = int(user_id)
175
+ myquery = {"user_id": user_id}
176
+ newvalues = { "$set": value }
177
+ await self.misc.update_one(myquery, newvalues)
178
+
179
+ async def is_user_verified(self, user_id):
180
+ """
181
+ The user object is retrieved using the get_notcopy_user() method, which takes a user_id as an argument and returns a user object containing information about the user.
182
+ The pastDate variable is set to the value of the last_verified field in the user object. If this field is not present in the user object, an Exception is raised and the user object is retrieved again using the get_notcopy_user() method.
183
+ The ist_timezone variable is set to the time zone for India Standard Time.
184
+ The pastDate variable is converted to the India Standard Time time zone using the .astimezone() method.
185
+ The current_time variable is set to the current time in the India Standard Time time zone using the datetime.now() method.
186
+ The seconds_since_midnight variable is set to the total number of seconds since midnight of the current day in the India Standard Time time zone. This is calculated by taking the difference between the current time and a datetime instance representing midnight of the current day in the India Standard Time time zone.
187
+ The time_diff variable is set to the difference between the current_time and the pastDate variables. This is a timedelta instance representing the amount of time that has elapsed between the two times.
188
+ The total_seconds variable is set to the total number of seconds represented by the time_diff timedelta instance. This is calculated using the .total_seconds() method.
189
+ The code returns True if the total_seconds is less than or equal to the seconds_since_midnight, and False otherwise. This indicates whether the pastDate time is within the same day as the current time.
190
+
191
+ :param user_id: The user's ID
192
+ :return: The number of seconds since the user was last verified.
193
+ """
194
+ user = await self.get_notcopy_user(user_id)
195
+
196
+ try:
197
+ pastDate = user["last_verified"]
198
+ except Exception:
199
+ user = await self.get_notcopy_user(user_id)
200
+ pastDate = user["last_verified"]
201
+
202
+ ist_timezone = pytz.timezone('Asia/Kolkata')
203
+ pastDate = pastDate.astimezone(ist_timezone)
204
+ pastDate = pastDate + datetime.timedelta(hours=24)
205
+ current_time = datetime.datetime.now(tz=ist_timezone)
206
+
207
+ # seconds_since_midnight = (current_time - datetime.datetime(current_time.year, current_time.month, current_time.day, 0, 0, 0, tzinfo=ist_timezone)).total_seconds()
208
+
209
+ # Calculate the difference between the two times
210
+ # time_diff = current_time - pastDate
211
+ # Get the total number of seconds between the two times
212
+ # total_seconds = time_diff.total_seconds()
213
+ return current_time <= pastDate
214
+
215
+ async def create_verify_id(self, user_id: int, hash):
216
+ res = {"user_id": user_id, "hash":hash, "verified":False}
217
+ return await self.verify_id.insert_one(res)
218
+
219
+ async def get_verify_id_info(self, user_id: int, hash):
220
+ return await self.verify_id.find_one({"user_id": user_id, "hash": hash})
221
+
222
+ async def update_verify_id_info(self, user_id, hash, value: dict):
223
+ myquery = {"user_id": user_id, "hash": hash}
224
+ newvalues = { "$set": value }
225
+ return await self.verify_id.update_one(myquery, newvalues)
226
+
227
+ db = Database(DATABASE_URI, DATABASE_NAME)
docker-compose.yml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3.8"
2
+ services:
3
+ worker:
4
+ build: .
5
+ environment:
6
+ BOT_TOKEN: $BOT_TOKEN
7
+ API_ID: $API_ID
8
+ API_HASH: $API_HASH
9
+ CHANNELS: $CHANNELS
10
+ ADMINS: $ADMINS
11
+ LOG_CHANNEL: $LOG_CHANNEL
12
+ DATABASE_NAME: $DATABASE_NAME
13
+ DATABASE_URI: $DATABASE_URI
14
+ HEROKU_API_KEY: $HEROKU_API_KEY
heroku.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ build:
2
+ docker:
3
+ worker: Dockerfile
info.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from os import environ
3
+ from Script import script
4
+
5
+ id_pattern = re.compile(r'^.\d+$')
6
+ def is_enabled(value, default):
7
+ if value.lower() in ["true", "yes", "1", "enable", "y"]:
8
+ return True
9
+ elif value.lower() in ["false", "no", "0", "disable", "n"]:
10
+ return False
11
+ else:
12
+ return default
13
+
14
+ # Bot information
15
+ SESSION = environ.get('SESSION', 'Media_search')
16
+ API_ID = int(environ.get('API_ID', '28888474'))
17
+ API_HASH = environ.get('API_HASH', 'a89f231abefe45692ae2e921c8659b7d')
18
+ BOT_TOKEN = environ.get('BOT_TOKEN', "5979446945:AAG7SFjxUsdIIe02dz9OLo2--bA8eZ9mV6U")
19
+
20
+ # Bot settings
21
+ CACHE_TIME = int(environ.get('CACHE_TIME', 300))
22
+ USE_CAPTION_FILTER = bool(environ.get('USE_CAPTION_FILTER', True))
23
+
24
+ PICS = (environ.get('PICS', 'https://te.legra.ph/file/cce1c345a4a752453a3a3.jpg https://telegra.ph/file/29bc7f30cd147351eb382.jpg https://telegra.ph/file/ca9e882b9f802c338df5b.jpg https://telegra.ph/file/ca6ff682e37dd394ab33b.jpg https://telegra.ph/file/0f7371846cf0e84766c4a.jpg https://telegra.ph/file/1619aba10a6418de3f0e9.jpg https://telegra.ph/file/c1449e2c65c655c0a3b9b.jpg https://telegra.ph/file/ba6ccb9e1fadc405e331c.jpg https://telegra.ph/file/1fc94a48a13aecad89040.jpg https://telegra.ph/file/810ef47b67543fca27451.jpg https://telegra.ph/file/321e3e560f810f01a40ed.jpg https://telegra.ph/file/ab1fd8a644c5c99c1df37.jpg https://telegra.ph/file/c30d4ac307cbe1879da6d.jpg https://telegra.ph/file/d208ed40085cf520758e0.jpg https://telegra.ph/file/4ed762d7dadb3105055d2.jpg https://telegra.ph/file/1391a72c8cbac5bf24e82.jpg https://telegra.ph/file/305f9a35edac3f3374d8e.jpg https://telegra.ph/file/296366c942ea5f7fa303a.jpg https://telegra.ph/file/22dee33038d8b6f110c70.jpg https://telegra.ph/file/8d1067866eed68e1255a4.jpg')).split()
25
+ NOR_IMG = environ.get("NOR_IMG", "https://te.legra.ph/file/a27dc8fe434e6b846b0f8.jpg")
26
+ MELCOW_VID = environ.get("MELCOW_VID", "https://te.legra.ph/file/6f55d902f9bf2d0afd4bb.mp4")
27
+ SPELL_IMG = environ.get("SPELL_IMG", "https://te.legra.ph/file/15c1ad448dfe472a5cbb8.jpg")
28
+
29
+ # MongoDB information
30
+ DATABASE_URI = environ.get('DATABASE_URI', "mongodb+srv://TTBots:1234@cluster0.ymqvecu.mongodb.net/?retryWrites=true&w=majority")
31
+ DATABASE_NAME = environ.get('DATABASE_NAME', "Autosearchtamil")
32
+ COLLECTION_NAME = environ.get('COLLECTION_NAME', 'Telegram_files')
33
+
34
+ # Admins, Channels & Users
35
+ ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '1838498574').split()]
36
+ CHANNELS = [int(ch) if id_pattern.search(ch) else ch for ch in environ.get('CHANNELS', '-1001611072522 -1001821933278 -1001833580627').split()]
37
+ auth_users = [int(user) if id_pattern.search(user) else user for user in environ.get('AUTH_USERS', '').split()]
38
+ AUTH_USERS = (auth_users + ADMINS) if auth_users else []
39
+ PREMIUM_USER = [int(user) if id_pattern.search(user) else user for user in environ.get('PREMIUM_USER', '1246727616').split()]
40
+ auth_channel = environ.get('AUTH_CHANNEL')
41
+ auth_grp = environ.get('AUTH_GROUP')
42
+ AUTH_CHANNEL = int(auth_channel) if auth_channel and id_pattern.search(auth_channel) else None
43
+ AUTH_GROUPS = [int(ch) for ch in auth_grp.split()] if auth_grp else None
44
+ support_chat_id = environ.get('SUPPORT_CHAT_ID', '-1001268015736')
45
+ reqst_channel = environ.get('REQST_CHANNEL_ID', '-1001984041373')
46
+ REQST_CHANNEL = int(reqst_channel) if reqst_channel and id_pattern.search(reqst_channel) else None
47
+ SUPPORT_CHAT_ID = int(support_chat_id) if support_chat_id and id_pattern.search(support_chat_id) else None
48
+ NO_RESULTS_MSG = bool(environ.get("NO_RESULTS_MSG", False))
49
+ REQ_CHANNEL = environ.get("REQ_CHANNEL", False)
50
+ REQ_CHANNEL = int(REQ_CHANNEL) if REQ_CHANNEL and id_pattern.search(REQ_CHANNEL) else False
51
+ JOIN_REQS_DB = environ.get("JOIN_REQS_DB", DATABASE_URI)
52
+ #group_sub = environ.get('GROUP_SUB')
53
+ #GROUP_SUB = int(group_sub) if auth_channel and id_pattern.search(group_sub) else None
54
+
55
+ # Others
56
+ VERIFY = bool(environ.get('VERIFY', False))
57
+ SHORTLINK_URL = environ.get('SHORTLINK_URL', 'mplaylink.com')
58
+ SHORTLINK_API = environ.get('SHORTLINK_API', '1f1da5c9df9a58058672ac8d8134e203b03426a1')
59
+ SECOND_SHORTLINK_URL = environ.get('SECOND_SHORTLINK_URL', 'mplaylink.com')
60
+ SECOND_SHORTLINK_API = environ.get('SECOND_SHORTLINK_API', '1f1da5c9df9a58058672ac8d8134e203b03426a1')
61
+ IS_SHORTLINK = bool(environ.get('IS_SHORTLINK', True))
62
+ DELETE_CHANNELS = [int(dch) if id_pattern.search(dch) else dch for dch in environ.get('DELETE_CHANNELS', '-1001869007828').split()]
63
+ MAX_B_TN = environ.get("MAX_B_TN", "5")
64
+ MAX_BTN = is_enabled((environ.get('MAX_BTN', "True")), True)
65
+ PORT = environ.get("PORT", "8080")
66
+ GRP_LNK = environ.get('GRP_LNK', 'https://t.me/+ps2An00KwZYwNTRl')
67
+ CHNL_LNK = environ.get('CHNL_LNK', 'https://t.me/TeamHMT_Bots')
68
+ TUTORIAL = environ.get('TUTORIAL', 'https://t.me/Team_HMT/8')
69
+ IS_TUTORIAL = bool(environ.get('IS_TUTORIAL', True))
70
+ MSG_ALRT = environ.get('MSG_ALRT', 'Wʜᴀᴛ Aʀᴇ Yᴏᴜ Lᴏᴏᴋɪɴɢ Aᴛ ?')
71
+ LOG_CHANNEL = int(environ.get('LOG_CHANNEL', '-1001837909538'))
72
+ SUPPORT_CHAT = environ.get('SUPPORT_CHAT', '+r9ArDaaCETE0OGU9')
73
+ P_TTI_SHOW_OFF = is_enabled((environ.get('P_TTI_SHOW_OFF', "False")), False)
74
+ IMDB = is_enabled((environ.get('IMDB', "True")), True)
75
+ AUTO_FFILTER = is_enabled((environ.get('AUTO_FFILTER', "True")), True)
76
+ AUTO_DELETE = is_enabled((environ.get('AUTO_DELETE', "True")), True)
77
+ SINGLE_BUTTON = is_enabled((environ.get('SINGLE_BUTTON', "True")), True)
78
+ CUSTOM_FILE_CAPTION = environ.get("CUSTOM_FILE_CAPTION", f"{script.CAPTION}")
79
+ BATCH_FILE_CAPTION = environ.get("BATCH_FILE_CAPTION", CUSTOM_FILE_CAPTION)
80
+ IMDB_TEMPLATE = environ.get("IMDB_TEMPLATE", f"{script.IMDB_TEMPLATE_TXT}")
81
+ LONG_IMDB_DESCRIPTION = is_enabled(environ.get("LONG_IMDB_DESCRIPTION", "False"), False)
82
+ SPELL_CHECK_REPLY = is_enabled(environ.get("SPELL_CHECK_REPLY", "True"), True)
83
+ MAX_LIST_ELM = environ.get("MAX_LIST_ELM", None)
84
+ INDEX_REQ_CHANNEL = int(environ.get('INDEX_REQ_CHANNEL', LOG_CHANNEL))
85
+ FILE_STORE_CHANNEL = [int(ch) for ch in (environ.get('FILE_STORE_CHANNEL', '')).split()]
86
+ MELCOW_NEW_USERS = is_enabled((environ.get('MELCOW_NEW_USERS', "True")), True)
87
+ PROTECT_CONTENT = is_enabled((environ.get('PROTECT_CONTENT', "False")), False)
88
+ PUBLIC_FILE_STORE = is_enabled((environ.get('PUBLIC_FILE_STORE', "True")), True)
89
+
90
+ LANGUAGES = ["malayalam", "mal", "tamil", "tam" ,"english", "eng", "hindi", "hin", "telugu", "tel", "kannada", "kan"]
91
+
92
+ SEASONS = ["season 1" , "season 2" , "season 3" , "season 4", "season 5" , "season 6" , "season 7" , "season 8" , "season 9" , "season 10"]
93
+
94
+ LOG_STR = "Current Cusomized Configurations are:-\n"
95
+ LOG_STR += ("IMDB Results are enabled, Bot will be showing imdb details for you queries.\n" if IMDB else "IMBD Results are disabled.\n")
96
+ LOG_STR += ("P_TTI_SHOW_OFF found , Users will be redirected to send /start to Bot PM instead of sending file file directly\n" if P_TTI_SHOW_OFF else "P_TTI_SHOW_OFF is disabled files will be send in PM, instead of sending start.\n")
97
+ LOG_STR += ("SINGLE_BUTTON is Found, filename and files size will be shown in a single button instead of two separate buttons\n" if SINGLE_BUTTON else "SINGLE_BUTTON is disabled , filename and file_sixe will be shown as different buttons\n")
98
+ LOG_STR += (f"CUSTOM_FILE_CAPTION enabled with value {CUSTOM_FILE_CAPTION}, your files will be send along with this customized caption.\n" if CUSTOM_FILE_CAPTION else "No CUSTOM_FILE_CAPTION Found, Default captions of file will be used.\n")
99
+ LOG_STR += ("Long IMDB storyline enabled." if LONG_IMDB_DESCRIPTION else "LONG_IMDB_DESCRIPTION is disabled , Plot will be shorter.\n")
100
+ LOG_STR += ("Spell Check Mode Is Enabled, bot will be suggesting related movies if movie not found\n" if SPELL_CHECK_REPLY else "SPELL_CHECK_REPLY Mode disabled\n")
101
+ LOG_STR += (f"MAX_LIST_ELM Found, long list will be shortened to first {MAX_LIST_ELM} elements\n" if MAX_LIST_ELM else "Full List of casts and crew will be shown in imdb template, restrict them by adding a value to MAX_LIST_ELM\n")
102
+ LOG_STR += f"Your current IMDB template is {IMDB_TEMPLATE}"
logging.conf ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [loggers]
2
+ keys=root
3
+
4
+ [handlers]
5
+ keys=consoleHandler,fileHandler
6
+
7
+ [formatters]
8
+ keys=consoleFormatter,fileFormatter
9
+
10
+ [logger_root]
11
+ level=DEBUG
12
+ handlers=consoleHandler,fileHandler
13
+
14
+ [handler_consoleHandler]
15
+ class=StreamHandler
16
+ level=INFO
17
+ formatter=consoleFormatter
18
+ args=(sys.stdout,)
19
+
20
+ [handler_fileHandler]
21
+ class=FileHandler
22
+ level=ERROR
23
+ formatter=fileFormatter
24
+ args=('Logs.txt','w',)
25
+
26
+ [formatter_consoleFormatter]
27
+ format=%(asctime)s - %(lineno)d - %(name)s - %(module)s - %(levelname)s - %(message)s
28
+ datefmt=%I:%M:%S %p
29
+
30
+ [formatter_fileFormatter]
31
+ format=[%(asctime)s:%(name)s:%(lineno)d:%(levelname)s] %(message)s
32
+ datefmt=%m/%d/%Y %I:%M:%S %p
plugins/__init__.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from aiohttp import web
2
+ from .route import routes
3
+
4
+
5
+ async def web_server():
6
+ web_app = web.Application(client_max_size=30000000)
7
+ web_app.add_routes(routes)
8
+ return web_app
plugins/banned.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyrogram import Client, filters
2
+ from utils import temp
3
+ from pyrogram.types import Message
4
+ from database.users_chats_db import db
5
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
6
+ from info import SUPPORT_CHAT
7
+
8
+ async def banned_users(_, client, message: Message):
9
+ return (
10
+ message.from_user is not None or not message.sender_chat
11
+ ) and message.from_user.id in temp.BANNED_USERS
12
+
13
+ banned_user = filters.create(banned_users)
14
+
15
+ async def disabled_chat(_, client, message: Message):
16
+ return message.chat.id in temp.BANNED_CHATS
17
+
18
+ disabled_group=filters.create(disabled_chat)
19
+
20
+
21
+ @Client.on_message(filters.private & banned_user & filters.incoming)
22
+ async def ban_reply(bot, message):
23
+ ban = await db.get_ban_status(message.from_user.id)
24
+ await message.reply(f'Sorry Dude, You are Banned to use Me. \nBan Reason: {ban["ban_reason"]}')
25
+
26
+ @Client.on_message(filters.group & disabled_group & filters.incoming)
27
+ async def grp_bd(bot, message):
28
+ buttons = [[
29
+ InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}')
30
+ ]]
31
+ reply_markup=InlineKeyboardMarkup(buttons)
32
+ vazha = await db.get_chat(message.chat.id)
33
+ k = await message.reply(
34
+ text=f"CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..\nReason : <code>{vazha['reason']}</code>.",
35
+ reply_markup=reply_markup)
36
+ try:
37
+ await k.pin()
38
+ except:
39
+ pass
40
+ await bot.leave_chat(message.chat.id)
plugins/broadcast.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from pyrogram import Client, filters
3
+ import datetime
4
+ import time
5
+ from database.users_chats_db import db
6
+ from info import ADMINS
7
+ from utils import broadcast_messages, broadcast_messages_group
8
+ import asyncio
9
+
10
+ @Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply)
11
+ # https://t.me/GetTGLink/4178
12
+ async def verupikkals(bot, message):
13
+ users = await db.get_all_users()
14
+ b_msg = message.reply_to_message
15
+ sts = await message.reply_text(
16
+ text='Broadcasting your messages...'
17
+ )
18
+ start_time = time.time()
19
+ total_users = await db.total_users_count()
20
+ done = 0
21
+ blocked = 0
22
+ deleted = 0
23
+ failed =0
24
+
25
+ success = 0
26
+ async for user in users:
27
+ pti, sh = await broadcast_messages(int(user['id']), b_msg)
28
+ if pti:
29
+ success += 1
30
+ elif pti == False:
31
+ if sh == "Blocked":
32
+ blocked+=1
33
+ elif sh == "Deleted":
34
+ deleted += 1
35
+ elif sh == "Error":
36
+ failed += 1
37
+ done += 1
38
+ await asyncio.sleep(2)
39
+ if not done % 20:
40
+ await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}")
41
+ time_taken = datetime.timedelta(seconds=int(time.time()-start_time))
42
+ await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}")
43
+
44
+ @Client.on_message(filters.command("grp_broadcast") & filters.user(ADMINS) & filters.reply)
45
+ async def broadcast_group(bot, message):
46
+ groups = await db.get_all_chats()
47
+ b_msg = message.reply_to_message
48
+ sts = await message.reply_text(
49
+ text='Broadcasting your messages To Groups...'
50
+ )
51
+ start_time = time.time()
52
+ total_groups = await db.total_chat_count()
53
+ done = 0
54
+ failed =0
55
+
56
+ success = 0
57
+ async for group in groups:
58
+ pti, sh = await broadcast_messages_group(int(group['id']), b_msg)
59
+ if pti:
60
+ success += 1
61
+ elif sh == "Error":
62
+ failed += 1
63
+ done += 1
64
+ if not done % 20:
65
+ await sts.edit(f"Broadcast in progress:\n\nTotal Groups {total_groups}\nCompleted: {done} / {total_groups}\nSuccess: {success}")
66
+ time_taken = datetime.timedelta(seconds=int(time.time()-start_time))
67
+ await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Groups {total_groups}\nCompleted: {done} / {total_groups}\nSuccess: {success}")
68
+
plugins/channel.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyrogram import Client, filters
2
+ from info import CHANNELS
3
+ from database.ia_filterdb import save_file
4
+
5
+ media_filter = filters.document | filters.video | filters.audio
6
+
7
+
8
+ @Client.on_message(filters.chat(CHANNELS) & media_filter)
9
+ async def media(bot, message):
10
+ """Media Handler"""
11
+ for file_type in ("document", "video", "audio"):
12
+ media = getattr(message, file_type, None)
13
+ if media is not None:
14
+ break
15
+ else:
16
+ return
17
+
18
+ media.file_type = file_type
19
+ media.caption = message.caption
20
+ await save_file(media)
plugins/commands.py ADDED
@@ -0,0 +1,1659 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #commands.py
2
+ from datetime import datetime
3
+ import time
4
+ import os
5
+ import string
6
+ import pytz
7
+ import logging
8
+ import random
9
+ import asyncio
10
+ from Script import script
11
+ from pyrogram import Client, filters, enums
12
+ from pyrogram.errors import ChatAdminRequired, FloodWait
13
+ from pyrogram.types import *
14
+ from database.ia_filterdb import *
15
+ from database.users_chats_db import db
16
+ from info import *
17
+ from utils import get_settings, get_size, is_subscribed, save_group_settings, temp, verify_user, check_token, check_verification, get_token, get_shortlink, get_tutorial
18
+ from database.connections_mdb import active_connection
19
+ # from plugins.pm_filter import ENABLE_SHORTLINK
20
+ from plugins.fsub import ForceSub
21
+ import re, asyncio, os, sys
22
+ import json
23
+ import base64
24
+ import requests
25
+ from bs4 import BeautifulSoup
26
+ logger = logging.getLogger(__name__)
27
+
28
+ BATCH_FILES = {}
29
+
30
+ @Client.on_message(filters.command("start") & filters.incoming)
31
+ async def start(client, message):
32
+ if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
33
+ buttons = [[
34
+ InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
35
+ ],[
36
+ InlineKeyboardButton('✪ Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url="https://t.me/+r9ArDaaCETE0OGU9"),
37
+ InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
38
+ ],[
39
+ InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK)
40
+ ]]
41
+ reply_markup = InlineKeyboardMarkup(buttons)
42
+ await message.reply(script.START_TXT.format(message.from_user.mention if message.from_user else message.chat.title, temp.U_NAME, temp.B_NAME), reply_markup=reply_markup, disable_web_page_preview=True)
43
+ await asyncio.sleep(2) # 😢 https://github.com/EvamariaTG/EvaMaria/blob/master/plugins/p_ttishow.py#L17 😬 wait a bit, before checking.
44
+ if not await db.get_chat(message.chat.id):
45
+ total=await client.get_chat_members_count(message.chat.id)
46
+ await client.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, "Unknown"))
47
+ await db.add_chat(message.chat.id, message.chat.title)
48
+ return
49
+ if not await db.is_user_exist(message.from_user.id):
50
+ await db.add_user(message.from_user.id, message.from_user.first_name)
51
+ await client.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(message.from_user.id, message.from_user.mention))
52
+ if len(message.command) != 2:
53
+ buttons = [[
54
+ InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
55
+ ],[
56
+ InlineKeyboardButton('Eᴀʀɴ Mᴏɴᴇʏ 💸', callback_data="shortlink_info"),
57
+ InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
58
+ ],[
59
+ InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'),
60
+ InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about')
61
+ ],[
62
+ InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK)
63
+ ]]
64
+ reply_markup = InlineKeyboardMarkup(buttons)
65
+ m=await message.reply_sticker("CAACAgUAAxkBAAFFRb1kyf8cQI9ZIgIc36p3uBzmVG8zUwACbwoAAspbUVYbd56jBKfgAAEeBA")
66
+ await asyncio.sleep(1)
67
+ await m.delete()
68
+ await message.reply_photo(
69
+ photo=random.choice(PICS),
70
+ caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME),
71
+ reply_markup=reply_markup,
72
+ parse_mode=enums.ParseMode.HTML
73
+ )
74
+ return
75
+
76
+ if AUTH_CHANNEL and not await is_subscribed(client, message):
77
+ try:
78
+ invite_link = await client.create_chat_invite_link(int(AUTH_CHANNEL))
79
+ except ChatAdminRequired:
80
+ logger.error("Make sure Bot is admin in Forcesub channel")
81
+ return
82
+ btn = [
83
+ [
84
+ InlineKeyboardButton(
85
+ "❆ Jᴏɪɴ Oᴜʀ Cʜᴀɴɴᴇʟ ❆", url=invite_link.invite_link
86
+ )
87
+ ]
88
+ ]
89
+
90
+ if message.command[1] != "subscribe":
91
+ try:
92
+ kk, file_id = message.command[1].split("_", 1)
93
+ btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", callback_data=f"checkssub#{kk}#{file_id}")])
94
+ except (IndexError, ValueError):
95
+ btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", url=f"https://t.me/{temp.U_NAME}?start={message.command[1]}")])
96
+ await client.send_message(
97
+ chat_id=message.from_user.id,
98
+ text="**You are not in our channel given below so you don't get the movie file...\n\nIf you want the movie file, click on the '🍿ᴊᴏɪɴ ᴏᴜʀ ʙᴀᴄᴋ-ᴜᴘ ���ʜᴀɴɴᴇʟ🍿' button below and join our back-up channel, then click on the '🔄 Try Again' button below...\n\nThen you will get the movie files...**",
99
+ reply_markup=InlineKeyboardMarkup(btn),
100
+ parse_mode=enums.ParseMode.MARKDOWN
101
+ )
102
+ return
103
+
104
+ if len(message.command) == 2 and message.command[1] in ["subscribe", "error", "okay", "help"]:
105
+ buttons = [[
106
+ InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
107
+ ],[
108
+ InlineKeyboardButton('Eᴀʀɴ Mᴏɴᴇʏ 💸', callback_data="shortlink_info"),
109
+ InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
110
+ ],[
111
+ InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'),
112
+ InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about')
113
+ ],[
114
+ InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK)
115
+ ]]
116
+ reply_markup = InlineKeyboardMarkup(buttons)
117
+ await message.reply_photo(
118
+ photo=random.choice(PICS),
119
+ caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME),
120
+ reply_markup=reply_markup,
121
+ parse_mode=enums.ParseMode.HTML
122
+ )
123
+ return
124
+
125
+ kk, file_id = message.command[1].split("_", 1) if "_" in message.command[1] else (False, False)
126
+ pre = kk if kk else False
127
+
128
+ if REQ_CHANNEL:
129
+ status = await ForceSub(client, message, file_id=file_id, pre=pre)
130
+ if not status:
131
+ return
132
+
133
+ data = message.command[1]
134
+ if not file_id:
135
+ file_id = data
136
+
137
+ if data.split("-", 1)[0] == "BATCH":
138
+ sts = await message.reply("<b>Please wait...</b>")
139
+ file_id = data.split("-", 1)[1]
140
+ msgs = BATCH_FILES.get(file_id)
141
+ if not msgs:
142
+ file = await client.download_media(file_id)
143
+ try:
144
+ with open(file) as file_data:
145
+ msgs=json.loads(file_data.read())
146
+ except:
147
+ await sts.edit("FAILED")
148
+ return await client.send_message(LOG_CHANNEL, "UNABLE TO OPEN FILE.")
149
+ os.remove(file)
150
+ BATCH_FILES[file_id] = msgs
151
+ for msg in msgs:
152
+ title = msg.get("title")
153
+ size=get_size(int(msg.get("size", 0)))
154
+ f_caption=msg.get("caption", "")
155
+ if BATCH_FILE_CAPTION:
156
+ try:
157
+ f_caption=BATCH_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
158
+ except Exception as e:
159
+ logger.exception(e)
160
+ f_caption=f_caption
161
+ if f_caption is None:
162
+ f_caption = f"{title}"
163
+ try:
164
+ await client.send_cached_media(
165
+ chat_id=message.from_user.id,
166
+ file_id=msg.get("file_id"),
167
+ caption=f_caption,
168
+ protect_content=msg.get('protect', False),
169
+ reply_markup=InlineKeyboardMarkup(
170
+ [
171
+ [
172
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
173
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
174
+ ],[
175
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
176
+ ]
177
+ ]
178
+ )
179
+ )
180
+ except FloodWait as e:
181
+ await asyncio.sleep(e.x)
182
+ logger.warning(f"Floodwait of {e.x} sec.")
183
+ await client.send_cached_media(
184
+ chat_id=message.from_user.id,
185
+ file_id=msg.get("file_id"),
186
+ caption=f_caption,
187
+ protect_content=msg.get('protect', False),
188
+ reply_markup=InlineKeyboardMarkup(
189
+ [
190
+ [
191
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
192
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
193
+ ],[
194
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
195
+ ]
196
+ ]
197
+ )
198
+ )
199
+ except Exception as e:
200
+ logger.warning(e, exc_info=True)
201
+ continue
202
+ await asyncio.sleep(1)
203
+ await sts.delete()
204
+ return
205
+
206
+ elif data.split("-", 1)[0] == "DSTORE":
207
+ sts = await message.reply("<b>Please wait...</b>")
208
+ b_string = data.split("-", 1)[1]
209
+ decoded = (base64.urlsafe_b64decode(b_string + "=" * (-len(b_string) % 4))).decode("ascii")
210
+ try:
211
+ f_msg_id, l_msg_id, f_chat_id, protect = decoded.split("_", 3)
212
+ except:
213
+ f_msg_id, l_msg_id, f_chat_id = decoded.split("_", 2)
214
+ protect = "/pbatch" if PROTECT_CONTENT else "batch"
215
+ diff = int(l_msg_id) - int(f_msg_id)
216
+ async for msg in client.iter_messages(int(f_chat_id), int(l_msg_id), int(f_msg_id)):
217
+ if msg.media:
218
+ media = getattr(msg, msg.media.value)
219
+ if BATCH_FILE_CAPTION:
220
+ try:
221
+ f_caption=BATCH_FILE_CAPTION.format(file_name=getattr(media, 'file_name', ''), file_size=getattr(media, 'file_size', ''), file_caption=getattr(msg, 'caption', ''))
222
+ except Exception as e:
223
+ logger.exception(e)
224
+ f_caption = getattr(msg, 'caption', '')
225
+ else:
226
+ media = getattr(msg, msg.media.value)
227
+ file_name = getattr(media, 'file_name', '')
228
+ f_caption = getattr(msg, 'caption', file_name)
229
+ try:
230
+ await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False)
231
+ except FloodWait as e:
232
+ await asyncio.sleep(e.x)
233
+ await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False)
234
+ except Exception as e:
235
+ logger.exception(e)
236
+ continue
237
+ elif msg.empty:
238
+ continue
239
+ else:
240
+ try:
241
+ await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False)
242
+ except FloodWait as e:
243
+ await asyncio.sleep(e.x)
244
+ await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False)
245
+ except Exception as e:
246
+ logger.exception(e)
247
+ continue
248
+ await asyncio.sleep(1)
249
+ return await sts.delete()
250
+
251
+ elif data.split("-", 1)[0] == "verify":
252
+ userid = data.split("-", 2)[1]
253
+ token = data.split("-", 3)[2]
254
+ if str(message.from_user.id) != str(userid):
255
+ return await message.reply_text(
256
+ text="<b>Invalid link or Expired link !</b>",
257
+ protect_content=True
258
+ )
259
+ is_valid = await check_token(client, userid, token)
260
+ if is_valid == True:
261
+ await message.reply_text(
262
+ text=f"<b>Hey {message.from_user.mention}, You are successfully verified !\nNow you have unlimited access for all movies till today midnight.</b>",
263
+ protect_content=True
264
+ )
265
+ await verify_user(client, userid, token)
266
+ else:
267
+ return await message.reply_text(
268
+ text="<b>Invalid link or Expired link !</b>",
269
+ protect_content=True
270
+ )
271
+ if data.startswith("sendfiles"):
272
+ chat_id = int("-" + file_id.split("-")[1])
273
+ user_id = message.from_user.id if message.from_user else None
274
+ if not await db.is_user_verified(user_id):
275
+ verify_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
276
+ await db.create_verify_id(user_id, verify_id)
277
+ st = await client.get_chat_member(chat_id, user_id)
278
+ if (
279
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
280
+ and st.status != enums.ChatMemberStatus.OWNER
281
+ ):
282
+ g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{file_id}_{verify_id}", True)
283
+ else:
284
+ g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{file_id}_{verify_id}", False)
285
+ await client.send_message(chat_id=message.from_user.id,text=f"<b>Get All Files in a Single Link!!!\n\n📂 ʟɪɴᴋ ➠ : {g}\n\n<i>Note: Open Link and Get Your File and also Get access for Unlimited files for next 24hrs without getting links in this bot</i></b>", reply_markup=InlineKeyboardMarkup(
286
+ [
287
+ [
288
+ InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
289
+ ], [
290
+ InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=await get_tutorial(chat_id))
291
+ ]
292
+ ]
293
+ )
294
+ )
295
+ # await asyncio.sleep(300)
296
+ # await k.edit("<b>Your message is successfully deleted!!!</b>")
297
+ return
298
+ else:
299
+ files = temp.GETALL.get(file_id)
300
+ if not files:
301
+ return await message.reply('<b><i>No such file exist.</b></i>')
302
+ # filesarr = []
303
+ for file in files:
304
+ file_id = file.file_id
305
+ files_ = await get_file_details(file_id)
306
+ files1 = files_[0]
307
+ title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))
308
+ size=get_size(files1.file_size)
309
+ f_caption=files1.caption
310
+ if CUSTOM_FILE_CAPTION:
311
+ try:
312
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
313
+ except Exception as e:
314
+ logger.exception(e)
315
+ f_caption=f_caption
316
+ if f_caption is None:
317
+ f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))}"
318
+ if not await check_verification(client, message.from_user.id) and VERIFY == True:
319
+ btn = [[
320
+ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
321
+ ]]
322
+ await message.reply_text(
323
+ text="<b>You are not verified !\nKindly verify to continue !</b>",
324
+ protect_content=True,
325
+ reply_markup=InlineKeyboardMarkup(btn)
326
+ )
327
+ return
328
+ msg = await client.send_cached_media(
329
+ chat_id=message.from_user.id,
330
+ file_id=file_id,
331
+ caption=f_caption,
332
+ protect_content=True if pre == 'filep' else False,
333
+ reply_markup=InlineKeyboardMarkup(
334
+ [
335
+ [
336
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
337
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
338
+ ],[
339
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
340
+ ]
341
+ ]
342
+ )
343
+ )
344
+ # filesarr.append(msg)
345
+ # k = await client.send_message(chat_id = message.from_user.id, text=f"<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie Files/Videos will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this ALL Files/Videos to your Saved Messages and Start Download there</i></b>")
346
+ # await asyncio.sleep(600)
347
+ # for x in filesarr:
348
+ # await x.delete()
349
+ # await k.edit_text("<b>Your All Files/Videos is successfully deleted!!!</b>")
350
+ return
351
+
352
+ elif data.startswith("short"):
353
+ user_id = message.from_user.id
354
+ if temp.SHORT.get(user_id)==None:
355
+ await message.reply_text(text="<b>Please Search Again in Group</b>")
356
+ return
357
+ else:
358
+ chat_id = temp.SHORT.get(user_id)
359
+ files_ = await get_file_details(file_id)
360
+ files = files_[0]
361
+ if not await db.is_user_verified(user_id):
362
+ verify_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
363
+ await db.create_verify_id(user_id, verify_id)
364
+ g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
365
+ await client.send_message(chat_id=user_id,text=f"<b>📕Nᴀᴍᴇ ➠ : <code>{files.file_name}</code> \n\n🔗Sɪᴢᴇ ➠ : {get_size(files.file_size)}\n\n📂Fɪʟᴇ ʟɪɴᴋ ➠ : {g}\n\n<i>Note: Open Link and Get Your File and also Get access for Unlimited files for next 24hrs without getting links in this bot</i></b>", reply_markup=InlineKeyboardMarkup(
366
+ [
367
+ [
368
+ InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
369
+ ], [
370
+ InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=await get_tutorial(chat_id))
371
+ ]
372
+ ]
373
+ )
374
+ )
375
+ # await asyncio.sleep(1200)
376
+ # await k.edit("<b>Your message is successfully deleted!!!</b>")
377
+ return
378
+ else:
379
+ title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
380
+ size=get_size(files.file_size)
381
+ f_caption=files.caption
382
+ if CUSTOM_FILE_CAPTION:
383
+ try:
384
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
385
+ except Exception as e:
386
+ logger.exception(e)
387
+ f_caption=f_caption
388
+ if f_caption is None:
389
+ f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
390
+ if not await check_verification(client, message.from_user.id) and VERIFY == True:
391
+ btn = [[
392
+ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
393
+ ]]
394
+ await message.reply_text(
395
+ text="<b>You are not verified !\nKindly verify to continue !</b>",
396
+ protect_content=True,
397
+ reply_markup=InlineKeyboardMarkup(btn)
398
+ )
399
+ return
400
+ msg = await client.send_cached_media(
401
+ chat_id=message.from_user.id,
402
+ file_id=file_id,
403
+ caption=f_caption,
404
+ protect_content=True if pre == 'filep' else False,
405
+ reply_markup=InlineKeyboardMarkup(
406
+ [
407
+ [
408
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
409
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
410
+ ],[
411
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
412
+ ]
413
+ ]
414
+ )
415
+ )
416
+ # btn = [[
417
+ # InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
418
+ # ]]
419
+ # k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
420
+ # await asyncio.sleep(600)
421
+ # await msg.delete()
422
+ # await k.edit_text("<b>Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇</b>",reply_markup=InlineKeyboardMarkup(btn))
423
+ return
424
+
425
+ elif data.startswith("all"):
426
+ m = message
427
+ user = m.from_user.id
428
+ verify_id = m.command[1].rsplit("_",1)[-1]
429
+ verify_id_info = await db.get_verify_id_info(user, verify_id)
430
+ if not verify_id_info or verify_id_info["verified"]:
431
+ await message.reply("Invalid link.😎 Link has already opened.👻 Try Again 😂")
432
+ return
433
+ ist_timezone = pytz.timezone('Asia/Kolkata')
434
+ await db.update_notcopy_user(user, {"last_verified":datetime.now(tz=ist_timezone)})
435
+ await db.update_verify_id_info(user, verify_id, {"verified":True})
436
+ await message.reply_text(text="<b>Hey You are Successfully verified!!!\n\nGet Unlimited Files for the Next 24Hours 😎\n\nSearch movies in group and get Direct Files without any Link</b>")
437
+ file_id = file_id.rsplit('_', 1)[0]
438
+ files = temp.GETALL.get(file_id)
439
+ if not files:
440
+ return await message.reply("<b><i>No such file exist or link expired. \n\nDon't worry search again in group and click send all to get all files directly without shortener link</b></i>")
441
+ return
442
+ # filesarr = []
443
+ for file in files:
444
+ file_id = file.file_id
445
+ files_ = await get_file_details(file_id)
446
+ files1 = files_[0]
447
+ title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))
448
+ size=get_size(files1.file_size)
449
+ f_caption=files1.caption
450
+ if CUSTOM_FILE_CAPTION:
451
+ try:
452
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
453
+ except Exception as e:
454
+ logger.exception(e)
455
+ f_caption=f_caption
456
+ if f_caption is None:
457
+ f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))}"
458
+ if not await check_verification(client, message.from_user.id) and VERIFY == True:
459
+ btn = [[
460
+ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
461
+ ]]
462
+ await message.reply_text(
463
+ text="<b>You are not verified !\nKindly verify to continue !</b>",
464
+ protect_content=True,
465
+ reply_markup=InlineKeyboardMarkup(btn)
466
+ )
467
+ return
468
+ msg = await client.send_cached_media(
469
+ chat_id=message.from_user.id,
470
+ file_id=file_id,
471
+ caption=f_caption,
472
+ protect_content=True if pre == 'filep' else False,
473
+ reply_markup=InlineKeyboardMarkup(
474
+ [
475
+ [
476
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
477
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
478
+ ],[
479
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
480
+ ]
481
+ ]
482
+ )
483
+ )
484
+ # filesarr.append(msg)
485
+ # k = await client.send_message(chat_id = message.from_user.id, text=f"<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie Files/Videos will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this ALL Files/Videos to your Saved Messages and Start Download there</i></b>")
486
+ # await asyncio.sleep(600)
487
+ # for x in filesarr:
488
+ # await x.delete()
489
+ # await k.edit_text("<b>Your All Files/Videos is successfully deleted!!!</b>")
490
+ return
491
+
492
+ elif data.startswith("files"):
493
+ user_id = message.from_user.id
494
+ if temp.SHORT.get(user_id)==None:
495
+ await message.reply_text(text="<b>Please Search Again in Group</b>")
496
+ return
497
+ else:
498
+ chat_id = temp.SHORT.get(user_id)
499
+ settings = await get_settings(chat_id)
500
+ if settings['is_shortlink'] and user_id not in PREMIUM_USER and not await db.is_user_verified(user_id):
501
+ files_ = await get_file_details(file_id)
502
+ files = files_[0]
503
+ verify_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
504
+ await db.create_verify_id(user_id, verify_id)
505
+ g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
506
+ await client.send_message(chat_id=user_id,text=f"<b>📕Nᴀᴍᴇ ➠ : <code>{files.file_name}</code> \n\n🔗Sɪᴢᴇ ➠ : {get_size(files.file_size)}\n\n📂Fɪʟᴇ ʟɪɴᴋ ➠ : {g}\n\n<i>Note: Open Link and Get Your File and also Get access for Unlimited files for next 24hrs without getting links in this bot</i></b>", reply_markup=InlineKeyboardMarkup(
507
+ [
508
+ [
509
+ InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
510
+ ], [
511
+ InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=await get_tutorial(chat_id))
512
+ ]
513
+ ]
514
+ )
515
+ )
516
+ # await asyncio.sleep(1200)
517
+ # await k.edit("<b>Your message is successfully deleted!!!</b>")
518
+ return
519
+ else:
520
+ files_ = await get_file_details(file_id)
521
+ files = files_[0]
522
+ title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
523
+ size=get_size(files.file_size)
524
+ f_caption=files.caption
525
+ if CUSTOM_FILE_CAPTION:
526
+ try:
527
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
528
+ except Exception as e:
529
+ logger.exception(e)
530
+ f_caption=f_caption
531
+ if f_caption is None:
532
+ f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
533
+ msg = await client.send_cached_media(
534
+ chat_id=message.from_user.id,
535
+ file_id=file_id,
536
+ caption=f_caption,
537
+ protect_content=True if pre == 'filep' else False,
538
+ reply_markup=InlineKeyboardMarkup(
539
+ [
540
+ [
541
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
542
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
543
+ ],[
544
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
545
+ ]
546
+ ]
547
+ )
548
+ )
549
+ # btn = [[
550
+ # InlineKeyboardButton("Get File Again", callback_data=f'del#{file_id}')
551
+ # ]]
552
+ # k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
553
+ # await asyncio.sleep(600)
554
+ # await msg.delete()
555
+ # await k.edit_text("<b>Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇</b>",reply_markup=InlineKeyboardMarkup(btn))
556
+ return
557
+ elif data.startswith("file"):
558
+ m = message
559
+ user = m.from_user.id
560
+ verify_id = m.command[1].rsplit("_",1)[-1]
561
+ verify_id_info = await db.get_verify_id_info(user, verify_id)
562
+ if not verify_id_info or verify_id_info["verified"]:
563
+ await message.reply("Invalid link.😎 Link has already opened.👻 Try Again 😂")
564
+ return
565
+ ist_timezone = pytz.timezone('Asia/Kolkata')
566
+ await db.update_notcopy_user(user, {"last_verified":datetime.now(tz=ist_timezone)})
567
+ await db.update_verify_id_info(user, verify_id, {"verified":True})
568
+ await message.reply_text(text="<b>Hey You are Successfully verified!!!\n\nGet Unlimited Files for the Next 24Hours 😎\n\nSearch movies in group and get Direct Files without any Link</b>")
569
+ file_id = file_id.rsplit('_', 1)[0]
570
+ files_ = await get_file_details(file_id)
571
+ if not files_:
572
+ pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1)
573
+ try:
574
+ msg = await client.send_cached_media(
575
+ chat_id=message.from_user.id,
576
+ file_id=file_id,
577
+ protect_content=True if pre == 'filep' else False,
578
+ reply_markup=InlineKeyboardMarkup(
579
+ [
580
+ [
581
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
582
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
583
+ ],[
584
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
585
+ ]
586
+ ]
587
+ )
588
+ )
589
+ filetype = msg.media
590
+ file = getattr(msg, filetype.value)
591
+ title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split()))
592
+ size=get_size(file.file_size)
593
+ f_caption = f"<code>{title}</code>"
594
+ if CUSTOM_FILE_CAPTION:
595
+ try:
596
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='')
597
+ except:
598
+ return
599
+ await msg.edit_caption(f_caption)
600
+ # btn = [[
601
+ # InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
602
+ # ]]
603
+ # k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
604
+ # await asyncio.sleep(600)
605
+ # await msg.delete()
606
+ # await k.edit_text("<b>Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇</b>",reply_markup=InlineKeyboardMarkup(btn))
607
+ return
608
+ except:
609
+ pass
610
+ return await message.reply('No such file exist.')
611
+ files = files_[0]
612
+ title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
613
+ size=get_size(files.file_size)
614
+ f_caption=files.caption
615
+ if CUSTOM_FILE_CAPTION:
616
+ try:
617
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
618
+ except Exception as e:
619
+ logger.exception(e)
620
+ f_caption=f_caption
621
+ if f_caption is None:
622
+ f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
623
+ if not await check_verification(client, message.from_user.id) and VERIFY == True:
624
+ btn = [[
625
+ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
626
+ ]]
627
+ await message.reply_text(
628
+ text="<b>You are not verified !\nKindly verify to continue !</b>",
629
+ protect_content=True,
630
+ reply_markup=InlineKeyboardMarkup(btn)
631
+ )
632
+ return
633
+ msg = await client.send_cached_media(
634
+ chat_id=message.from_user.id,
635
+ file_id=file_id,
636
+ caption=f_caption,
637
+ protect_content=True if pre == 'filep' else False,
638
+ reply_markup=InlineKeyboardMarkup(
639
+ [
640
+ [
641
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
642
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
643
+ ],[
644
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
645
+ ]
646
+ ]
647
+ )
648
+ )
649
+ # btn = [[
650
+ # InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
651
+ # ]]
652
+ # k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
653
+ # await asyncio.sleep(600)
654
+ # await msg.delete()
655
+ # await k.edit_text("<b>Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇</b>",reply_markup=InlineKeyboardMarkup(btn))
656
+ return
657
+ files_ = await get_file_details(file_id)
658
+ if not files_:
659
+ pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1)
660
+ try:
661
+ msg = await client.send_cached_media(
662
+ chat_id=message.from_user.id,
663
+ file_id=file_id,
664
+ protect_content=True if pre == 'filep' else False,
665
+ reply_markup=InlineKeyboardMarkup(
666
+ [
667
+ [
668
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
669
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
670
+ ],[
671
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
672
+ ]
673
+ ]
674
+ )
675
+ )
676
+ filetype = msg.media
677
+ file = getattr(msg, filetype.value)
678
+ title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split()))
679
+ size=get_size(file.file_size)
680
+ f_caption = f"<code>{title}</code>"
681
+ if CUSTOM_FILE_CAPTION:
682
+ try:
683
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='')
684
+ except:
685
+ return
686
+ await msg.edit_caption(f_caption)
687
+ # btn = [[
688
+ # InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
689
+ # ]]
690
+ # k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
691
+ # await asyncio.sleep(600)
692
+ # await msg.delete()
693
+ # await k.edit_text("<b>Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇</b>",reply_markup=InlineKeyboardMarkup(btn))
694
+ return
695
+ except:
696
+ pass
697
+ return await message.reply('No such file exist.')
698
+ files = files_[0]
699
+ title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
700
+ size=get_size(files.file_size)
701
+ f_caption=files.caption
702
+ if CUSTOM_FILE_CAPTION:
703
+ try:
704
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
705
+ except Exception as e:
706
+ logger.exception(e)
707
+ f_caption=f_caption
708
+ if f_caption is None:
709
+ f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
710
+ if not await check_verification(client, message.from_user.id) and VERIFY == True:
711
+ btn = [[
712
+ InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
713
+ ]]
714
+ await message.reply_text(
715
+ text="<b>You are not verified !\nKindly verify to continue !</b>",
716
+ protect_content=True,
717
+ reply_markup=InlineKeyboardMarkup(btn)
718
+ )
719
+ return
720
+ msg = await client.send_cached_media(
721
+ chat_id=message.from_user.id,
722
+ file_id=file_id,
723
+ caption=f_caption,
724
+ protect_content=True if pre == 'filep' else False,
725
+ reply_markup=InlineKeyboardMarkup(
726
+ [
727
+ [
728
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
729
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
730
+ ],[
731
+ InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movies")
732
+ ]
733
+ ]
734
+ )
735
+ )
736
+ # btn = [[
737
+ # InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
738
+ # ]]
739
+ # k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
740
+ # await asyncio.sleep(600)
741
+ # await msg.delete()
742
+ # await k.edit_text("<b>Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇</b>",reply_markup=InlineKeyboardMarkup(btn))
743
+ return
744
+
745
+ @Client.on_message(filters.command('channel') & filters.user(ADMINS))
746
+ async def channel_info(bot, message):
747
+
748
+ """Send basic information of channel"""
749
+ if isinstance(CHANNELS, (int, str)):
750
+ channels = [CHANNELS]
751
+ elif isinstance(CHANNELS, list):
752
+ channels = CHANNELS
753
+ else:
754
+ raise ValueError("Unexpected type of CHANNELS")
755
+
756
+ text = '📑 **Indexed channels/groups**\n'
757
+ for channel in channels:
758
+ chat = await bot.get_chat(channel)
759
+ if chat.username:
760
+ text += '\n@' + chat.username
761
+ else:
762
+ text += '\n' + chat.title or chat.first_name
763
+
764
+ text += f'\n\n**Total:** {len(CHANNELS)}'
765
+
766
+ if len(text) < 4096:
767
+ await message.reply(text)
768
+ else:
769
+ file = 'Indexed channels.txt'
770
+ with open(file, 'w') as f:
771
+ f.write(text)
772
+ await message.reply_document(file)
773
+ os.remove(file)
774
+
775
+
776
+ @Client.on_message(filters.command('logs') & filters.user(ADMINS))
777
+ async def log_file(bot, message):
778
+ """Send log file"""
779
+ try:
780
+ await message.reply_document('Logs.txt')
781
+ except Exception as e:
782
+ await message.reply(str(e))
783
+
784
+ @Client.on_message(filters.command('delete') & filters.user(ADMINS))
785
+ async def delete(bot, message):
786
+ """Delete file from database"""
787
+ reply = message.reply_to_message
788
+ if reply and reply.media:
789
+ msg = await message.reply("Processing...⏳", quote=True)
790
+ else:
791
+ await message.reply('Reply to file with /delete which you want to delete', quote=True)
792
+ return
793
+
794
+ for file_type in ("document", "video", "audio"):
795
+ media = getattr(reply, file_type, None)
796
+ if media is not None:
797
+ break
798
+ else:
799
+ await msg.edit('This is not supported file format')
800
+ return
801
+
802
+ file_id, file_ref = unpack_new_file_id(media.file_id)
803
+
804
+ result = await Media.collection.delete_one({
805
+ '_id': file_id,
806
+ })
807
+ if result.deleted_count:
808
+ await msg.edit('File is successfully deleted from database')
809
+ else:
810
+ file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name))
811
+ result = await Media.collection.delete_many({
812
+ 'file_name': file_name,
813
+ 'file_size': media.file_size,
814
+ 'mime_type': media.mime_type
815
+ })
816
+ if result.deleted_count:
817
+ await msg.edit('File is successfully deleted from database')
818
+ else:
819
+ # files indexed before https://github.com/EvamariaTG/EvaMaria/commit/f3d2a1bcb155faf44178e5d7a685a1b533e714bf#diff-86b613edf1748372103e94cacff3b578b36b698ef9c16817bb98fe9ef22fb669R39
820
+ # have original file name.
821
+ result = await Media.collection.delete_many({
822
+ 'file_name': media.file_name,
823
+ 'file_size': media.file_size,
824
+ 'mime_type': media.mime_type
825
+ })
826
+ if result.deleted_count:
827
+ await msg.edit('File is successfully deleted from database')
828
+ else:
829
+ await msg.edit('File not found in database')
830
+
831
+
832
+ @Client.on_message(filters.command('deleteall') & filters.user(ADMINS))
833
+ async def delete_all_index(bot, message):
834
+ await message.reply_text(
835
+ 'This will delete all indexed files.\nDo you want to continue??',
836
+ reply_markup=InlineKeyboardMarkup(
837
+ [
838
+ [
839
+ InlineKeyboardButton(
840
+ text="YES", callback_data="autofilter_delete"
841
+ )
842
+ ],
843
+ [
844
+ InlineKeyboardButton(
845
+ text="CANCEL", callback_data="close_data"
846
+ )
847
+ ],
848
+ ]
849
+ ),
850
+ quote=True,
851
+ )
852
+
853
+
854
+ @Client.on_callback_query(filters.regex(r'^autofilter_delete'))
855
+ async def delete_all_index_confirm(bot, message):
856
+ await Media.collection.drop()
857
+ await message.answer('Piracy Is Crime')
858
+ await message.message.edit('Succesfully Deleted All The Indexed Files.')
859
+
860
+
861
+ @Client.on_message(filters.command('settings'))
862
+ async def settings(client, message):
863
+ userid = message.from_user.id if message.from_user else None
864
+ if not userid:
865
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
866
+ chat_type = message.chat.type
867
+
868
+ if chat_type == enums.ChatType.PRIVATE:
869
+ grpid = await active_connection(str(userid))
870
+ if grpid is not None:
871
+ grp_id = grpid
872
+ try:
873
+ chat = await client.get_chat(grpid)
874
+ title = chat.title
875
+ except:
876
+ await message.reply_text("Make sure I'm present in your group!!", quote=True)
877
+ return
878
+ else:
879
+ await message.reply_text("I'm not connected to any groups!", quote=True)
880
+ return
881
+
882
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
883
+ grp_id = message.chat.id
884
+ title = message.chat.title
885
+
886
+ else:
887
+ return
888
+
889
+ st = await client.get_chat_member(grp_id, userid)
890
+ if (
891
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
892
+ and st.status != enums.ChatMemberStatus.OWNER
893
+ and str(userid) not in ADMINS
894
+ ):
895
+ return
896
+
897
+ settings = await get_settings(grp_id)
898
+
899
+ try:
900
+ if settings['max_btn']:
901
+ settings = await get_settings(grp_id)
902
+ except KeyError:
903
+ await save_group_settings(grp_id, 'max_btn', False)
904
+ settings = await get_settings(grp_id)
905
+ if 'is_shortlink' not in settings.keys():
906
+ await save_group_settings(grp_id, 'is_shortlink', False)
907
+ else:
908
+ pass
909
+
910
+ if settings is not None:
911
+ buttons = [
912
+ [
913
+ InlineKeyboardButton(
914
+ 'Rᴇsᴜʟᴛ Pᴀɢᴇ',
915
+ callback_data=f'setgs#button#{settings["button"]}#{grp_id}',
916
+ ),
917
+ InlineKeyboardButton(
918
+ 'Bᴜᴛᴛᴏɴ' if settings["button"] else 'Tᴇxᴛ',
919
+ callback_data=f'setgs#button#{settings["button"]}#{grp_id}',
920
+ ),
921
+ ],
922
+ [
923
+ InlineKeyboardButton(
924
+ 'Fɪʟᴇ Sᴇɴᴅ Mᴏᴅᴇ',
925
+ callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}',
926
+ ),
927
+ InlineKeyboardButton(
928
+ 'Mᴀɴᴜᴀʟ Sᴛᴀʀᴛ' if settings["botpm"] else 'Aᴜᴛᴏ Sᴇɴᴅ',
929
+ callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}',
930
+ ),
931
+ ],
932
+ [
933
+ InlineKeyboardButton(
934
+ 'Pʀᴏᴛᴇᴄᴛ Cᴏɴᴛᴇɴᴛ',
935
+ callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}',
936
+ ),
937
+ InlineKeyboardButton(
938
+ '✔ Oɴ' if settings["file_secure"] else '✘ Oғғ',
939
+ callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}',
940
+ ),
941
+ ],
942
+ [
943
+ InlineKeyboardButton(
944
+ 'Iᴍᴅʙ',
945
+ callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}',
946
+ ),
947
+ InlineKeyboardButton(
948
+ '✔ Oɴ' if settings["imdb"] else '✘ Oғғ',
949
+ callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}',
950
+ ),
951
+ ],
952
+ [
953
+ InlineKeyboardButton(
954
+ 'Sᴘᴇʟʟ Cʜᴇᴄᴋ',
955
+ callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}',
956
+ ),
957
+ InlineKeyboardButton(
958
+ '✔ Oɴ' if settings["spell_check"] else '✘ Oғғ',
959
+ callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}',
960
+ ),
961
+ ],
962
+ [
963
+ InlineKeyboardButton(
964
+ 'Wᴇʟᴄᴏᴍᴇ Msɢ',
965
+ callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}',
966
+ ),
967
+ InlineKeyboardButton(
968
+ '✔ Oɴ' if settings["welcome"] else '✘ Oғғ',
969
+ callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}',
970
+ ),
971
+ ],
972
+ [
973
+ InlineKeyboardButton(
974
+ 'Aᴜᴛᴏ-Dᴇʟᴇᴛᴇ',
975
+ callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}',
976
+ ),
977
+ InlineKeyboardButton(
978
+ '5 Mɪɴs' if settings["auto_delete"] else '✘ Oғғ',
979
+ callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}',
980
+ ),
981
+ ],
982
+ [
983
+ InlineKeyboardButton(
984
+ 'Aᴜᴛᴏ-Fɪʟᴛᴇʀ',
985
+ callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}',
986
+ ),
987
+ InlineKeyboardButton(
988
+ '✔ Oɴ' if settings["auto_ffilter"] else '✘ Oғғ',
989
+ callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}',
990
+ ),
991
+ ],
992
+ [
993
+ InlineKeyboardButton(
994
+ 'Mᴀx Bᴜᴛᴛᴏɴs',
995
+ callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}',
996
+ ),
997
+ InlineKeyboardButton(
998
+ '10' if settings["max_btn"] else f'{MAX_B_TN}',
999
+ callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}',
1000
+ ),
1001
+ ],
1002
+ [
1003
+ InlineKeyboardButton(
1004
+ 'ShortLink',
1005
+ callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}',
1006
+ ),
1007
+ InlineKeyboardButton(
1008
+ '✔ Oɴ' if settings["is_shortlink"] else '✘ Oғғ',
1009
+ callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}',
1010
+ ),
1011
+ ],
1012
+ ]
1013
+
1014
+ btn = [[
1015
+ InlineKeyboardButton("Oᴘᴇɴ Hᴇʀᴇ ↓", callback_data=f"opnsetgrp#{grp_id}"),
1016
+ InlineKeyboardButton("Oᴘᴇɴ Iɴ PM ⇲", callback_data=f"opnsetpm#{grp_id}")
1017
+ ]]
1018
+
1019
+ reply_markup = InlineKeyboardMarkup(buttons)
1020
+ if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1021
+ await message.reply_text(
1022
+ text="<b>Dᴏ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴏᴘᴇɴ sᴇᴛᴛɪɴɢs ʜᴇʀᴇ ?</b>",
1023
+ reply_markup=InlineKeyboardMarkup(btn),
1024
+ disable_web_page_preview=True,
1025
+ parse_mode=enums.ParseMode.HTML,
1026
+ reply_to_message_id=message.id
1027
+ )
1028
+ else:
1029
+ await message.reply_text(
1030
+ text=f"<b>Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙</b>",
1031
+ reply_markup=reply_markup,
1032
+ disable_web_page_preview=True,
1033
+ parse_mode=enums.ParseMode.HTML,
1034
+ reply_to_message_id=message.id
1035
+ )
1036
+
1037
+
1038
+
1039
+ @Client.on_message(filters.command('set_template'))
1040
+ async def save_template(client, message):
1041
+ sts = await message.reply("Checking template")
1042
+ userid = message.from_user.id if message.from_user else None
1043
+ if not userid:
1044
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
1045
+ chat_type = message.chat.type
1046
+
1047
+ if chat_type == enums.ChatType.PRIVATE:
1048
+ grpid = await active_connection(str(userid))
1049
+ if grpid is not None:
1050
+ grp_id = grpid
1051
+ try:
1052
+ chat = await client.get_chat(grpid)
1053
+ title = chat.title
1054
+ except:
1055
+ await message.reply_text("Make sure I'm present in your group!!", quote=True)
1056
+ return
1057
+ else:
1058
+ await message.reply_text("I'm not connected to any groups!", quote=True)
1059
+ return
1060
+
1061
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1062
+ grp_id = message.chat.id
1063
+ title = message.chat.title
1064
+
1065
+ else:
1066
+ return
1067
+
1068
+ st = await client.get_chat_member(grp_id, userid)
1069
+ if (
1070
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
1071
+ and st.status != enums.ChatMemberStatus.OWNER
1072
+ and str(userid) not in ADMINS
1073
+ ):
1074
+ return
1075
+
1076
+ if len(message.command) < 2:
1077
+ return await sts.edit("No Input!!")
1078
+ template = message.text.split(" ", 1)[1]
1079
+ await save_group_settings(grp_id, 'template', template)
1080
+ await sts.edit(f"Successfully changed template for {title} to\n\n{template}")
1081
+
1082
+
1083
+ @Client.on_message((filters.command(["request", "Request"]) | filters.regex("#request") | filters.regex("#Request")) & filters.group)
1084
+ async def requestss(bot, message):
1085
+ if REQST_CHANNEL is None or SUPPORT_CHAT_ID is None: return # Must add REQST_CHANNEL and SUPPORT_CHAT_ID to use this feature
1086
+ if message.reply_to_message and SUPPORT_CHAT_ID == message.chat.id:
1087
+ chat_id = message.chat.id
1088
+ reporter = str(message.from_user.id)
1089
+ mention = message.from_user.mention
1090
+ success = True
1091
+ content = message.reply_to_message.text
1092
+ try:
1093
+ if REQST_CHANNEL is not None:
1094
+ btn = [[
1095
+ InlineKeyboardButton('View Request', url=f"{message.reply_to_message.link}"),
1096
+ InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
1097
+ ]]
1098
+ reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>", reply_markup=InlineKeyboardMarkup(btn))
1099
+ success = True
1100
+ elif len(content) >= 3:
1101
+ for admin in ADMINS:
1102
+ btn = [[
1103
+ InlineKeyboardButton('View Request', url=f"{message.reply_to_message.link}"),
1104
+ InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
1105
+ ]]
1106
+ reported_post = await bot.send_message(chat_id=admin, text=f"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>", reply_markup=InlineKeyboardMarkup(btn))
1107
+ success = True
1108
+ else:
1109
+ if len(content) < 3:
1110
+ await message.reply_text("<b>You must type about your request [Minimum 3 Characters]. Requests can't be empty.</b>")
1111
+ if len(content) < 3:
1112
+ success = False
1113
+ except Exception as e:
1114
+ await message.reply_text(f"Error: {e}")
1115
+ pass
1116
+
1117
+ elif SUPPORT_CHAT_ID == message.chat.id:
1118
+ chat_id = message.chat.id
1119
+ reporter = str(message.from_user.id)
1120
+ mention = message.from_user.mention
1121
+ success = True
1122
+ content = message.text
1123
+ keywords = ["#request", "/request", "#Request", "/Request"]
1124
+ for keyword in keywords:
1125
+ if keyword in content:
1126
+ content = content.replace(keyword, "")
1127
+ try:
1128
+ if REQST_CHANNEL is not None and len(content) >= 3:
1129
+ btn = [[
1130
+ InlineKeyboardButton('View Request', url=f"{message.link}"),
1131
+ InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
1132
+ ]]
1133
+ reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>", reply_markup=InlineKeyboardMarkup(btn))
1134
+ success = True
1135
+ elif len(content) >= 3:
1136
+ for admin in ADMINS:
1137
+ btn = [[
1138
+ InlineKeyboardButton('View Request', url=f"{message.link}"),
1139
+ InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
1140
+ ]]
1141
+ reported_post = await bot.send_message(chat_id=admin, text=f"<b>𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}</b>", reply_markup=InlineKeyboardMarkup(btn))
1142
+ success = True
1143
+ else:
1144
+ if len(content) < 3:
1145
+ await message.reply_text("<b>You must type about your request [Minimum 3 Characters]. Requests can't be empty.</b>")
1146
+ if len(content) < 3:
1147
+ success = False
1148
+ except Exception as e:
1149
+ await message.reply_text(f"Error: {e}")
1150
+ pass
1151
+
1152
+ else:
1153
+ success = False
1154
+
1155
+ if success:
1156
+ '''if isinstance(REQST_CHANNEL, (int, str)):
1157
+ channels = [REQST_CHANNEL]
1158
+ elif isinstance(REQST_CHANNEL, list):
1159
+ channels = REQST_CHANNEL
1160
+ for channel in channels:
1161
+ chat = await bot.get_chat(channel)
1162
+ #chat = int(chat)'''
1163
+ link = await bot.create_chat_invite_link(int(REQST_CHANNEL))
1164
+ btn = [[
1165
+ InlineKeyboardButton('Join Channel', url=link.invite_link),
1166
+ InlineKeyboardButton('View Request', url=f"{reported_post.link}")
1167
+ ]]
1168
+ await message.reply_text("<b>Your request has been added! Please wait for some time.\n\nJoin Channel First & View Request</b>", reply_markup=InlineKeyboardMarkup(btn))
1169
+
1170
+ @Client.on_message(filters.command("send") & filters.user(ADMINS))
1171
+ async def send_msg(bot, message):
1172
+ if message.reply_to_message:
1173
+ target_id = message.text.split(" ", 1)[1]
1174
+ out = "Users Saved In DB Are:\n\n"
1175
+ success = False
1176
+ try:
1177
+ user = await bot.get_users(target_id)
1178
+ users = await db.get_all_users()
1179
+ async for usr in users:
1180
+ out += f"{usr['id']}"
1181
+ out += '\n'
1182
+ if str(user.id) in str(out):
1183
+ await message.reply_to_message.copy(int(user.id))
1184
+ success = True
1185
+ else:
1186
+ success = False
1187
+ if success:
1188
+ await message.reply_text(f"<b>Your message has been successfully send to {user.mention}.</b>")
1189
+ else:
1190
+ await message.reply_text("<b>This user didn't started this bot yet !</b>")
1191
+ except Exception as e:
1192
+ await message.reply_text(f"<b>Error: {e}</b>")
1193
+ else:
1194
+ await message.reply_text("<b>Use this command as a reply to any message using the target chat id. For eg: /send userid</b>")
1195
+
1196
+ @Client.on_message(filters.command("deletefiles") & filters.user(ADMINS))
1197
+ async def deletemultiplefiles(bot, message):
1198
+ chat_type = message.chat.type
1199
+ if chat_type != enums.ChatType.PRIVATE:
1200
+ return await message.reply_text(f"<b>Hey {message.from_user.mention}, This command won't work in groups. It only works on my PM !</b>")
1201
+ else:
1202
+ pass
1203
+ try:
1204
+ keyword = message.text.split(" ", 1)[1]
1205
+ except:
1206
+ return await message.reply_text(f"<b>Hey {message.from_user.mention}, Give me a keyword along with the command to delete files.</b>")
1207
+ k = await bot.send_message(chat_id=message.chat.id, text=f"<b>Fetching Files for your query {keyword} on DB... Please wait...</b>")
1208
+ files, total = await get_bad_files(keyword)
1209
+ await k.delete()
1210
+ #await k.edit_text(f"<b>Found {total} files for your query {keyword} !\n\nFile deletion process will start in 5 seconds !</b>")
1211
+ #await asyncio.sleep(5)
1212
+ btn = [[
1213
+ InlineKeyboardButton("Yes, Continue !", callback_data=f"killfilesdq#{keyword}")
1214
+ ],[
1215
+ InlineKeyboardButton("No, Abort operation !", callback_data="close_data")
1216
+ ]]
1217
+ await message.reply_text(
1218
+ text=f"<b>Found {total} files for your query {keyword} !\n\nDo you want to delete?</b>",
1219
+ reply_markup=InlineKeyboardMarkup(btn),
1220
+ parse_mode=enums.ParseMode.HTML
1221
+ )
1222
+
1223
+ @Client.on_message(filters.command("shortlink"))
1224
+ async def shortlink(bot, message):
1225
+ userid = message.from_user.id if message.from_user else None
1226
+ if not userid:
1227
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1228
+ chat_type = message.chat.type
1229
+ if chat_type == enums.ChatType.PRIVATE:
1230
+ return await message.reply_text(f"<b>Hey {message.from_user.mention}, This command only works on groups !\n\n<u>Follow These Steps to Connect Shortener:</u>\n\n1. Add Me in Your Group with Full Admin Rights\n\n2. After Adding in Grp, Set your Shortener\n\nSend this command in your group\n\n—> /shortlink ""{your_shortener_website_name} {your_shortener_api}\n\n#Sample:-\n/shortlink mplaylink.com 1f1da5c9df9a58058672ac8d8134e203b03426a1\n\nThat's it!!! Enjoy Earning Money 💲\n\n[[[ Trusted Earning Site - https://bit.ly/mplaylink ]]]\n\nIf you have any Doubts, Feel Free to Ask me - @TeamHMT_Bot\n\n(Puriyala na intha bot la message pannunga - @TeamHMT_bot)</b>")
1231
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1232
+ grpid = message.chat.id
1233
+ title = message.chat.title
1234
+ else:
1235
+ return
1236
+ data = message.text
1237
+ userid = message.from_user.id
1238
+ user = await bot.get_chat_member(grpid, userid)
1239
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1240
+ return await message.reply_text("<b>You don't have access to use this command!\n\nAdd Me to Your Own Group as Admin and Try This Command\n\nFor More PM Me With This Command</b>")
1241
+ else:
1242
+ pass
1243
+ try:
1244
+ command, shortlink_url, api = data.split(" ")
1245
+ except:
1246
+ return await message.reply_text("<b>Command Incomplete :(\n\nGive me a shortener website link and api along with the command !\n\nFormat: <code>/shortlink mplaylink.com 1f1da5c9df9a58058672ac8d8134e203b03426a1</code></b>")
1247
+ reply = await message.reply_text("<b>Please Wait...</b>")
1248
+ shortlink_url = re.sub(r"https?://?", "", shortlink_url)
1249
+ shortlink_url = re.sub(r"[:/]", "", shortlink_url)
1250
+ await save_group_settings(grpid, 'shortlink', shortlink_url)
1251
+ await save_group_settings(grpid, 'shortlink_api', api)
1252
+ await save_group_settings(grpid, 'is_shortlink', True)
1253
+ await reply.edit_text(f"<b>Successfully added shortlink API for {title}.\n\nCurrent Shortlink Website: <code>{shortlink_url}</code>\nCurrent API: <code>{api}</code></b>")
1254
+
1255
+ @Client.on_message(filters.command("setshortlinkoff") & filters.user(ADMINS))
1256
+ async def offshortlink(bot, message):
1257
+ chat_type = message.chat.type
1258
+ if chat_type == enums.ChatType.PRIVATE:
1259
+ return await message.reply_text("I will Work Only in group")
1260
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1261
+ grpid = message.chat.id
1262
+ title = message.chat.title
1263
+ else:
1264
+ return
1265
+ await save_group_settings(grpid, 'is_shortlink', False)
1266
+ # ENABLE_SHORTLINK = False
1267
+ return await message.reply_text("Successfully disabled shortlink")
1268
+
1269
+ @Client.on_message(filters.command("setshortlinkon") & filters.user(ADMINS))
1270
+ async def onshortlink(bot, message):
1271
+ chat_type = message.chat.type
1272
+ if chat_type == enums.ChatType.PRIVATE:
1273
+ return await message.reply_text("I will Work Only in group")
1274
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1275
+ grpid = message.chat.id
1276
+ title = message.chat.title
1277
+ else:
1278
+ return
1279
+ await save_group_settings(grpid, 'is_shortlink', True)
1280
+ # ENABLE_SHORTLINK = True
1281
+ return await message.reply_text("Successfully enabled shortlink")
1282
+
1283
+ @Client.on_message(filters.command("shortlink_info"))
1284
+ async def showshortlink(bot, message):
1285
+ userid = message.from_user.id if message.from_user else None
1286
+ if not userid:
1287
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1288
+ chat_type = message.chat.type
1289
+ if chat_type == enums.ChatType.PRIVATE:
1290
+ return await message.reply_text(f"<b>Hey {message.from_user.mention}, This Command Only Works in Group\n\nTry this command in your own group, if you are using me in your group</b>")
1291
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1292
+ grpid = message.chat.id
1293
+ title = message.chat.title
1294
+ else:
1295
+ return
1296
+ chat_id=message.chat.id
1297
+ userid = message.from_user.id
1298
+ user = await bot.get_chat_member(grpid, userid)
1299
+ # if 'shortlink' in settings.keys():
1300
+ # su = settings['shortlink']
1301
+ # sa = settings['shortlink_api']
1302
+ # else:
1303
+ # return await message.reply_text("<b>Shortener Url Not Connected\n\nYou can Connect Using /shortlink command</b>")
1304
+ # if 'tutorial' in settings.keys():
1305
+ # st = settings['tutorial']
1306
+ # else:
1307
+ # return await message.reply_text("<b>Tutorial Link Not Connected\n\nYou can Connect Using /set_tutorial command</b>")
1308
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1309
+ return await message.reply_text("<b>Tʜɪs ᴄᴏᴍᴍᴀɴᴅ Wᴏʀᴋs Oɴʟʏ Fᴏʀ ᴛʜɪs Gʀᴏᴜᴘ Oᴡɴᴇʀ/Aᴅᴍɪɴ\n\nTʀʏ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ɪɴ ʏᴏᴜʀ Oᴡɴ Gʀᴏᴜᴘ, Iғ Yᴏᴜ Aʀᴇ Usɪɴɢ Mᴇ Iɴ Yᴏᴜʀ Gʀᴏᴜᴘ</b>")
1310
+ else:
1311
+ settings = await get_settings(chat_id) #fetching settings for group
1312
+ if 'shortlink' in settings.keys() and 'tutorial' in settings.keys():
1313
+ su = settings['shortlink']
1314
+ sa = settings['shortlink_api']
1315
+ st = settings['tutorial']
1316
+ return await message.reply_text(f"<b>Shortlink Website: <code>{su}</code>\n\nApi: <code>{sa}</code>\n\nTutorial: <code>{st}</code></b>")
1317
+ elif 'shortlink' in settings.keys() and 'tutorial' not in settings.keys():
1318
+ su = settings['shortlink']
1319
+ sa = settings['shortlink_api']
1320
+ return await message.reply_text(f"<b>Shortener Website: <code>{su}</code>\n\nApi: <code>{sa}</code>\n\nTutorial Link Not Connected\n\nYou can Connect Using /set_tutorial command</b>")
1321
+ elif 'shortlink' not in settings.keys() and 'tutorial' in settings.keys():
1322
+ st = settings['tutorial']
1323
+ return await message.reply_text(f"<b>Tutorial: <code>{st}</code>\n\nShortener Url Not Connected\n\nYou can Connect Using /shortlink command</b>")
1324
+ else:
1325
+ return await message.reply_text("Shortener url and Tutorial Link Not Connected. Check this commands, /shortlink and /set_tutorial")
1326
+
1327
+
1328
+ @Client.on_message(filters.command("set_tutorial"))
1329
+ async def settutorial(bot, message):
1330
+ userid = message.from_user.id if message.from_user else None
1331
+ if not userid:
1332
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1333
+ chat_type = message.chat.type
1334
+ if chat_type == enums.ChatType.PRIVATE:
1335
+ return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
1336
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1337
+ grpid = message.chat.id
1338
+ title = message.chat.title
1339
+ else:
1340
+ return
1341
+ userid = message.from_user.id
1342
+ user = await bot.get_chat_member(grpid, userid)
1343
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1344
+ return
1345
+ else:
1346
+ pass
1347
+ if len(message.command) == 1:
1348
+ return await message.reply("<b>Give me a tutorial link along with this command\n\nCommand Usage: /set_tutorial your tutorial link</b>")
1349
+ elif len(message.command) == 2:
1350
+ reply = await message.reply_text("<b>Please Wait...</b>")
1351
+ tutorial = message.command[1]
1352
+ await save_group_settings(grpid, 'tutorial', tutorial)
1353
+ await save_group_settings(grpid, 'is_tutorial', True)
1354
+ await reply.edit_text(f"<b>Successfully Added Tutorial\n\nHere is your tutorial link for your group {title} - <code>{tutorial}</code></b>")
1355
+ else:
1356
+ return await message.reply("<b>You entered Incorrect Format\n\nFormat: /set_tutorial your tutorial link</b>")
1357
+
1358
+ @Client.on_message(filters.command("remove_tutorial"))
1359
+ async def removetutorial(bot, message):
1360
+ userid = message.from_user.id if message.from_user else None
1361
+ if not userid:
1362
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1363
+ chat_type = message.chat.type
1364
+ if chat_type == enums.ChatType.PRIVATE:
1365
+ return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
1366
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1367
+ grpid = message.chat.id
1368
+ title = message.chat.title
1369
+ else:
1370
+ return
1371
+ userid = message.from_user.id
1372
+ user = await bot.get_chat_member(grpid, userid)
1373
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1374
+ return
1375
+ else:
1376
+ pass
1377
+ reply = await message.reply_text("<b>Please Wait...</b>")
1378
+ await save_group_settings(grpid, 'is_tutorial', False)
1379
+ await reply.edit_text(f"<b>Successfully Removed Your Tutorial Link!!!</b>")
1380
+
1381
+ @Client.on_message(filters.command("restart") & filters.user(ADMINS))
1382
+ async def stop_button(bot, message):
1383
+ msg = await bot.send_message(text="**🔄 𝙿𝚁𝙾𝙲𝙴𝚂𝚂𝙴𝚂 𝚂𝚃𝙾𝙿𝙴𝙳. 𝙱𝙾𝚃 𝙸𝚂 𝚁𝙴𝚂𝚃𝙰𝚁𝚃𝙸𝙽𝙶...**", chat_id=message.chat.id)
1384
+ await asyncio.sleep(3)
1385
+ await msg.edit("**✅️ 𝙱𝙾𝚃 𝙸𝚂 𝚁𝙴𝚂𝚃𝙰𝚁𝚃𝙴𝙳. 𝙽𝙾𝚆 𝚈𝙾𝚄 𝙲𝙰𝙽 𝚄𝚂𝙴 𝙼𝙴**")
1386
+ os.execl(sys.executable, sys.executable, *sys.argv)
1387
+
1388
+ @Client.on_message(filters.group & filters.command("fsub"))
1389
+ async def f_sub_cmd(bot, message):
1390
+ userid = message.from_user.id if message.from_user else None
1391
+ if not userid:
1392
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1393
+ chat_type = message.chat.type
1394
+ if chat_type == enums.ChatType.PRIVATE:
1395
+ return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
1396
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1397
+ grpid = message.chat.id
1398
+ title = message.chat.title
1399
+ else:
1400
+ return
1401
+ userid = message.from_user.id
1402
+ user = await bot.get_chat_member(grpid, userid)
1403
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1404
+ return
1405
+ else:
1406
+ pass
1407
+ m=await message.reply("<b>Please wait...</b>")
1408
+ try:
1409
+ group = await get_group(message.chat.id)
1410
+ user_id = group["user_id"]
1411
+ user_name = group["user_name"]
1412
+ verified = group["verified"]
1413
+ except:
1414
+ await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
1415
+ # return await bot.leave_chat(message.chat.id)
1416
+ group = await get_group(message.chat.id)
1417
+ user_id = group["user_id"]
1418
+ user_name = group["user_name"]
1419
+ verified = group["verified"]
1420
+ if message.from_user.id!=user_id:
1421
+ return await m.edit(f"Only {user_name} can use this command 😁")
1422
+ if bool(verified)==False:
1423
+ return await m.edit(f"<b>Hey {message.from_user.mention}, This chat is not verified!\n\nUse /verify to verify your group</b>")
1424
+ try:
1425
+ f_sub = int(message.command[-1])
1426
+ except:
1427
+ return await m.edit("❌ Incorrect format!\nUse `/fsub ChannelID`")
1428
+ try:
1429
+ chat = await bot.get_chat(f_sub)
1430
+ group = await bot.get_chat(message.chat.id)
1431
+ c_link = chat.invite_link
1432
+ g_link = group.invite_link
1433
+ except Exception as e:
1434
+ text = f"❌ Error: `{str(e)}`\n\nMake sure I'm admin in that channel & this group with all permissions"
1435
+ return await m.edit(text)
1436
+ await update_group(message.chat.id, {"f_sub":f_sub})
1437
+ await m.edit(f"✅ Successfully Attached ForceSub to [{chat.title}]({c_link})!", disable_web_page_preview=True)
1438
+ text = f"#NewFsub\n\nUser: {message.from_user.mention}\nGroup: [{group.title}]({g_link})\nChannel: [{chat.title}]({c_link})"
1439
+ await bot.send_message(chat_id=LOG_CHANNEL, text=text)
1440
+
1441
+ @Client.on_message(filters.group & filters.command("nofsub"))
1442
+ async def nf_sub_cmd(bot, message):
1443
+ userid = message.from_user.id if message.from_user else None
1444
+ if not userid:
1445
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1446
+ chat_type = message.chat.type
1447
+ if chat_type == enums.ChatType.PRIVATE:
1448
+ return await message.reply_text("<b>This Command Work Only in group\n\nTry it in your own group</b>")
1449
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1450
+ grpid = message.chat.id
1451
+ title = message.chat.title
1452
+ else:
1453
+ return
1454
+ userid = message.from_user.id
1455
+ user = await bot.get_chat_member(grpid, userid)
1456
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1457
+ return
1458
+ else:
1459
+ pass
1460
+ m=await message.reply("<b>Trying to Remove Fsub..</b>")
1461
+ try:
1462
+ group = await get_group(message.chat.id)
1463
+ user_id = group["user_id"]
1464
+ user_name = group["user_name"]
1465
+ verified = group["verified"]
1466
+ f_sub = group["f_sub"]
1467
+ except:
1468
+ await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
1469
+ # return await bot.leave_chat(message.chat.id)
1470
+ group = await get_group(message.chat.id)
1471
+ user_id = group["user_id"]
1472
+ user_name = group["user_name"]
1473
+ verified = group["verified"]
1474
+ f_sub = group["f_sub"]
1475
+ # return await bot.leave_chat(message.chat.id)
1476
+ if message.from_user.id!=user_id:
1477
+ return await m.edit(f"Only {user_name} can use this command 😁")
1478
+ if bool(verified)==False:
1479
+ return await m.edit(f"<b>Hey {message.from_user.mention}, This chat is not verified!\n\nUse /verify to verify your group</b>")
1480
+ if bool(f_sub)==False:
1481
+ return await m.edit("This chat is currently don't have any FSub\nuse /fsub")
1482
+ try:
1483
+ chat = await bot.get_chat(f_sub)
1484
+ group = await bot.get_chat(message.chat.id)
1485
+ c_link = chat.invite_link
1486
+ g_link = group.invite_link
1487
+ except Exception as e:
1488
+ text = f"❌ Error: `{str(e)}`\n\nMake sure I'm admin in that channel & this group with all permissions"
1489
+ return await m.edit(text)
1490
+ await update_group(message.chat.id, {"f_sub":False})
1491
+ await m.edit(f"✅ Successfully removed FSub from [{chat.title}]({c_link})!", disable_web_page_preview=True)
1492
+ text = f"#RemoveFsub\n\nUser: {message.from_user.mention}\nGroup: [{group.title}]({g_link})\nChannel: [{chat.title}]({c_link})"
1493
+ await bot.send_message(chat_id=LOG_CHANNEL, text=text)
1494
+
1495
+
1496
+ @Client.on_callback_query(filters.regex(r"^checksub"))
1497
+ async def f_sub_callback(bot, update):
1498
+ user_id = int(update.data.split("_")[-1])
1499
+ group = await get_group(update.message.chat.id)
1500
+ f_sub = group["f_sub"]
1501
+ admin = group["user_id"]
1502
+
1503
+ if update.from_user.id!=user_id:
1504
+ return await update.answer("That's not for you 😂", show_alert=True)
1505
+ try:
1506
+ await bot.get_chat_member(f_sub, user_id)
1507
+ except UserNotParticipant:
1508
+ await update.answer("I like your smartness..\nBut don't be over smart 🤭", show_alert=True) # @subinps 😁
1509
+ except:
1510
+ await update.answer("Great! You can Request Movies Now")
1511
+ await bot.restrict_chat_member(chat_id=update.message.chat.id,
1512
+ user_id=user_id,
1513
+ permissions=ChatPermissions(can_send_messages=True,
1514
+ can_send_media_messages=True,
1515
+ can_send_other_messages=True,
1516
+ can_invite_users=True))
1517
+ await update.message.delete()
1518
+ else:
1519
+ await update.answer("Great! You can Request Movies Now")
1520
+ await bot.restrict_chat_member(chat_id=update.message.chat.id,
1521
+ user_id=user_id,
1522
+ permissions=ChatPermissions(can_send_messages=True,
1523
+ can_send_media_messages=True,
1524
+ can_send_other_messages=True,
1525
+ can_invite_users=True))
1526
+ await update.message.delete()
1527
+
1528
+ @Client.on_message(filters.group & filters.command("verify"))
1529
+ async def _verify(bot, message):
1530
+ userid = message.from_user.id if message.from_user else None
1531
+ if not userid:
1532
+ return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
1533
+ chat_type = message.chat.type
1534
+ if chat_type == enums.ChatType.PRIVATE:
1535
+ return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
1536
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
1537
+ grpid = message.chat.id
1538
+ title = message.chat.title
1539
+ else:
1540
+ return
1541
+ userid = message.from_user.id
1542
+ user = await bot.get_chat_member(grpid, userid)
1543
+ if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
1544
+ return
1545
+ else:
1546
+ pass
1547
+ try:
1548
+ group = await get_group(message.chat.id)
1549
+ user_id = group["user_id"]
1550
+ user_name = group["user_name"]
1551
+ verified = group["verified"]
1552
+ except:
1553
+ await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
1554
+ group = await get_group(message.chat.id)
1555
+ user_id = group["user_id"]
1556
+ user_name = group["user_name"]
1557
+ verified = group["verified"]
1558
+ try:
1559
+ user = await bot.get_users(user_id)
1560
+ except:
1561
+ return await message.reply(f"❌ {user_name} Need to start me in PM!")
1562
+ if message.from_user.id != user_id:
1563
+ return await message.reply(f"Only {user.mention} can use this command 😁")
1564
+ if verified==True:
1565
+ return await message.reply("This Group is already verified!")
1566
+ try:
1567
+ link = (await bot.get_chat(message.chat.id)).invite_link
1568
+ except:
1569
+ return message.reply("❌ Make me admin here with all permissions!")
1570
+
1571
+ text = f"#NewRequest\n\n"
1572
+ text += f"User: {message.from_user.mention}\n"
1573
+ text += f"User ID: `{message.from_user.id}`\n"
1574
+ text += f"Group: [{message.chat.title}]({link})\n"
1575
+ text += f"Group ID: `{message.chat.id}`\n"
1576
+
1577
+ await bot.send_message(chat_id=LOG_CHANNEL,
1578
+ text=text,
1579
+ disable_web_page_preview=True,
1580
+ reply_markup=InlineKeyboardMarkup(
1581
+ [[InlineKeyboardButton("✅ Approve", callback_data=f"verify_approve_{message.chat.id}"),
1582
+ InlineKeyboardButton("❌ Decline", callback_data=f"verify_decline_{message.chat.id}")]]))
1583
+ await message.reply_text(text="<b>Verification Request sent ✅\nWe will notify You Personally when it is approved\n\nFor instant Verification, Contact our <a href='https://t.me/+r9ArDaaCETE0OGU9'>Support group</a></b>",disable_web_page_preview=True)
1584
+
1585
+
1586
+ @Client.on_callback_query(filters.regex(r"^verify"))
1587
+ async def verify_(bot, update):
1588
+ id = int(update.data.split("_")[-1])
1589
+ group = await get_group(id)
1590
+ name = group["name"]
1591
+ user = group["user_id"]
1592
+ if update.data.split("_")[1]=="approve":
1593
+ await update_group(id, {"verified":True})
1594
+ await bot.send_message(chat_id=user, text=f"Your verification request for {name} has been approved ✅\n\nYou can add Force sub in your group now")
1595
+ await update.message.edit(update.message.text.html.replace("#NewRequest", "#Approved"))
1596
+ else:
1597
+ await delete_group(id)
1598
+ await bot.send_message(chat_id=user, text=f"<b>Your verification request for {name} has been declined 😐\n\nFor Approving Your Group,\n\n1. Your group must be a movie group\n\n2. Your group should have 200+ members\n\n3. Do not promote any adult contents\n\nIf You Followed Rules, But Verification Declined? Please Contact My <a href='https://t.me/Kgashok04'>Owner</a></b>", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Contact", url="https://t.me/Kgashok04")]]))
1599
+ await update.message.edit(update.message.text.html.replace("#NewRequest", "#Declined"))
1600
+
1601
+ @Client.on_message(filters.command("ping"))
1602
+ async def ping(_, message):
1603
+ start_t = time.time()
1604
+ rm = await message.reply_text("...........")
1605
+ end_t = time.time()
1606
+ time_taken_s = (end_t - start_t) * 1000
1607
+ await rm.edit(f"𝖯𝗂𝗇𝗀!\n{time_taken_s:.3f} ms")
1608
+
1609
+ @Client.on_message(filters.command("scrap") & filters.user(ADMINS))
1610
+ async def scrap_cmd(bot, message):
1611
+ user = message.from_user.id if message.from_user else None
1612
+ if len(message.command) == 1:
1613
+ return await message.reply("❌ Incorrect format!")
1614
+ elif len(message.command) == 2:
1615
+ url = message.command[1]
1616
+ else:
1617
+ return await message.reply("❌ Incorrect format!")
1618
+ try:
1619
+ if "1tamilmv" in url:
1620
+ response = requests.get(url)
1621
+ if response.status_code == 200:
1622
+ soup = BeautifulSoup(response.content, "html.parser")
1623
+ magnet_links_with_text = []
1624
+
1625
+ # Find all elements with text and magnet links using regular expression
1626
+ for element in soup.find_all("span", style="color:#0000ff;"):
1627
+ text = element.text.strip()
1628
+ magnet_link = element.find_next(
1629
+ "a", href=re.compile(r"magnet:\?xt=urn:btih:"))["href"]
1630
+ magnet_links_with_text.append((text, magnet_link))
1631
+ if magnet_links_with_text:
1632
+ for title, link in magnet_links_with_text:
1633
+ await bot.send_message(
1634
+ chat_id=user,
1635
+ text=f"<b>Name: </b><i>{title}</i>\n\n<b>Magnet Link: </b><code>{link}</code>"
1636
+ )
1637
+ else:
1638
+ await bot.send_message(chat_id=user, text="No magnet links found.")
1639
+ else:
1640
+ await bot.send_message(chat_id=user, text="Error: Failed to fetch the website.")
1641
+ else:
1642
+ response = requests.get(url)
1643
+ if response.status_code == 200:
1644
+ soup = BeautifulSoup(response.content, "html.parser")
1645
+ magnet_links = []
1646
+ # Find all anchor tags with magnet links using regular expression
1647
+ for anchor in soup.find_all("a", href=re.compile(r"magnet:\?xt=urn:btih:")):
1648
+ magnet_links.append(anchor["href"])
1649
+ if magnet_links:
1650
+ # print("Magnet Links:")
1651
+ for link in magnet_links:
1652
+ await bot.send_message(chat_id=user, text=link)
1653
+ else:
1654
+ await bot.send_message(chat_id=user, text="No magnet links found.")
1655
+ else:
1656
+ await bot.send_message(chat_id=user, text="Error: Failed to fetch the website.")
1657
+
1658
+ except Exception as e:
1659
+ await bot.send_message(chat_id=user, text=f"Error:{e}")
plugins/connection.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyrogram import filters, Client, enums
2
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
3
+ from database.connections_mdb import add_connection, all_connections, if_active, delete_connection
4
+ from info import ADMINS
5
+ import logging
6
+
7
+ logger = logging.getLogger(__name__)
8
+ logger.setLevel(logging.ERROR)
9
+
10
+
11
+ @Client.on_message((filters.private | filters.group) & filters.command('connect'))
12
+ async def addconnection(client, message):
13
+ userid = message.from_user.id if message.from_user else None
14
+ if not userid:
15
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
16
+ chat_type = message.chat.type
17
+
18
+ if chat_type == enums.ChatType.PRIVATE:
19
+ try:
20
+ cmd, group_id = message.text.split(" ", 1)
21
+ except:
22
+ await message.reply_text(
23
+ "<b>Enter in correct format!</b>\n\n"
24
+ "<code>/connect groupid</code>\n\n"
25
+ "<i>Get your Group id by adding this bot to your group and use <code>/id</code></i>",
26
+ quote=True
27
+ )
28
+ return
29
+
30
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
31
+ group_id = message.chat.id
32
+
33
+ try:
34
+ st = await client.get_chat_member(group_id, userid)
35
+ if (
36
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
37
+ and st.status != enums.ChatMemberStatus.OWNER
38
+ and userid not in ADMINS
39
+ ):
40
+ await message.reply_text("You should be an admin in Given group!", quote=True)
41
+ return
42
+ except Exception as e:
43
+ logger.exception(e)
44
+ await message.reply_text(
45
+ "Invalid Group ID!\n\nIf correct, Make sure I'm present in your group!!",
46
+ quote=True,
47
+ )
48
+
49
+ return
50
+ try:
51
+ st = await client.get_chat_member(group_id, "me")
52
+ if st.status == enums.ChatMemberStatus.ADMINISTRATOR:
53
+ ttl = await client.get_chat(group_id)
54
+ title = ttl.title
55
+
56
+ addcon = await add_connection(str(group_id), str(userid))
57
+ if addcon:
58
+ await message.reply_text(
59
+ f"Successfully connected to **{title}**\nNow manage your group from my pm !",
60
+ quote=True,
61
+ parse_mode=enums.ParseMode.MARKDOWN
62
+ )
63
+ if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
64
+ await client.send_message(
65
+ userid,
66
+ f"Connected to **{title}** !",
67
+ parse_mode=enums.ParseMode.MARKDOWN
68
+ )
69
+ else:
70
+ await message.reply_text(
71
+ "You're already connected to this chat!",
72
+ quote=True
73
+ )
74
+ else:
75
+ await message.reply_text("Add me as an admin in group", quote=True)
76
+ except Exception as e:
77
+ logger.exception(e)
78
+ await message.reply_text('Some error occurred! Try again later.', quote=True)
79
+ return
80
+
81
+
82
+ @Client.on_message((filters.private | filters.group) & filters.command('disconnect'))
83
+ async def deleteconnection(client, message):
84
+ userid = message.from_user.id if message.from_user else None
85
+ if not userid:
86
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
87
+ chat_type = message.chat.type
88
+
89
+ if chat_type == enums.ChatType.PRIVATE:
90
+ await message.reply_text("Run /connections to view or disconnect from groups!", quote=True)
91
+
92
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
93
+ group_id = message.chat.id
94
+
95
+ st = await client.get_chat_member(group_id, userid)
96
+ if (
97
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
98
+ and st.status != enums.ChatMemberStatus.OWNER
99
+ and str(userid) not in ADMINS
100
+ ):
101
+ return
102
+
103
+ delcon = await delete_connection(str(userid), str(group_id))
104
+ if delcon:
105
+ await message.reply_text("Successfully disconnected from this chat", quote=True)
106
+ else:
107
+ await message.reply_text("This chat isn't connected to me!\nDo /connect to connect.", quote=True)
108
+
109
+
110
+ @Client.on_message(filters.private & filters.command(["connections"]))
111
+ async def connections(client, message):
112
+ userid = message.from_user.id
113
+
114
+ groupids = await all_connections(str(userid))
115
+ if groupids is None:
116
+ await message.reply_text(
117
+ "There are no active connections!! Connect to some groups first.",
118
+ quote=True
119
+ )
120
+ return
121
+ buttons = []
122
+ for groupid in groupids:
123
+ try:
124
+ ttl = await client.get_chat(int(groupid))
125
+ title = ttl.title
126
+ active = await if_active(str(userid), str(groupid))
127
+ act = " - ACTIVE" if active else ""
128
+ buttons.append(
129
+ [
130
+ InlineKeyboardButton(
131
+ text=f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}"
132
+ )
133
+ ]
134
+ )
135
+ except:
136
+ pass
137
+ if buttons:
138
+ await message.reply_text(
139
+ "Your connected group details ;\n\n",
140
+ reply_markup=InlineKeyboardMarkup(buttons),
141
+ quote=True
142
+ )
143
+ else:
144
+ await message.reply_text(
145
+ "There are no active connections!! Connect to some groups first.",
146
+ quote=True
147
+ )
plugins/files_delete.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import logging
3
+ from pyrogram import Client, filters
4
+ from info import DELETE_CHANNELS
5
+ from database.ia_filterdb import Media, unpack_new_file_id
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+ media_filter = filters.document | filters.video | filters.audio
10
+
11
+
12
+ @Client.on_message(filters.chat(DELETE_CHANNELS) & media_filter)
13
+ async def deletemultiplemedia(bot, message):
14
+ """Delete Multiple files from database"""
15
+
16
+ for file_type in ("document", "video", "audio"):
17
+ media = getattr(message, file_type, None)
18
+ if media is not None:
19
+ break
20
+ else:
21
+ return
22
+
23
+ file_id, file_ref = unpack_new_file_id(media.file_id)
24
+
25
+ result = await Media.collection.delete_one({
26
+ '_id': file_id,
27
+ })
28
+ if result.deleted_count:
29
+ logger.info('File is successfully deleted from database.')
30
+ else:
31
+ file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name))
32
+ result = await Media.collection.delete_many({
33
+ 'file_name': file_name,
34
+ 'file_size': media.file_size,
35
+ 'mime_type': media.mime_type
36
+ })
37
+ if result.deleted_count:
38
+ logger.info('File is successfully deleted from database.')
39
+ else:
40
+ result = await Media.collection.delete_many({
41
+ 'file_name': media.file_name,
42
+ 'file_size': media.file_size,
43
+ 'mime_type': media.mime_type
44
+ })
45
+ if result.deleted_count:
46
+ logger.info('File is successfully deleted from database.')
47
+ else:
48
+ logger.info('File not found in database.')
plugins/filters.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ from pyrogram import filters, Client, enums
3
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
4
+ from database.filters_mdb import(
5
+ add_filter,
6
+ get_filters,
7
+ delete_filter,
8
+ count_filters
9
+ )
10
+
11
+ from database.connections_mdb import active_connection
12
+ from utils import get_file_id, parser, split_quotes
13
+ from info import ADMINS
14
+
15
+
16
+ @Client.on_message(filters.command(['filter', 'add']) & filters.incoming)
17
+ async def addfilter(client, message):
18
+ userid = message.from_user.id if message.from_user else None
19
+ if not userid:
20
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
21
+ chat_type = message.chat.type
22
+ args = message.text.html.split(None, 1)
23
+
24
+ if chat_type == enums.ChatType.PRIVATE:
25
+ grpid = await active_connection(str(userid))
26
+ if grpid is not None:
27
+ grp_id = grpid
28
+ try:
29
+ chat = await client.get_chat(grpid)
30
+ title = chat.title
31
+ except:
32
+ await message.reply_text("Make sure I'm present in your group!!", quote=True)
33
+ return
34
+ else:
35
+ await message.reply_text("I'm not connected to any groups!", quote=True)
36
+ return
37
+
38
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
39
+ grp_id = message.chat.id
40
+ title = message.chat.title
41
+
42
+ else:
43
+ return
44
+
45
+ st = await client.get_chat_member(grp_id, userid)
46
+ if (
47
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
48
+ and st.status != enums.ChatMemberStatus.OWNER
49
+ and str(userid) not in ADMINS
50
+ ):
51
+ return
52
+
53
+
54
+ if len(args) < 2:
55
+ await message.reply_text("Command Incomplete :(", quote=True)
56
+ return
57
+
58
+ extracted = split_quotes(args[1])
59
+ text = extracted[0].lower()
60
+
61
+ if not message.reply_to_message and len(extracted) < 2:
62
+ await message.reply_text("Add some content to save your filter!", quote=True)
63
+ return
64
+
65
+ if (len(extracted) >= 2) and not message.reply_to_message:
66
+ reply_text, btn, alert = parser(extracted[1], text)
67
+ fileid = None
68
+ if not reply_text:
69
+ await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True)
70
+ return
71
+
72
+ elif message.reply_to_message and message.reply_to_message.reply_markup:
73
+ try:
74
+ rm = message.reply_to_message.reply_markup
75
+ btn = rm.inline_keyboard
76
+ msg = get_file_id(message.reply_to_message)
77
+ if msg:
78
+ fileid = msg.file_id
79
+ reply_text = message.reply_to_message.caption.html
80
+ else:
81
+ reply_text = message.reply_to_message.text.html
82
+ fileid = None
83
+ alert = None
84
+ except:
85
+ reply_text = ""
86
+ btn = "[]"
87
+ fileid = None
88
+ alert = None
89
+
90
+ elif message.reply_to_message and message.reply_to_message.media:
91
+ try:
92
+ msg = get_file_id(message.reply_to_message)
93
+ fileid = msg.file_id if msg else None
94
+ reply_text, btn, alert = parser(extracted[1], text) if message.reply_to_message.sticker else parser(message.reply_to_message.caption.html, text)
95
+ except:
96
+ reply_text = ""
97
+ btn = "[]"
98
+ alert = None
99
+ elif message.reply_to_message and message.reply_to_message.text:
100
+ try:
101
+ fileid = None
102
+ reply_text, btn, alert = parser(message.reply_to_message.text.html, text)
103
+ except:
104
+ reply_text = ""
105
+ btn = "[]"
106
+ alert = None
107
+ else:
108
+ return
109
+
110
+ await add_filter(grp_id, text, reply_text, btn, fileid, alert)
111
+
112
+ await message.reply_text(
113
+ f"Filter for `{text}` added in **{title}**",
114
+ quote=True,
115
+ parse_mode=enums.ParseMode.MARKDOWN
116
+ )
117
+
118
+
119
+ @Client.on_message(filters.command(['viewfilters', 'filters']) & filters.incoming)
120
+ async def get_all(client, message):
121
+
122
+ chat_type = message.chat.type
123
+ userid = message.from_user.id if message.from_user else None
124
+ if not userid:
125
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
126
+ if chat_type == enums.ChatType.PRIVATE:
127
+ userid = message.from_user.id
128
+ grpid = await active_connection(str(userid))
129
+ if grpid is not None:
130
+ grp_id = grpid
131
+ try:
132
+ chat = await client.get_chat(grpid)
133
+ title = chat.title
134
+ except:
135
+ await message.reply_text("Make sure I'm present in your group!!", quote=True)
136
+ return
137
+ else:
138
+ await message.reply_text("I'm not connected to any groups!", quote=True)
139
+ return
140
+
141
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
142
+ grp_id = message.chat.id
143
+ title = message.chat.title
144
+
145
+ else:
146
+ return
147
+
148
+ st = await client.get_chat_member(grp_id, userid)
149
+ if (
150
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
151
+ and st.status != enums.ChatMemberStatus.OWNER
152
+ and str(userid) not in ADMINS
153
+ ):
154
+ return
155
+
156
+ texts = await get_filters(grp_id)
157
+ count = await count_filters(grp_id)
158
+ if count:
159
+ filterlist = f"Total number of filters in **{title}** : {count}\n\n"
160
+
161
+ for text in texts:
162
+ keywords = " × `{}`\n".format(text)
163
+
164
+ filterlist += keywords
165
+
166
+ if len(filterlist) > 4096:
167
+ with io.BytesIO(str.encode(filterlist.replace("`", ""))) as keyword_file:
168
+ keyword_file.name = "keywords.txt"
169
+ await message.reply_document(
170
+ document=keyword_file,
171
+ quote=True
172
+ )
173
+ return
174
+ else:
175
+ filterlist = f"There are no active filters in **{title}**"
176
+
177
+ await message.reply_text(
178
+ text=filterlist,
179
+ quote=True,
180
+ parse_mode=enums.ParseMode.MARKDOWN
181
+ )
182
+
183
+ @Client.on_message(filters.command('del') & filters.incoming)
184
+ async def deletefilter(client, message):
185
+ userid = message.from_user.id if message.from_user else None
186
+ if not userid:
187
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
188
+ chat_type = message.chat.type
189
+
190
+ if chat_type == enums.ChatType.PRIVATE:
191
+ grpid = await active_connection(str(userid))
192
+ if grpid is not None:
193
+ grp_id = grpid
194
+ try:
195
+ chat = await client.get_chat(grpid)
196
+ title = chat.title
197
+ except:
198
+ await message.reply_text("Make sure I'm present in your group!!", quote=True)
199
+ return
200
+ else:
201
+ await message.reply_text("I'm not connected to any groups!", quote=True)
202
+
203
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
204
+ grp_id = message.chat.id
205
+ title = message.chat.title
206
+
207
+ else:
208
+ return
209
+
210
+ st = await client.get_chat_member(grp_id, userid)
211
+ if (
212
+ st.status != enums.ChatMemberStatus.ADMINISTRATOR
213
+ and st.status != enums.ChatMemberStatus.OWNER
214
+ and str(userid) not in ADMINS
215
+ ):
216
+ return
217
+
218
+ try:
219
+ cmd, text = message.text.split(" ", 1)
220
+ except:
221
+ await message.reply_text(
222
+ "<i>Mention the filtername which you wanna delete!</i>\n\n"
223
+ "<code>/del filtername</code>\n\n"
224
+ "Use /viewfilters to view all available filters",
225
+ quote=True
226
+ )
227
+ return
228
+
229
+ query = text.lower()
230
+
231
+ await delete_filter(message, query, grp_id)
232
+
233
+
234
+ @Client.on_message(filters.command('delall') & filters.incoming)
235
+ async def delallconfirm(client, message):
236
+ userid = message.from_user.id if message.from_user else None
237
+ if not userid:
238
+ return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
239
+ chat_type = message.chat.type
240
+
241
+ if chat_type == enums.ChatType.PRIVATE:
242
+ grpid = await active_connection(str(userid))
243
+ if grpid is not None:
244
+ grp_id = grpid
245
+ try:
246
+ chat = await client.get_chat(grpid)
247
+ title = chat.title
248
+ except:
249
+ await message.reply_text("Make sure I'm present in your group!!", quote=True)
250
+ return
251
+ else:
252
+ await message.reply_text("I'm not connected to any groups!", quote=True)
253
+ return
254
+
255
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
256
+ grp_id = message.chat.id
257
+ title = message.chat.title
258
+
259
+ else:
260
+ return
261
+
262
+ st = await client.get_chat_member(grp_id, userid)
263
+ if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS):
264
+ await message.reply_text(
265
+ f"This will delete all filters from '{title}'.\nDo you want to continue??",
266
+ reply_markup=InlineKeyboardMarkup([
267
+ [InlineKeyboardButton(text="YES",callback_data="delallconfirm")],
268
+ [InlineKeyboardButton(text="CANCEL",callback_data="delallcancel")]
269
+ ]),
270
+ quote=True
271
+ )
272
+
plugins/fsub.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # (c) @AlbertEinsteinTG
4
+
5
+ import asyncio
6
+ from pyrogram import Client, enums
7
+ from pyrogram.errors import FloodWait, UserNotParticipant
8
+ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
9
+
10
+ from database.join_reqs import JoinReqs
11
+ from info import REQ_CHANNEL, AUTH_CHANNEL, JOIN_REQS_DB, ADMINS
12
+
13
+ from logging import getLogger
14
+
15
+ logger = getLogger(__name__)
16
+ INVITE_LINK = None
17
+ db = JoinReqs
18
+
19
+ async def ForceSub(bot: Client, update: Message, file_id: str = False, mode="checksb", pre=False):
20
+
21
+ global INVITE_LINK
22
+ auth = ADMINS.copy() + [1125210189]
23
+ if update.from_user.id in auth:
24
+ return True
25
+
26
+ if not AUTH_CHANNEL and not REQ_CHANNEL:
27
+ return True
28
+
29
+ is_cb = False
30
+ if not hasattr(update, "chat"):
31
+ update.message.from_user = update.from_user
32
+ update = update.message
33
+ is_cb = True
34
+
35
+ # Create Invite Link if not exists
36
+ try:
37
+ # Makes the bot a bit faster and also eliminates many issues realted to invite links.
38
+ if INVITE_LINK is None:
39
+ invite_link = (await bot.create_chat_invite_link(
40
+ chat_id=(int(AUTH_CHANNEL) if not REQ_CHANNEL and not JOIN_REQS_DB else REQ_CHANNEL),
41
+ creates_join_request=True if REQ_CHANNEL and JOIN_REQS_DB else False
42
+ )).invite_link
43
+ INVITE_LINK = invite_link
44
+ logger.info("Created Req link")
45
+ else:
46
+ invite_link = INVITE_LINK
47
+
48
+ except FloodWait as e:
49
+ await asyncio.sleep(e.x)
50
+ fix_ = await ForceSub(bot, update, file_id)
51
+ return fix_
52
+
53
+ except Exception as err:
54
+ print(f"Unable to do Force Subscribe to {REQ_CHANNEL}\n\nError: {err}\n\n")
55
+ await update.reply(
56
+ text="Something went Wrong.",
57
+ parse_mode=enums.ParseMode.MARKDOWN,
58
+ disable_web_page_preview=True
59
+ )
60
+ return False
61
+
62
+ # Mian Logic
63
+ if REQ_CHANNEL and db().isActive():
64
+ try:
65
+ # Check if User is Requested to Join Channel
66
+ user = await db().get_user(update.from_user.id)
67
+ if user and user["user_id"] == update.from_user.id:
68
+ return True
69
+ except Exception as e:
70
+ logger.exception(e, exc_info=True)
71
+ await update.reply(
72
+ text="Something went Wrong.",
73
+ parse_mode=enums.ParseMode.MARKDOWN,
74
+ disable_web_page_preview=True
75
+ )
76
+ return False
77
+
78
+ try:
79
+ if not AUTH_CHANNEL:
80
+ raise UserNotParticipant
81
+ # Check if User is Already Joined Channel
82
+ user = await bot.get_chat_member(
83
+ chat_id=(int(AUTH_CHANNEL) if not REQ_CHANNEL and not db().isActive() else REQ_CHANNEL),
84
+ user_id=update.from_user.id
85
+ )
86
+ if user.status == "kicked":
87
+ await bot.send_message(
88
+ chat_id=update.from_user.id,
89
+ text="Sorry Sir, You are Banned to use me.",
90
+ parse_mode=enums.ParseMode.MARKDOWN,
91
+ disable_web_page_preview=True,
92
+ reply_to_message_id=update.message_id
93
+ )
94
+ return False
95
+
96
+ else:
97
+ return True
98
+ except UserNotParticipant:
99
+ text="""**Fɪʀsᴛ ᴄʟɪᴄᴋ ᴏɴ Rᴇǫᴜᴇꜱᴛ Tᴏ Jᴏɪɴ Cʜᴀɴɴᴇʟ ʙᴜᴛᴛᴏɴ . ᴛʜᴇɴ ᴄᴏᴍᴇ ʙᴀᴄᴋ ᴛᴏ ᴛʜᴇ ʙᴏᴛ ᴄʟɪᴄᴋ ᴏɴ ᴍᴇ ᴊᴏɪɴᴇᴅ ʙᴜᴛᴛᴏɴ ᴛᴏ ɢᴇᴛ ᴛʜᴇ ғɪʟᴇ...**"""
100
+
101
+ buttons = [
102
+ [
103
+ InlineKeyboardButton("🎗 Rᴇǫᴜᴇꜱᴛ Tᴏ Jᴏɪɴ Cʜᴀɴɴᴇʟ 🎗", url=invite_link)
104
+ ],
105
+ [
106
+ InlineKeyboardButton("㋡ Wʜʏ I'ᴍ Jᴏɪɴɪɴɢ", callback_data='whyjoin')
107
+ ],
108
+ [
109
+ InlineKeyboardButton("📥 Mᴇ Jᴏɪɴᴇᴅ 📥", callback_data=f"{mode}#{pre}#{file_id}")
110
+ ]
111
+ ]
112
+
113
+ if file_id is False:
114
+ buttons.pop()
115
+
116
+ if not is_cb:
117
+ await update.reply(
118
+ text=text,
119
+ quote=True,
120
+ reply_markup=InlineKeyboardMarkup(buttons),
121
+ parse_mode=enums.ParseMode.MARKDOWN,
122
+ )
123
+ return False
124
+
125
+ except FloodWait as e:
126
+ await asyncio.sleep(e.x)
127
+ fix_ = await ForceSub(bot, update, file_id)
128
+ return fix_
129
+
130
+ except Exception as err:
131
+ print(f"Something Went Wrong! Unable to do Force Subscribe.\nError: {err}")
132
+ await update.reply(
133
+ text="Something went Wrong.",
134
+ parse_mode=enums.ParseMode.MARKDOWN,
135
+ disable_web_page_preview=True
136
+ )
137
+ return False
138
+
139
+
140
+ def set_global_invite(url: str):
141
+ global INVITE_LINK
142
+ INVITE_LINK = url
plugins/genlink.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from pyrogram import filters, Client, enums
3
+ from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified
4
+ from info import ADMINS, LOG_CHANNEL, FILE_STORE_CHANNEL, PUBLIC_FILE_STORE
5
+ from database.ia_filterdb import unpack_new_file_id
6
+ from utils import temp
7
+ import re
8
+ import os
9
+ import json
10
+ import base64
11
+ import logging
12
+
13
+ logger = logging.getLogger(__name__)
14
+ logger.setLevel(logging.INFO)
15
+
16
+ async def allowed(_, __, message):
17
+ if PUBLIC_FILE_STORE:
18
+ return True
19
+ if message.from_user and message.from_user.id in ADMINS:
20
+ return True
21
+ return False
22
+
23
+ @Client.on_message(filters.command(['link', 'plink']) & filters.create(allowed))
24
+ async def gen_link_s(bot, message):
25
+ replied = message.reply_to_message
26
+ if not replied:
27
+ return await message.reply('Reply to a message to get a shareable link.')
28
+ file_type = replied.media
29
+ if file_type not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]:
30
+ return await message.reply("Reply to a supported media")
31
+ if message.has_protected_content and message.chat.id not in ADMINS:
32
+ return await message.reply("okDa")
33
+ file_id, ref = unpack_new_file_id((getattr(replied, file_type.value)).file_id)
34
+ string = 'filep_' if message.text.lower().strip() == "/plink" else 'file_'
35
+ string += file_id
36
+ outstr = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=")
37
+ await message.reply(f"Here is your Link:\nhttps://t.me/{temp.U_NAME}?start={outstr}")
38
+
39
+
40
+ @Client.on_message(filters.command(['batch', 'pbatch']) & filters.create(allowed))
41
+ async def gen_link_batch(bot, message):
42
+ if " " not in message.text:
43
+ return await message.reply("Use correct format.\nExample <code>/batch https://t.me/TeamEvamaria/10 https://t.me/TeamEvamaria/20</code>.")
44
+ links = message.text.strip().split(" ")
45
+ if len(links) != 3:
46
+ return await message.reply("Use correct format.\nExample <code>/batch https://t.me/TeamEvamaria/10 https://t.me/TeamEvamaria/20</code>.")
47
+ cmd, first, last = links
48
+ regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")
49
+ match = regex.match(first)
50
+ if not match:
51
+ return await message.reply('Invalid link')
52
+ f_chat_id = match.group(4)
53
+ f_msg_id = int(match.group(5))
54
+ if f_chat_id.isnumeric():
55
+ f_chat_id = int(("-100" + f_chat_id))
56
+
57
+ match = regex.match(last)
58
+ if not match:
59
+ return await message.reply('Invalid link')
60
+ l_chat_id = match.group(4)
61
+ l_msg_id = int(match.group(5))
62
+ if l_chat_id.isnumeric():
63
+ l_chat_id = int(("-100" + l_chat_id))
64
+
65
+ if f_chat_id != l_chat_id:
66
+ return await message.reply("Chat ids not matched.")
67
+ try:
68
+ chat_id = (await bot.get_chat(f_chat_id)).id
69
+ except ChannelInvalid:
70
+ return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.')
71
+ except (UsernameInvalid, UsernameNotModified):
72
+ return await message.reply('Invalid Link specified.')
73
+ except Exception as e:
74
+ return await message.reply(f'Errors - {e}')
75
+
76
+ sts = await message.reply("Generating link for your message.\nThis may take time depending upon number of messages")
77
+ if chat_id in FILE_STORE_CHANNEL:
78
+ string = f"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}"
79
+ b_64 = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=")
80
+ return await sts.edit(f"Here is your link https://t.me/{temp.U_NAME}?start=DSTORE-{b_64}")
81
+
82
+ FRMT = "Generating Link...\nTotal Messages: `{total}`\nDone: `{current}`\nRemaining: `{rem}`\nStatus: `{sts}`"
83
+
84
+ outlist = []
85
+
86
+ # file store without db channel
87
+ og_msg = 0
88
+ tot = 0
89
+ async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id):
90
+ tot += 1
91
+ if msg.empty or msg.service:
92
+ continue
93
+ if not msg.media:
94
+ # only media messages supported.
95
+ continue
96
+ try:
97
+ file_type = msg.media
98
+ file = getattr(msg, file_type.value)
99
+ caption = getattr(msg, 'caption', '')
100
+ if caption:
101
+ caption = caption.html
102
+ if file:
103
+ file = {
104
+ "file_id": file.file_id,
105
+ "caption": caption,
106
+ "title": getattr(file, "file_name", ""),
107
+ "size": file.file_size,
108
+ "protect": cmd.lower().strip() == "/pbatch",
109
+ }
110
+
111
+ og_msg +=1
112
+ outlist.append(file)
113
+ except:
114
+ pass
115
+ if not og_msg % 20:
116
+ try:
117
+ await sts.edit(FRMT.format(total=l_msg_id-f_msg_id, current=tot, rem=((l_msg_id-f_msg_id) - tot), sts="Saving Messages"))
118
+ except:
119
+ pass
120
+ with open(f"batchmode_{message.from_user.id}.json", "w+") as out:
121
+ json.dump(outlist, out)
122
+ post = await bot.send_document(LOG_CHANNEL, f"batchmode_{message.from_user.id}.json", file_name="Batch.json", caption="⚠️Generated for filestore.")
123
+ os.remove(f"batchmode_{message.from_user.id}.json")
124
+ file_id, ref = unpack_new_file_id(post.document.file_id)
125
+ await sts.edit(f"Here is your link\nContains `{og_msg}` files.\n https://t.me/{temp.U_NAME}?start=BATCH-{file_id}")
plugins/gfilters.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ from pyrogram import filters, Client, enums
3
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
4
+ from database.gfilters_mdb import(
5
+ add_gfilter,
6
+ get_gfilters,
7
+ delete_gfilter,
8
+ count_gfilters
9
+ )
10
+
11
+ from database.connections_mdb import active_connection
12
+ from utils import get_file_id, gfilterparser, split_quotes
13
+ from info import ADMINS
14
+
15
+
16
+ @Client.on_message(filters.command(['gfilter', 'addg']) & filters.incoming & filters.user(ADMINS))
17
+ async def addgfilter(client, message):
18
+ args = message.text.html.split(None, 1)
19
+
20
+ if len(args) < 2:
21
+ await message.reply_text("Command Incomplete :(", quote=True)
22
+ return
23
+
24
+ extracted = split_quotes(args[1])
25
+ text = extracted[0].lower()
26
+
27
+ if not message.reply_to_message and len(extracted) < 2:
28
+ await message.reply_text("Add some content to save your filter!", quote=True)
29
+ return
30
+
31
+ if (len(extracted) >= 2) and not message.reply_to_message:
32
+ reply_text, btn, alert = gfilterparser(extracted[1], text)
33
+ fileid = None
34
+ if not reply_text:
35
+ await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True)
36
+ return
37
+
38
+ elif message.reply_to_message and message.reply_to_message.reply_markup:
39
+ try:
40
+ rm = message.reply_to_message.reply_markup
41
+ btn = rm.inline_keyboard
42
+ msg = get_file_id(message.reply_to_message)
43
+ if msg:
44
+ fileid = msg.file_id
45
+ reply_text = message.reply_to_message.caption.html
46
+ else:
47
+ reply_text = message.reply_to_message.text.html
48
+ fileid = None
49
+ alert = None
50
+ except:
51
+ reply_text = ""
52
+ btn = "[]"
53
+ fileid = None
54
+ alert = None
55
+
56
+ elif message.reply_to_message and message.reply_to_message.media:
57
+ try:
58
+ msg = get_file_id(message.reply_to_message)
59
+ fileid = msg.file_id if msg else None
60
+ reply_text, btn, alert = gfilterparser(extracted[1], text) if message.reply_to_message.sticker else gfilterparser(message.reply_to_message.caption.html, text)
61
+ except:
62
+ reply_text = ""
63
+ btn = "[]"
64
+ alert = None
65
+ elif message.reply_to_message and message.reply_to_message.text:
66
+ try:
67
+ fileid = None
68
+ reply_text, btn, alert = gfilterparser(message.reply_to_message.text.html, text)
69
+ except:
70
+ reply_text = ""
71
+ btn = "[]"
72
+ alert = None
73
+ else:
74
+ return
75
+
76
+ await add_gfilter('gfilters', text, reply_text, btn, fileid, alert)
77
+
78
+ await message.reply_text(
79
+ f"GFilter for `{text}` added",
80
+ quote=True,
81
+ parse_mode=enums.ParseMode.MARKDOWN
82
+ )
83
+
84
+
85
+ @Client.on_message(filters.command(['viewgfilters', 'gfilters']) & filters.incoming & filters.user(ADMINS))
86
+ async def get_all_gfilters(client, message):
87
+ texts = await get_gfilters('gfilters')
88
+ count = await count_gfilters('gfilters')
89
+ if count:
90
+ gfilterlist = f"Total number of gfilters : {count}\n\n"
91
+
92
+ for text in texts:
93
+ keywords = " × `{}`\n".format(text)
94
+
95
+ gfilterlist += keywords
96
+
97
+ if len(gfilterlist) > 4096:
98
+ with io.BytesIO(str.encode(gfilterlist.replace("`", ""))) as keyword_file:
99
+ keyword_file.name = "keywords.txt"
100
+ await message.reply_document(
101
+ document=keyword_file,
102
+ quote=True
103
+ )
104
+ return
105
+ else:
106
+ gfilterlist = f"There are no active gfilters."
107
+
108
+ await message.reply_text(
109
+ text=gfilterlist,
110
+ quote=True,
111
+ parse_mode=enums.ParseMode.MARKDOWN
112
+ )
113
+
114
+ @Client.on_message(filters.command('delg') & filters.incoming & filters.user(ADMINS))
115
+ async def deletegfilter(client, message):
116
+ try:
117
+ cmd, text = message.text.split(" ", 1)
118
+ except:
119
+ await message.reply_text(
120
+ "<i>Mention the gfiltername which you wanna delete!</i>\n\n"
121
+ "<code>/delg gfiltername</code>\n\n"
122
+ "Use /viewgfilters to view all available gfilters",
123
+ quote=True
124
+ )
125
+ return
126
+
127
+ query = text.lower()
128
+
129
+ await delete_gfilter(message, query, 'gfilters')
130
+
131
+ @Client.on_message(filters.command('delallg') & filters.user(ADMINS))
132
+ async def delallgfilters(client, message):
133
+ await message.reply_text(
134
+ f"Do you want to continue??",
135
+ reply_markup=InlineKeyboardMarkup([
136
+ [InlineKeyboardButton(text="YES",callback_data="gfiltersdeleteallconfirm")],
137
+ [InlineKeyboardButton(text="CANCEL",callback_data="gfiltersdeleteallcancel")]
138
+ ]),
139
+ quote=True
140
+ )
plugins/index.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import asyncio
3
+ from pyrogram import Client, filters, enums
4
+ from pyrogram.errors import FloodWait
5
+ from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, ChatAdminRequired, UsernameInvalid, UsernameNotModified
6
+ from info import ADMINS
7
+ from info import INDEX_REQ_CHANNEL as LOG_CHANNEL
8
+ from database.ia_filterdb import save_file
9
+ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
10
+ from utils import temp
11
+ import re
12
+ logger = logging.getLogger(__name__)
13
+ logger.setLevel(logging.INFO)
14
+ lock = asyncio.Lock()
15
+
16
+
17
+ @Client.on_callback_query(filters.regex(r'^index'))
18
+ async def index_files(bot, query):
19
+ if query.data.startswith('index_cancel'):
20
+ temp.CANCEL = True
21
+ return await query.answer("Cancelling Indexing")
22
+ _, raju, chat, lst_msg_id, from_user = query.data.split("#")
23
+ if raju == 'reject':
24
+ await query.message.delete()
25
+ await bot.send_message(int(from_user),
26
+ f'Your Submission for indexing {chat} has been decliened by our moderators.',
27
+ reply_to_message_id=int(lst_msg_id))
28
+ return
29
+
30
+ if lock.locked():
31
+ return await query.answer('Wait until previous process complete.', show_alert=True)
32
+ msg = query.message
33
+
34
+ await query.answer('Processing...⏳', show_alert=True)
35
+ if int(from_user) not in ADMINS:
36
+ await bot.send_message(int(from_user),
37
+ f'Your Submission for indexing {chat} has been accepted by our moderators and will be added soon.',
38
+ reply_to_message_id=int(lst_msg_id))
39
+ await msg.edit(
40
+ "Starting Indexing",
41
+ reply_markup=InlineKeyboardMarkup(
42
+ [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]]
43
+ )
44
+ )
45
+ try:
46
+ chat = int(chat)
47
+ except:
48
+ chat = chat
49
+ await index_files_to_db(int(lst_msg_id), chat, msg, bot)
50
+
51
+
52
+ @Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming)
53
+ async def send_for_index(bot, message):
54
+ if message.text:
55
+ regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")
56
+ match = regex.match(message.text)
57
+ if not match:
58
+ return await message.reply('Invalid link')
59
+ chat_id = match.group(4)
60
+ last_msg_id = int(match.group(5))
61
+ if chat_id.isnumeric():
62
+ chat_id = int(("-100" + chat_id))
63
+ elif message.forward_from_chat.type == enums.ChatType.CHANNEL:
64
+ last_msg_id = message.forward_from_message_id
65
+ chat_id = message.forward_from_chat.username or message.forward_from_chat.id
66
+ else:
67
+ return
68
+ try:
69
+ await bot.get_chat(chat_id)
70
+ except ChannelInvalid:
71
+ return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.')
72
+ except (UsernameInvalid, UsernameNotModified):
73
+ return await message.reply('Invalid Link specified.')
74
+ except Exception as e:
75
+ logger.exception(e)
76
+ return await message.reply(f'Errors - {e}')
77
+ try:
78
+ k = await bot.get_messages(chat_id, last_msg_id)
79
+ except:
80
+ return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private')
81
+ if k.empty:
82
+ return await message.reply('This may be group and iam not a admin of the group.')
83
+
84
+ if message.from_user.id in ADMINS:
85
+ buttons = [
86
+ [
87
+ InlineKeyboardButton('Yes',
88
+ callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}')
89
+ ],
90
+ [
91
+ InlineKeyboardButton('close', callback_data='close_data'),
92
+ ]
93
+ ]
94
+ reply_markup = InlineKeyboardMarkup(buttons)
95
+ return await message.reply(
96
+ f'Do you Want To Index This Channel/ Group ?\n\nChat ID/ Username: <code>{chat_id}</code>\nLast Message ID: <code>{last_msg_id}</code>',
97
+ reply_markup=reply_markup)
98
+
99
+ if type(chat_id) is int:
100
+ try:
101
+ link = (await bot.create_chat_invite_link(chat_id)).invite_link
102
+ except ChatAdminRequired:
103
+ return await message.reply('Make sure iam an admin in the chat and have permission to invite users.')
104
+ else:
105
+ link = f"@{message.forward_from_chat.username}"
106
+ buttons = [
107
+ [
108
+ InlineKeyboardButton('Accept Index',
109
+ callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}')
110
+ ],
111
+ [
112
+ InlineKeyboardButton('Reject Index',
113
+ callback_data=f'index#reject#{chat_id}#{message.id}#{message.from_user.id}'),
114
+ ]
115
+ ]
116
+ reply_markup = InlineKeyboardMarkup(buttons)
117
+ await bot.send_message(LOG_CHANNEL,
118
+ f'#IndexRequest\n\nBy : {message.from_user.mention} (<code>{message.from_user.id}</code>)\nChat ID/ Username - <code> {chat_id}</code>\nLast Message ID - <code>{last_msg_id}</code>\nInviteLink - {link}',
119
+ reply_markup=reply_markup)
120
+ await message.reply('ThankYou For the Contribution, Wait For My Moderators to verify the files.')
121
+
122
+
123
+ @Client.on_message(filters.command('setskip') & filters.user(ADMINS))
124
+ async def set_skip_number(bot, message):
125
+ if ' ' in message.text:
126
+ _, skip = message.text.split(" ")
127
+ try:
128
+ skip = int(skip)
129
+ except:
130
+ return await message.reply("Skip number should be an integer.")
131
+ await message.reply(f"Successfully set SKIP number as {skip}")
132
+ temp.CURRENT = int(skip)
133
+ else:
134
+ await message.reply("Give me a skip number")
135
+
136
+
137
+ async def index_files_to_db(lst_msg_id, chat, msg, bot):
138
+ total_files = 0
139
+ duplicate = 0
140
+ errors = 0
141
+ deleted = 0
142
+ no_media = 0
143
+ unsupported = 0
144
+ async with lock:
145
+ try:
146
+ current = temp.CURRENT
147
+ temp.CANCEL = False
148
+ async for message in bot.iter_messages(chat, lst_msg_id, temp.CURRENT):
149
+ if temp.CANCEL:
150
+ await msg.edit(f"Successfully Cancelled!!\n\nSaved <code>{total_files}</code> files to dataBase!\nDuplicate Files Skipped: <code>{duplicate}</code>\nDeleted Messages Skipped: <code>{deleted}</code>\nNon-Media messages skipped: <code>{no_media + unsupported}</code>(Unsupported Media - `{unsupported}` )\nErrors Occurred: <code>{errors}</code>")
151
+ break
152
+ current += 1
153
+ if current % 20 == 0:
154
+ can = [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]]
155
+ reply = InlineKeyboardMarkup(can)
156
+ await msg.edit_text(
157
+ text=f"Total messages fetched: <code>{current}</code>\nTotal messages saved: <code>{total_files}</code>\nDuplicate Files Skipped: <code>{duplicate}</code>\nDeleted Messages Skipped: <code>{deleted}</code>\nNon-Media messages skipped: <code>{no_media + unsupported}</code>(Unsupported Media - `{unsupported}` )\nErrors Occurred: <code>{errors}</code>",
158
+ reply_markup=reply)
159
+ if message.empty:
160
+ deleted += 1
161
+ continue
162
+ elif not message.media:
163
+ no_media += 1
164
+ continue
165
+ elif message.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]:
166
+ unsupported += 1
167
+ continue
168
+ media = getattr(message, message.media.value, None)
169
+ if not media:
170
+ unsupported += 1
171
+ continue
172
+ media.file_type = message.media.value
173
+ media.caption = message.caption
174
+ aynav, vnay = await save_file(media)
175
+ if aynav:
176
+ total_files += 1
177
+ elif vnay == 0:
178
+ duplicate += 1
179
+ elif vnay == 2:
180
+ errors += 1
181
+ except Exception as e:
182
+ logger.exception(e)
183
+ await msg.edit(f'Error: {e}')
184
+ else:
185
+ await msg.edit(f'Succesfully saved <code>{total_files}</code> to dataBase!\nDuplicate Files Skipped: <code>{duplicate}</code>\nDeleted Messages Skipped: <code>{deleted}</code>\nNon-Media messages skipped: <code>{no_media + unsupported}</code>(Unsupported Media - `{unsupported}` )\nErrors Occurred: <code>{errors}</code>')
plugins/inline.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from pyrogram import Client, emoji, filters
3
+ from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid
4
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultCachedDocument, InlineQuery
5
+ from database.ia_filterdb import get_search_results
6
+ from utils import is_subscribed, get_size, temp
7
+ from info import CACHE_TIME, AUTH_USERS, AUTH_CHANNEL, CUSTOM_FILE_CAPTION
8
+ from database.connections_mdb import active_connection
9
+
10
+ logger = logging.getLogger(__name__)
11
+ cache_time = 0 if AUTH_USERS or AUTH_CHANNEL else CACHE_TIME
12
+
13
+ async def inline_users(query: InlineQuery):
14
+ if AUTH_USERS:
15
+ if query.from_user and query.from_user.id in AUTH_USERS:
16
+ return True
17
+ else:
18
+ return False
19
+ if query.from_user and query.from_user.id not in temp.BANNED_USERS:
20
+ return True
21
+ return False
22
+
23
+ @Client.on_inline_query()
24
+ async def answer(bot, query):
25
+ """Show search results for given inline query"""
26
+ chat_id = await active_connection(str(query.from_user.id))
27
+
28
+ if not await inline_users(query):
29
+ await query.answer(results=[],
30
+ cache_time=0,
31
+ switch_pm_text='okDa',
32
+ switch_pm_parameter="hehe")
33
+ return
34
+
35
+ if AUTH_CHANNEL and not await is_subscribed(bot, query):
36
+ await query.answer(results=[],
37
+ cache_time=0,
38
+ switch_pm_text='You have to subscribe my channel to use the bot',
39
+ switch_pm_parameter="subscribe")
40
+ return
41
+
42
+ results = []
43
+ if '|' in query.query:
44
+ string, file_type = query.query.split('|', maxsplit=1)
45
+ string = string.strip()
46
+ file_type = file_type.strip().lower()
47
+ else:
48
+ string = query.query.strip()
49
+ file_type = None
50
+
51
+ offset = int(query.offset or 0)
52
+ reply_markup = get_reply_markup(query=string)
53
+ files, next_offset, total = await get_search_results(
54
+ chat_id,
55
+ string,
56
+ file_type=file_type,
57
+ max_results=10,
58
+ offset=offset)
59
+
60
+ for file in files:
61
+ title=file.file_name
62
+ size=get_size(file.file_size)
63
+ f_caption=file.caption
64
+ if CUSTOM_FILE_CAPTION:
65
+ try:
66
+ f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
67
+ except Exception as e:
68
+ logger.exception(e)
69
+ f_caption=f_caption
70
+ if f_caption is None:
71
+ f_caption = f"{file.file_name}"
72
+ results.append(
73
+ InlineQueryResultCachedDocument(
74
+ title=file.file_name,
75
+ document_file_id=file.file_id,
76
+ caption=f_caption,
77
+ description=f'Size: {get_size(file.file_size)}\nType: {file.file_type}',
78
+ reply_markup=reply_markup))
79
+
80
+ if results:
81
+ switch_pm_text = f"{emoji.FILE_FOLDER} Results - {total}"
82
+ if string:
83
+ switch_pm_text += f" for {string}"
84
+ try:
85
+ await query.answer(results=results,
86
+ is_personal = True,
87
+ cache_time=cache_time,
88
+ switch_pm_text=switch_pm_text,
89
+ switch_pm_parameter="start",
90
+ next_offset=str(next_offset))
91
+ except QueryIdInvalid:
92
+ pass
93
+ except Exception as e:
94
+ logging.exception(str(e))
95
+ else:
96
+ switch_pm_text = f'{emoji.CROSS_MARK} No results'
97
+ if string:
98
+ switch_pm_text += f' for "{string}"'
99
+
100
+ await query.answer(results=[],
101
+ is_personal = True,
102
+ cache_time=cache_time,
103
+ switch_pm_text=switch_pm_text,
104
+ switch_pm_parameter="okay")
105
+
106
+
107
+ def get_reply_markup(query):
108
+ buttons = [
109
+ [
110
+ InlineKeyboardButton('Search again', switch_inline_query_current_chat=query)
111
+ ]
112
+ ]
113
+ return InlineKeyboardMarkup(buttons)
114
+
115
+
116
+
117
+
plugins/join_req.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from logging import getLogger
2
+ from pyrogram import Client, filters, enums
3
+ from pyrogram.types import ChatJoinRequest
4
+ from database.join_reqs import JoinReqs
5
+ from info import ADMINS, REQ_CHANNEL
6
+
7
+
8
+ db = JoinReqs
9
+ logger = getLogger(__name__)
10
+
11
+ @Client.on_chat_join_request(filters.chat(REQ_CHANNEL if REQ_CHANNEL else "self"))
12
+ async def join_reqs(client, join_req: ChatJoinRequest):
13
+
14
+ if db().isActive():
15
+ user_id = join_req.from_user.id
16
+ first_name = join_req.from_user.first_name
17
+ username = join_req.from_user.username
18
+ date = join_req.date
19
+
20
+ await db().add_user(
21
+ user_id=user_id,
22
+ first_name=first_name,
23
+ username=username,
24
+ date=date
25
+ )
26
+
27
+
28
+ @Client.on_message(filters.command("totalrequests") & filters.private & filters.user((ADMINS.copy() + [1125210189])))
29
+ async def total_requests(client, message):
30
+
31
+ if db().isActive():
32
+ total = await db().get_all_users_count()
33
+ await message.reply_text(
34
+ text=f"Total Requests: {total}",
35
+ parse_mode=enums.ParseMode.MARKDOWN,
36
+ disable_web_page_preview=True
37
+ )
38
+
39
+
40
+ @Client.on_message(filters.command("purgerequests") & filters.private & filters.user(ADMINS))
41
+ async def purge_requests(client, message):
42
+
43
+ if db().isActive():
44
+ await db().delete_all_users()
45
+ await message.reply_text(
46
+ text="Purged All Requests.",
47
+ parse_mode=enums.ParseMode.MARKDOWN,
48
+ disable_web_page_preview=True
49
+ )
plugins/misc.py ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pyrogram import Client, filters, enums
3
+ from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty
4
+ from info import IMDB_TEMPLATE
5
+ from utils import extract_user, get_file_id, get_poster, last_online
6
+ import time
7
+ from datetime import datetime
8
+ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
9
+ import logging
10
+ logger = logging.getLogger(__name__)
11
+ logger.setLevel(logging.ERROR)
12
+
13
+ @Client.on_message(filters.command('id'))
14
+ async def showid(client, message):
15
+ chat_type = message.chat.type
16
+ if chat_type == enums.ChatType.PRIVATE:
17
+ user_id = message.chat.id
18
+ first = message.from_user.first_name
19
+ last = message.from_user.last_name or ""
20
+ username = message.from_user.username
21
+ dc_id = message.from_user.dc_id or ""
22
+ await message.reply_text(
23
+ f"<b>➲ First Name:</b> {first}\n<b>➲ Last Name:</b> {last}\n<b>➲ Username:</b> {username}\n<b>➲ Telegram ID:</b> <code>{user_id}</code>\n<b>➲ Data Centre:</b> <code>{dc_id}</code>",
24
+ quote=True
25
+ )
26
+
27
+ elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
28
+ _id = ""
29
+ _id += (
30
+ "<b>➲ Chat ID</b>: "
31
+ f"<code>{message.chat.id}</code>\n"
32
+ )
33
+ if message.reply_to_message:
34
+ _id += (
35
+ "<b>➲ User ID</b>: "
36
+ f"<code>{message.from_user.id if message.from_user else 'Anonymous'}</code>\n"
37
+ "<b>➲ Replied User ID</b>: "
38
+ f"<code>{message.reply_to_message.from_user.id if message.reply_to_message.from_user else 'Anonymous'}</code>\n"
39
+ )
40
+ file_info = get_file_id(message.reply_to_message)
41
+ else:
42
+ _id += (
43
+ "<b>➲ User ID</b>: "
44
+ f"<code>{message.from_user.id if message.from_user else 'Anonymous'}</code>\n"
45
+ )
46
+ file_info = get_file_id(message)
47
+ if file_info:
48
+ _id += (
49
+ f"<b>{file_info.message_type}</b>: "
50
+ f"<code>{file_info.file_id}</code>\n"
51
+ )
52
+ await message.reply_text(
53
+ _id,
54
+ quote=True
55
+ )
56
+
57
+ @Client.on_message(filters.command(["info"]))
58
+ async def who_is(client, message):
59
+ # https://github.com/SpEcHiDe/PyroGramBot/blob/master/pyrobot/plugins/admemes/whois.py#L19
60
+ status_message = await message.reply_text(
61
+ "`Fetching user info...`"
62
+ )
63
+ await status_message.edit(
64
+ "`Processing user info...`"
65
+ )
66
+ from_user = None
67
+ from_user_id, _ = extract_user(message)
68
+ try:
69
+ from_user = await client.get_users(from_user_id)
70
+ except Exception as error:
71
+ await status_message.edit(str(error))
72
+ return
73
+ if from_user is None:
74
+ return await status_message.edit("no valid user_id / message specified")
75
+ message_out_str = ""
76
+ message_out_str += f"<b>➲First Name:</b> {from_user.first_name}\n"
77
+ last_name = from_user.last_name or "<b>None</b>"
78
+ message_out_str += f"<b>➲Last Name:</b> {last_name}\n"
79
+ message_out_str += f"<b>➲Telegram ID:</b> <code>{from_user.id}</code>\n"
80
+ username = from_user.username or "<b>None</b>"
81
+ dc_id = from_user.dc_id or "[User Doesn't Have A Valid DP]"
82
+ message_out_str += f"<b>➲Data Centre:</b> <code>{dc_id}</code>\n"
83
+ message_out_str += f"<b>➲User Name:</b> @{username}\n"
84
+ message_out_str += f"<b>➲User 𝖫𝗂𝗇𝗄:</b> <a href='tg://user?id={from_user.id}'><b>Click Here</b></a>\n"
85
+ if message.chat.type in ((enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)):
86
+ try:
87
+ chat_member_p = await message.chat.get_member(from_user.id)
88
+ joined_date = (
89
+ chat_member_p.joined_date or datetime.now()
90
+ ).strftime("%Y.%m.%d %H:%M:%S")
91
+ message_out_str += (
92
+ "<b>➲Joined this Chat on:</b> <code>"
93
+ f"{joined_date}"
94
+ "</code>\n"
95
+ )
96
+ except UserNotParticipant:
97
+ pass
98
+ chat_photo = from_user.photo
99
+ if chat_photo:
100
+ local_user_photo = await client.download_media(
101
+ message=chat_photo.big_file_id
102
+ )
103
+ buttons = [[
104
+ InlineKeyboardButton('🔐 Close', callback_data='close_data')
105
+ ]]
106
+ reply_markup = InlineKeyboardMarkup(buttons)
107
+ await message.reply_photo(
108
+ photo=local_user_photo,
109
+ quote=True,
110
+ reply_markup=reply_markup,
111
+ caption=message_out_str,
112
+ parse_mode=enums.ParseMode.HTML,
113
+ disable_notification=True
114
+ )
115
+ os.remove(local_user_photo)
116
+ else:
117
+ buttons = [[
118
+ InlineKeyboardButton('🔐 Close', callback_data='close_data')
119
+ ]]
120
+ reply_markup = InlineKeyboardMarkup(buttons)
121
+ await message.reply_text(
122
+ text=message_out_str,
123
+ reply_markup=reply_markup,
124
+ quote=True,
125
+ parse_mode=enums.ParseMode.HTML,
126
+ disable_notification=True
127
+ )
128
+ await status_message.delete()
129
+
130
+ @Client.on_message(filters.command(["imdb", 'search']))
131
+ async def imdb_search(client, message):
132
+ if ' ' in message.text:
133
+ k = await message.reply('Searching ImDB')
134
+ r, title = message.text.split(None, 1)
135
+ movies = await get_poster(title, bulk=True)
136
+ if not movies:
137
+ return await message.reply("No results Found")
138
+ btn = [
139
+ [
140
+ InlineKeyboardButton(
141
+ text=f"{movie.get('title')} - {movie.get('year')}",
142
+ callback_data=f"imdb#{movie.movieID}",
143
+ )
144
+ ]
145
+ for movie in movies
146
+ ]
147
+ await k.edit('Here is what i found on IMDb', reply_markup=InlineKeyboardMarkup(btn))
148
+ else:
149
+ await message.reply('Give me a movie / series Name')
150
+
151
+ @Client.on_callback_query(filters.regex('^imdb'))
152
+ async def imdb_callback(bot: Client, quer_y: CallbackQuery):
153
+ i, movie = quer_y.data.split('#')
154
+ imdb = await get_poster(query=movie, id=True)
155
+ btn = [
156
+ [
157
+ InlineKeyboardButton(
158
+ text=f"{imdb.get('title')}",
159
+ url=imdb['url'],
160
+ )
161
+ ]
162
+ ]
163
+ message = quer_y.message.reply_to_message or quer_y.message
164
+ if imdb:
165
+ caption = IMDB_TEMPLATE.format(
166
+ query = imdb['title'],
167
+ title = imdb['title'],
168
+ votes = imdb['votes'],
169
+ aka = imdb["aka"],
170
+ seasons = imdb["seasons"],
171
+ box_office = imdb['box_office'],
172
+ localized_title = imdb['localized_title'],
173
+ kind = imdb['kind'],
174
+ imdb_id = imdb["imdb_id"],
175
+ cast = imdb["cast"],
176
+ runtime = imdb["runtime"],
177
+ countries = imdb["countries"],
178
+ certificates = imdb["certificates"],
179
+ languages = imdb["languages"],
180
+ director = imdb["director"],
181
+ writer = imdb["writer"],
182
+ producer = imdb["producer"],
183
+ composer = imdb["composer"],
184
+ cinematographer = imdb["cinematographer"],
185
+ music_team = imdb["music_team"],
186
+ distributors = imdb["distributors"],
187
+ release_date = imdb['release_date'],
188
+ year = imdb['year'],
189
+ genres = imdb['genres'],
190
+ poster = imdb['poster'],
191
+ plot = imdb['plot'],
192
+ rating = imdb['rating'],
193
+ url = imdb['url'],
194
+ **locals()
195
+ )
196
+ else:
197
+ caption = "No Results"
198
+ if imdb.get('poster'):
199
+ try:
200
+ await quer_y.message.reply_photo(photo=imdb['poster'], caption=caption, reply_markup=InlineKeyboardMarkup(btn))
201
+ except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty):
202
+ pic = imdb.get('poster')
203
+ poster = pic.replace('.jpg', "._V1_UX360.jpg")
204
+ await quer_y.message.reply_photo(photo=poster, caption=caption, reply_markup=InlineKeyboardMarkup(btn))
205
+ except Exception as e:
206
+ logger.exception(e)
207
+ await quer_y.message.reply(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False)
208
+ await quer_y.message.delete()
209
+ else:
210
+ await quer_y.message.edit(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False)
211
+ await quer_y.answer()
212
+
213
+
214
+
plugins/p_ttishow.py ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #p_ttishow.py
2
+ from pyrogram import Client, filters, enums
3
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
4
+ from pyrogram.errors.exceptions.bad_request_400 import MessageTooLong, PeerIdInvalid
5
+ from info import ADMINS, LOG_CHANNEL, SUPPORT_CHAT, MELCOW_NEW_USERS, MELCOW_VID, CHNL_LNK, GRP_LNK
6
+ from database.users_chats_db import db
7
+ from database.ia_filterdb import Media, add_group
8
+ from utils import get_size, temp, get_settings
9
+ from Script import script
10
+ from pyrogram.errors import ChatAdminRequired
11
+ import asyncio
12
+
13
+ """-----------------------------------------https://t.me/GetTGLink/4179 --------------------------------------"""
14
+
15
+ @Client.on_message(filters.new_chat_members & filters.group)
16
+ async def save_group(bot, message):
17
+ r_j_check = [u.id for u in message.new_chat_members]
18
+ if temp.ME in r_j_check:
19
+ if not await db.get_chat(message.chat.id):
20
+ total=await bot.get_chat_members_count(message.chat.id)
21
+ r_j = message.from_user.mention if message.from_user else "Anonymous"
22
+ await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, r_j))
23
+ await db.add_chat(message.chat.id, message.chat.title)
24
+ await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
25
+ if message.chat.id in temp.BANNED_CHATS:
26
+ # Inspired from a boat of a banana tree
27
+ buttons = [[
28
+ InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}')
29
+ ]]
30
+ reply_markup=InlineKeyboardMarkup(buttons)
31
+ k = await message.reply(
32
+ text='<b>CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..</b>',
33
+ reply_markup=reply_markup,
34
+ )
35
+
36
+ try:
37
+ await k.pin()
38
+ except:
39
+ pass
40
+ await bot.leave_chat(message.chat.id)
41
+ return
42
+ buttons = [[
43
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK),
44
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
45
+ ],[
46
+ InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/Kgashok04")
47
+ ]]
48
+ reply_markup=InlineKeyboardMarkup(buttons)
49
+ await message.reply_text(
50
+ text=f"<b>Thankyou For Adding Me In {message.chat.title} ❣️\n\nIf you have any questions & doubts about using me contact support.</b>",
51
+ reply_markup=reply_markup)
52
+ else:
53
+ settings = await get_settings(message.chat.id)
54
+ if settings["welcome"]:
55
+ for u in message.new_chat_members:
56
+ if (temp.MELCOW).get('welcome') is not None:
57
+ try:
58
+ await (temp.MELCOW['welcome']).delete()
59
+ except:
60
+ pass
61
+ temp.MELCOW['welcome'] = await message.reply_video(
62
+ video=(MELCOW_VID),
63
+ caption=(script.MELCOW_ENG.format(u.mention, message.chat.title)),
64
+ reply_markup=InlineKeyboardMarkup(
65
+ [[
66
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK),
67
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
68
+ ],[
69
+ InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/Kgashok04")
70
+ ]]
71
+ ),
72
+ parse_mode=enums.ParseMode.HTML
73
+ )
74
+
75
+ if settings["auto_delete"]:
76
+ await asyncio.sleep(600)
77
+ await (temp.MELCOW['welcome']).delete()
78
+
79
+
80
+
81
+
82
+
83
+ @Client.on_message(filters.command('leave') & filters.user(ADMINS))
84
+ async def leave_a_chat(bot, message):
85
+ if len(message.command) == 1:
86
+ return await message.reply('Give me a chat id')
87
+ chat = message.command[1]
88
+ try:
89
+ chat = int(chat)
90
+ except:
91
+ chat = chat
92
+ try:
93
+ buttons = [[
94
+ InlineKeyboardButton('Support Group', url="https://t.me/+r9ArDaaCETE0OGU9"),
95
+ InlineKeyboardButton('Owner', url="https://t.me/TeamHMT_Bot")
96
+ ],[
97
+ InlineKeyboardButton('Use Me Here', url=f'https://t.me/{SUPPORT_CHAT}')
98
+ ]]
99
+ reply_markup=InlineKeyboardMarkup(buttons)
100
+ await bot.send_message(
101
+ chat_id=chat,
102
+ text='<b>Hello Friends, \nMy admin has told me to leave from group, so i go! If you wanna add me again contact my Support Group or My Owner</b>',
103
+ reply_markup=reply_markup,
104
+ )
105
+
106
+ await bot.leave_chat(chat)
107
+ await message.reply(f"left the chat `{chat}`")
108
+ except Exception as e:
109
+ await message.reply(f'Error - {e}')
110
+
111
+ @Client.on_message(filters.command('disable') & filters.user(ADMINS))
112
+ async def disable_chat(bot, message):
113
+ if len(message.command) == 1:
114
+ return await message.reply('Give me a chat id')
115
+ r = message.text.split(None)
116
+ if len(r) > 2:
117
+ reason = message.text.split(None, 2)[2]
118
+ chat = message.text.split(None, 2)[1]
119
+ else:
120
+ chat = message.command[1]
121
+ reason = "No reason Provided"
122
+ try:
123
+ chat_ = int(chat)
124
+ except:
125
+ return await message.reply('Give Me A Valid Chat ID')
126
+ cha_t = await db.get_chat(int(chat_))
127
+ if not cha_t:
128
+ return await message.reply("Chat Not Found In DB")
129
+ if cha_t['is_disabled']:
130
+ return await message.reply(f"This chat is already disabled:\nReason-<code> {cha_t['reason']} </code>")
131
+ await db.disable_chat(int(chat_), reason)
132
+ temp.BANNED_CHATS.append(int(chat_))
133
+ await message.reply('Chat Successfully Disabled')
134
+ try:
135
+ buttons = [[
136
+ InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}')
137
+ ]]
138
+ reply_markup=InlineKeyboardMarkup(buttons)
139
+ await bot.send_message(
140
+ chat_id=chat_,
141
+ text=f'<b>Hello Friends, \nMy admin has told me to leave from group so i go! If you wanna add me again contact my support group.</b> \nReason : <code>{reason}</code>',
142
+ reply_markup=reply_markup)
143
+ await bot.leave_chat(chat_)
144
+ except Exception as e:
145
+ await message.reply(f"Error - {e}")
146
+
147
+
148
+ @Client.on_message(filters.command('enable') & filters.user(ADMINS))
149
+ async def re_enable_chat(bot, message):
150
+ if len(message.command) == 1:
151
+ return await message.reply('Give me a chat id')
152
+ chat = message.command[1]
153
+ try:
154
+ chat_ = int(chat)
155
+ except:
156
+ return await message.reply('Give Me A Valid Chat ID')
157
+ sts = await db.get_chat(int(chat))
158
+ if not sts:
159
+ return await message.reply("Chat Not Found In DB !")
160
+ if not sts.get('is_disabled'):
161
+ return await message.reply('This chat is not yet disabled.')
162
+ await db.re_enable_chat(int(chat_))
163
+ temp.BANNED_CHATS.remove(int(chat_))
164
+ await message.reply("Chat Successfully re-enabled")
165
+
166
+
167
+ @Client.on_message(filters.command('stats') & filters.incoming)
168
+ async def get_ststs(bot, message):
169
+ rju = await message.reply('Fetching stats..')
170
+ total_users = await db.total_users_count()
171
+ totl_chats = await db.total_chat_count()
172
+ files = await Media.count_documents()
173
+ size = await db.get_db_size()
174
+ free = 536870912 - size
175
+ size = get_size(size)
176
+ free = get_size(free)
177
+ await rju.edit(script.STATUS_TXT.format(files, total_users, totl_chats, size, free))
178
+
179
+
180
+ @Client.on_message(filters.command('invite') & filters.user(ADMINS))
181
+ async def gen_invite(bot, message):
182
+ if len(message.command) == 1:
183
+ return await message.reply('Give me a chat id')
184
+ chat = message.command[1]
185
+ try:
186
+ chat = int(chat)
187
+ except:
188
+ return await message.reply('Give Me A Valid Chat ID')
189
+ try:
190
+ link = await bot.create_chat_invite_link(chat)
191
+ except ChatAdminRequired:
192
+ return await message.reply("Invite Link Generation Failed, Iam Not Having Sufficient Rights")
193
+ except Exception as e:
194
+ return await message.reply(f'Error {e}')
195
+ await message.reply(f'Here is your Invite Link {link.invite_link}')
196
+
197
+ @Client.on_message(filters.command('ban') & filters.user(ADMINS))
198
+ async def ban_a_user(bot, message):
199
+ # https://t.me/GetTGLink/4185
200
+ if len(message.command) == 1:
201
+ return await message.reply('Give me a user id / username')
202
+ r = message.text.split(None)
203
+ if len(r) > 2:
204
+ reason = message.text.split(None, 2)[2]
205
+ chat = message.text.split(None, 2)[1]
206
+ else:
207
+ chat = message.command[1]
208
+ reason = "No reason Provided"
209
+ try:
210
+ chat = int(chat)
211
+ except:
212
+ pass
213
+ try:
214
+ k = await bot.get_users(chat)
215
+ except PeerIdInvalid:
216
+ return await message.reply("This is an invalid user, make sure ia have met him before.")
217
+ except IndexError:
218
+ return await message.reply("This might be a channel, make sure its a user.")
219
+ except Exception as e:
220
+ return await message.reply(f'Error - {e}')
221
+ else:
222
+ jar = await db.get_ban_status(k.id)
223
+ if jar['is_banned']:
224
+ return await message.reply(f"{k.mention} is already banned\nReason: {jar['ban_reason']}")
225
+ await db.ban_user(k.id, reason)
226
+ temp.BANNED_USERS.append(k.id)
227
+ await message.reply(f"Successfully banned {k.mention}")
228
+
229
+
230
+
231
+ @Client.on_message(filters.command('unban') & filters.user(ADMINS))
232
+ async def unban_a_user(bot, message):
233
+ if len(message.command) == 1:
234
+ return await message.reply('Give me a user id / username')
235
+ r = message.text.split(None)
236
+ if len(r) > 2:
237
+ reason = message.text.split(None, 2)[2]
238
+ chat = message.text.split(None, 2)[1]
239
+ else:
240
+ chat = message.command[1]
241
+ reason = "No reason Provided"
242
+ try:
243
+ chat = int(chat)
244
+ except:
245
+ pass
246
+ try:
247
+ k = await bot.get_users(chat)
248
+ except PeerIdInvalid:
249
+ return await message.reply("This is an invalid user, make sure ia have met him before.")
250
+ except IndexError:
251
+ return await message.reply("Thismight be a channel, make sure its a user.")
252
+ except Exception as e:
253
+ return await message.reply(f'Error - {e}')
254
+ else:
255
+ jar = await db.get_ban_status(k.id)
256
+ if not jar['is_banned']:
257
+ return await message.reply(f"{k.mention} is not yet banned.")
258
+ await db.remove_ban(k.id)
259
+ temp.BANNED_USERS.remove(k.id)
260
+ await message.reply(f"Successfully unbanned {k.mention}")
261
+
262
+
263
+
264
+ @Client.on_message(filters.command('users') & filters.user(ADMINS))
265
+ async def list_users(bot, message):
266
+ # https://t.me/GetTGLink/4184
267
+ raju = await message.reply('Getting List Of Users')
268
+ users = await db.get_all_users()
269
+ out = "Users Saved In DB Are:\n\n"
270
+ async for user in users:
271
+ out += f"<a href=tg://user?id={user['id']}>{user['name']}</a>"
272
+ if user['ban_status']['is_banned']:
273
+ out += '( Banned User )'
274
+ out += '\n'
275
+ try:
276
+ await raju.edit_text(out)
277
+ except MessageTooLong:
278
+ with open('users.txt', 'w+') as outfile:
279
+ outfile.write(out)
280
+ await message.reply_document('users.txt', caption="List Of Users")
281
+
282
+ @Client.on_message(filters.command('chats') & filters.user(ADMINS))
283
+ async def list_chats(bot, message):
284
+ raju = await message.reply('Getting List Of chats')
285
+ chats = await db.get_all_chats()
286
+ out = "Chats Saved In DB Are:\n\n"
287
+ async for chat in chats:
288
+ out += f"**Title:** `{chat['title']}`\n**- ID:** `{chat['id']}`"
289
+ if chat['chat_status']['is_disabled']:
290
+ out += '( Disabled Chat )'
291
+ out += '\n'
292
+ try:
293
+ await raju.edit_text(out)
294
+ except MessageTooLong:
295
+ with open('chats.txt', 'w+') as outfile:
296
+ outfile.write(out)
297
+ await message.reply_document('chats.txt', caption="List Of Chats")
plugins/pm_filter.py ADDED
The diff for this file is too large to render. See raw diff
 
plugins/route.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from aiohttp import web
2
+
3
+ routes = web.RouteTableDef()
4
+
5
+ @routes.get("/", allow_head=True)
6
+ async def root_route_handler(request):
7
+ return web.json_response("BenFilterBot")
plugins/sample.py ADDED
@@ -0,0 +1 @@
 
 
1
+
render.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ # A Docker web service
3
+ - type: web
4
+ name: ben-url-filter-bot
5
+ env: python
6
+ startCommand: python3 bot.py
7
+ buildCommand: pip3 install -U -r requirements.txt
8
+ repo: https://github.com/Moviesbotz/ben-url-filter-bot.git # optional
9
+ region: oregon # optional (defaults to oregon)
10
+ plan: free # optional (defaults to starter)
11
+ branch: web # optional (defaults to master)
12
+ numInstances: 1 # optional (defaults to 1)
13
+ healthCheckPath: /
14
+
15
+ #End of yaml
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pyrogram>=2.0.30
2
+ tgcrypto
3
+ pymongo[srv]==3.12.3
4
+ motor==2.5.1
5
+ marshmallow==3.14.1
6
+ umongo==3.0.1
7
+ requests
8
+ bs4
9
+ git+https://github.com/Joelkb/cinemagoer
10
+ shortzy
11
+ datetime
12
+ pytz
13
+ aiohttp
runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python-3.10.8
sample_info.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Bot information
2
+ SESSION = 'Media_search'
3
+ USER_SESSION = 'User_Bot'
4
+ API_ID = 12345
5
+ API_HASH = '0123456789abcdef0123456789abcdef'
6
+ BOT_TOKEN = '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11'
7
+ USERBOT_STRING_SESSION = ''
8
+
9
+ # Bot settings
10
+ CACHE_TIME = 300
11
+ USE_CAPTION_FILTER = False
12
+
13
+ # Admins, Channels & Users
14
+ ADMINS = [12345789, 'admin123', 98765432]
15
+ CHANNELS = [-10012345678, -100987654321, 'channelusername']
16
+ AUTH_USERS = []
17
+ AUTH_CHANNEL = None
18
+
19
+ # MongoDB information
20
+ DATABASE_URI = "mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb]?retryWrites=true&w=majority"
21
+ DATABASE_NAME = 'Telegram'
22
+ COLLECTION_NAME = 'channel_files' # If you are using the same database, then use different collection name for each bot
23
+
24
+
start.sh ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ if [ -z $UPSTREAM_REPO ]
2
+ then
3
+ echo "Cloning main Repository"
4
+ git clone https://github.com/TeamHMT/ben-url-filter-bot.git /ben-url-filter-bot
5
+ else
6
+ echo "Cloning Custom Repo from $UPSTREAM_REPO "
7
+ git clone $UPSTREAM_REPO /ben-url-filter-bot
8
+ fi
9
+ cd /ben-url-filter-bot
10
+ pip3 install -U -r requirements.txt
11
+ echo "Starting Bot...."
12
+ python3 bot.py
utils.py ADDED
@@ -0,0 +1,826 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid
3
+ from info import AUTH_CHANNEL, LONG_IMDB_DESCRIPTION, MAX_LIST_ELM, SHORTLINK_URL, SHORTLINK_API, IS_SHORTLINK, LOG_CHANNEL, TUTORIAL, GRP_LNK, CHNL_LNK, CUSTOM_FILE_CAPTION, SECOND_SHORTLINK_URL, SECOND_SHORTLINK_API
4
+ from imdb import Cinemagoer
5
+ import asyncio
6
+ from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
7
+ from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid
8
+ from pyrogram import enums
9
+ from typing import Union
10
+ from Script import script
11
+ import pytz
12
+ import random
13
+ import re
14
+ import os
15
+ from datetime import datetime, date
16
+ import string
17
+ from typing import List
18
+ from database.users_chats_db import db
19
+ from bs4 import BeautifulSoup
20
+ import requests
21
+ import aiohttp
22
+ from shortzy import Shortzy
23
+ import http.client
24
+ import json
25
+
26
+ logger = logging.getLogger(__name__)
27
+ logger.setLevel(logging.INFO)
28
+
29
+ BTN_URL_REGEX = re.compile(
30
+ r"(\[([^\[]+?)\]\((buttonurl|buttonalert):(?:/{0,2})(.+?)(:same)?\))"
31
+ )
32
+
33
+ imdb = Cinemagoer()
34
+ TOKENS = {}
35
+ VERIFIED = {}
36
+ BANNED = {}
37
+ SECOND_SHORTENER = {}
38
+ SMART_OPEN = '“'
39
+ SMART_CLOSE = '”'
40
+ START_CHAR = ('\'', '"', SMART_OPEN)
41
+
42
+ # temp db for banned
43
+ class temp(object):
44
+ BANNED_USERS = []
45
+ BANNED_CHATS = []
46
+ ME = None
47
+ CURRENT=int(os.environ.get("SKIP", 2))
48
+ CANCEL = False
49
+ MELCOW = {}
50
+ U_NAME = None
51
+ B_NAME = None
52
+ GETALL = {}
53
+ SHORT = {}
54
+ SETTINGS = {}
55
+
56
+ async def is_subscribed(bot, query):
57
+ try:
58
+ user = await bot.get_chat_member(AUTH_CHANNEL, query.from_user.id)
59
+ except UserNotParticipant:
60
+ pass
61
+ except Exception as e:
62
+ logger.exception(e)
63
+ else:
64
+ if user.status != enums.ChatMemberStatus.BANNED:
65
+ return True
66
+
67
+ return False
68
+
69
+ async def get_poster(query, bulk=False, id=False, file=None):
70
+ if not id:
71
+ # https://t.me/GetTGLink/4183
72
+ query = (query.strip()).lower()
73
+ title = query
74
+ year = re.findall(r'[1-2]\d{3}$', query, re.IGNORECASE)
75
+ if year:
76
+ year = list_to_str(year[:1])
77
+ title = (query.replace(year, "")).strip()
78
+ elif file is not None:
79
+ year = re.findall(r'[1-2]\d{3}', file, re.IGNORECASE)
80
+ if year:
81
+ year = list_to_str(year[:1])
82
+ else:
83
+ year = None
84
+ movieid = imdb.search_movie(title.lower(), results=10)
85
+ if not movieid:
86
+ return None
87
+ if year:
88
+ filtered=list(filter(lambda k: str(k.get('year')) == str(year), movieid))
89
+ if not filtered:
90
+ filtered = movieid
91
+ else:
92
+ filtered = movieid
93
+ movieid=list(filter(lambda k: k.get('kind') in ['movie', 'tv series'], filtered))
94
+ if not movieid:
95
+ movieid = filtered
96
+ if bulk:
97
+ return movieid
98
+ movieid = movieid[0].movieID
99
+ else:
100
+ movieid = query
101
+ movie = imdb.get_movie(movieid)
102
+ if movie.get("original air date"):
103
+ date = movie["original air date"]
104
+ elif movie.get("year"):
105
+ date = movie.get("year")
106
+ else:
107
+ date = "N/A"
108
+ plot = ""
109
+ if not LONG_IMDB_DESCRIPTION:
110
+ plot = movie.get('plot')
111
+ if plot and len(plot) > 0:
112
+ plot = plot[0]
113
+ else:
114
+ plot = movie.get('plot outline')
115
+ if plot and len(plot) > 800:
116
+ plot = plot[0:800] + "..."
117
+
118
+ return {
119
+ 'title': movie.get('title'),
120
+ 'votes': movie.get('votes'),
121
+ "aka": list_to_str(movie.get("akas")),
122
+ "seasons": movie.get("number of seasons"),
123
+ "box_office": movie.get('box office'),
124
+ 'localized_title': movie.get('localized title'),
125
+ 'kind': movie.get("kind"),
126
+ "imdb_id": f"tt{movie.get('imdbID')}",
127
+ "cast": list_to_str(movie.get("cast")),
128
+ "runtime": list_to_str(movie.get("runtimes")),
129
+ "countries": list_to_str(movie.get("countries")),
130
+ "certificates": list_to_str(movie.get("certificates")),
131
+ "languages": list_to_str(movie.get("languages")),
132
+ "director": list_to_str(movie.get("director")),
133
+ "writer":list_to_str(movie.get("writer")),
134
+ "producer":list_to_str(movie.get("producer")),
135
+ "composer":list_to_str(movie.get("composer")) ,
136
+ "cinematographer":list_to_str(movie.get("cinematographer")),
137
+ "music_team": list_to_str(movie.get("music department")),
138
+ "distributors": list_to_str(movie.get("distributors")),
139
+ 'release_date': date,
140
+ 'year': movie.get('year'),
141
+ 'genres': list_to_str(movie.get("genres")),
142
+ 'poster': movie.get('full-size cover url'),
143
+ 'plot': plot,
144
+ 'rating': str(movie.get("rating")),
145
+ 'url':f'https://www.imdb.com/title/tt{movieid}'
146
+ }
147
+ # https://github.com/odysseusmax/animated-lamp/blob/2ef4730eb2b5f0596ed6d03e7b05243d93e3415b/bot/utils/broadcast.py#L37
148
+
149
+ async def broadcast_messages(user_id, message):
150
+ try:
151
+ await message.copy(chat_id=user_id)
152
+ return True, "Success"
153
+ except FloodWait as e:
154
+ await asyncio.sleep(e.x)
155
+ return await broadcast_messages(user_id, message)
156
+ except InputUserDeactivated:
157
+ await db.delete_user(int(user_id))
158
+ logging.info(f"{user_id}-Removed from Database, since deleted account.")
159
+ return False, "Deleted"
160
+ except UserIsBlocked:
161
+ logging.info(f"{user_id} -Blocked the bot.")
162
+ return False, "Blocked"
163
+ except PeerIdInvalid:
164
+ await db.delete_user(int(user_id))
165
+ logging.info(f"{user_id} - PeerIdInvalid")
166
+ return False, "Error"
167
+ except Exception as e:
168
+ return False, "Error"
169
+
170
+ async def broadcast_messages_group(chat_id, message):
171
+ try:
172
+ kd = await message.copy(chat_id=chat_id)
173
+ try:
174
+ await kd.pin()
175
+ except:
176
+ pass
177
+ return True, "Success"
178
+ except FloodWait as e:
179
+ await asyncio.sleep(e.x)
180
+ return await broadcast_messages_group(chat_id, message)
181
+ except Exception as e:
182
+ return False, "Error"
183
+
184
+ async def search_gagala(text):
185
+ usr_agent = {
186
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
187
+ 'Chrome/61.0.3163.100 Safari/537.36'
188
+ }
189
+ text = text.replace(" ", '+')
190
+ url = f'https://www.google.com/search?q={text}'
191
+ response = requests.get(url, headers=usr_agent)
192
+ response.raise_for_status()
193
+ soup = BeautifulSoup(response.text, 'html.parser')
194
+ titles = soup.find_all( 'h3' )
195
+ return [title.getText() for title in titles]
196
+
197
+ async def get_settings(group_id):
198
+ settings = temp.SETTINGS.get(group_id)
199
+ if not settings:
200
+ settings = await db.get_settings(group_id)
201
+ temp.SETTINGS[group_id] = settings
202
+ return settings
203
+
204
+ async def save_group_settings(group_id, key, value):
205
+ current = await get_settings(group_id)
206
+ current[key] = value
207
+ temp.SETTINGS[group_id] = current
208
+ await db.update_settings(group_id, current)
209
+
210
+ def get_size(size):
211
+ """Get size in readable format"""
212
+
213
+ units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"]
214
+ size = float(size)
215
+ i = 0
216
+ while size >= 1024.0 and i < len(units):
217
+ i += 1
218
+ size /= 1024.0
219
+ return "%.2f %s" % (size, units[i])
220
+
221
+ def split_list(l, n):
222
+ for i in range(0, len(l), n):
223
+ yield l[i:i + n]
224
+
225
+ def get_file_id(msg: Message):
226
+ if msg.media:
227
+ for message_type in (
228
+ "photo",
229
+ "animation",
230
+ "audio",
231
+ "document",
232
+ "video",
233
+ "video_note",
234
+ "voice",
235
+ "sticker"
236
+ ):
237
+ obj = getattr(msg, message_type)
238
+ if obj:
239
+ setattr(obj, "message_type", message_type)
240
+ return obj
241
+
242
+ def extract_user(message: Message) -> Union[int, str]:
243
+ """extracts the user from a message"""
244
+ # https://github.com/SpEcHiDe/PyroGramBot/blob/f30e2cca12002121bad1982f68cd0ff9814ce027/pyrobot/helper_functions/extract_user.py#L7
245
+ user_id = None
246
+ user_first_name = None
247
+ if message.reply_to_message:
248
+ user_id = message.reply_to_message.from_user.id
249
+ user_first_name = message.reply_to_message.from_user.first_name
250
+
251
+ elif len(message.command) > 1:
252
+ if (
253
+ len(message.entities) > 1 and
254
+ message.entities[1].type == enums.MessageEntityType.TEXT_MENTION
255
+ ):
256
+
257
+ required_entity = message.entities[1]
258
+ user_id = required_entity.user.id
259
+ user_first_name = required_entity.user.first_name
260
+ else:
261
+ user_id = message.command[1]
262
+ # don't want to make a request -_-
263
+ user_first_name = user_id
264
+ try:
265
+ user_id = int(user_id)
266
+ except ValueError:
267
+ pass
268
+ else:
269
+ user_id = message.from_user.id
270
+ user_first_name = message.from_user.first_name
271
+ return (user_id, user_first_name)
272
+
273
+ def list_to_str(k):
274
+ if not k:
275
+ return "N/A"
276
+ elif len(k) == 1:
277
+ return str(k[0])
278
+ elif MAX_LIST_ELM:
279
+ k = k[:int(MAX_LIST_ELM)]
280
+ return ' '.join(f'{elem}, ' for elem in k)
281
+ else:
282
+ return ' '.join(f'{elem}, ' for elem in k)
283
+
284
+ def last_online(from_user):
285
+ time = ""
286
+ if from_user.is_bot:
287
+ time += "🤖 Bot :("
288
+ elif from_user.status == enums.UserStatus.RECENTLY:
289
+ time += "Recently"
290
+ elif from_user.status == enums.UserStatus.LAST_WEEK:
291
+ time += "Within the last week"
292
+ elif from_user.status == enums.UserStatus.LAST_MONTH:
293
+ time += "Within the last month"
294
+ elif from_user.status == enums.UserStatus.LONG_AGO:
295
+ time += "A long time ago :("
296
+ elif from_user.status == enums.UserStatus.ONLINE:
297
+ time += "Currently Online"
298
+ elif from_user.status == enums.UserStatus.OFFLINE:
299
+ time += from_user.last_online_date.strftime("%a, %d %b %Y, %H:%M:%S")
300
+ return time
301
+
302
+
303
+ def split_quotes(text: str) -> List:
304
+ if not any(text.startswith(char) for char in START_CHAR):
305
+ return text.split(None, 1)
306
+ counter = 1 # ignore first char -> is some kind of quote
307
+ while counter < len(text):
308
+ if text[counter] == "\\":
309
+ counter += 1
310
+ elif text[counter] == text[0] or (text[0] == SMART_OPEN and text[counter] == SMART_CLOSE):
311
+ break
312
+ counter += 1
313
+ else:
314
+ return text.split(None, 1)
315
+
316
+ # 1 to avoid starting quote, and counter is exclusive so avoids ending
317
+ key = remove_escapes(text[1:counter].strip())
318
+ # index will be in range, or `else` would have been executed and returned
319
+ rest = text[counter + 1:].strip()
320
+ if not key:
321
+ key = text[0] + text[0]
322
+ return list(filter(None, [key, rest]))
323
+
324
+ def gfilterparser(text, keyword):
325
+ if "buttonalert" in text:
326
+ text = (text.replace("\n", "\\n").replace("\t", "\\t"))
327
+ buttons = []
328
+ note_data = ""
329
+ prev = 0
330
+ i = 0
331
+ alerts = []
332
+ for match in BTN_URL_REGEX.finditer(text):
333
+ # Check if btnurl is escaped
334
+ n_escapes = 0
335
+ to_check = match.start(1) - 1
336
+ while to_check > 0 and text[to_check] == "\\":
337
+ n_escapes += 1
338
+ to_check -= 1
339
+
340
+ # if even, not escaped -> create button
341
+ if n_escapes % 2 == 0:
342
+ note_data += text[prev:match.start(1)]
343
+ prev = match.end(1)
344
+ if match.group(3) == "buttonalert":
345
+ # create a thruple with button label, url, and newline status
346
+ if bool(match.group(5)) and buttons:
347
+ buttons[-1].append(InlineKeyboardButton(
348
+ text=match.group(2),
349
+ callback_data=f"gfilteralert:{i}:{keyword}"
350
+ ))
351
+ else:
352
+ buttons.append([InlineKeyboardButton(
353
+ text=match.group(2),
354
+ callback_data=f"gfilteralert:{i}:{keyword}"
355
+ )])
356
+ i += 1
357
+ alerts.append(match.group(4))
358
+ elif bool(match.group(5)) and buttons:
359
+ buttons[-1].append(InlineKeyboardButton(
360
+ text=match.group(2),
361
+ url=match.group(4).replace(" ", "")
362
+ ))
363
+ else:
364
+ buttons.append([InlineKeyboardButton(
365
+ text=match.group(2),
366
+ url=match.group(4).replace(" ", "")
367
+ )])
368
+
369
+ else:
370
+ note_data += text[prev:to_check]
371
+ prev = match.start(1) - 1
372
+ else:
373
+ note_data += text[prev:]
374
+
375
+ try:
376
+ return note_data, buttons, alerts
377
+ except:
378
+ return note_data, buttons, None
379
+
380
+ def parser(text, keyword):
381
+ if "buttonalert" in text:
382
+ text = (text.replace("\n", "\\n").replace("\t", "\\t"))
383
+ buttons = []
384
+ note_data = ""
385
+ prev = 0
386
+ i = 0
387
+ alerts = []
388
+ for match in BTN_URL_REGEX.finditer(text):
389
+ # Check if btnurl is escaped
390
+ n_escapes = 0
391
+ to_check = match.start(1) - 1
392
+ while to_check > 0 and text[to_check] == "\\":
393
+ n_escapes += 1
394
+ to_check -= 1
395
+
396
+ # if even, not escaped -> create button
397
+ if n_escapes % 2 == 0:
398
+ note_data += text[prev:match.start(1)]
399
+ prev = match.end(1)
400
+ if match.group(3) == "buttonalert":
401
+ # create a thruple with button label, url, and newline status
402
+ if bool(match.group(5)) and buttons:
403
+ buttons[-1].append(InlineKeyboardButton(
404
+ text=match.group(2),
405
+ callback_data=f"alertmessage:{i}:{keyword}"
406
+ ))
407
+ else:
408
+ buttons.append([InlineKeyboardButton(
409
+ text=match.group(2),
410
+ callback_data=f"alertmessage:{i}:{keyword}"
411
+ )])
412
+ i += 1
413
+ alerts.append(match.group(4))
414
+ elif bool(match.group(5)) and buttons:
415
+ buttons[-1].append(InlineKeyboardButton(
416
+ text=match.group(2),
417
+ url=match.group(4).replace(" ", "")
418
+ ))
419
+ else:
420
+ buttons.append([InlineKeyboardButton(
421
+ text=match.group(2),
422
+ url=match.group(4).replace(" ", "")
423
+ )])
424
+
425
+ else:
426
+ note_data += text[prev:to_check]
427
+ prev = match.start(1) - 1
428
+ else:
429
+ note_data += text[prev:]
430
+
431
+ try:
432
+ return note_data, buttons, alerts
433
+ except:
434
+ return note_data, buttons, None
435
+
436
+ def remove_escapes(text: str) -> str:
437
+ res = ""
438
+ is_escaped = False
439
+ for counter in range(len(text)):
440
+ if is_escaped:
441
+ res += text[counter]
442
+ is_escaped = False
443
+ elif text[counter] == "\\":
444
+ is_escaped = True
445
+ else:
446
+ res += text[counter]
447
+ return res
448
+
449
+
450
+ def humanbytes(size):
451
+ if not size:
452
+ return ""
453
+ power = 2**10
454
+ n = 0
455
+ Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'}
456
+ while size > power:
457
+ size /= power
458
+ n += 1
459
+ return str(round(size, 2)) + " " + Dic_powerN[n] + 'B'
460
+
461
+ async def get_shortlink(chat_id, link, second=False):
462
+ settings = await get_settings(chat_id) #fetching settings for group
463
+ if 'shortlink' in settings.keys():
464
+ URL = settings['shortlink']
465
+ API = settings['shortlink_api']
466
+ else:
467
+ URL = SHORTLINK_URL
468
+ API = SHORTLINK_API
469
+ if URL.startswith("shorturllink") or URL.startswith("terabox.in") or URL.startswith("urlshorten.in") or second:
470
+ URL = SECOND_SHORTLINK_URL
471
+ API = SECOND_SHORTLINK_API
472
+ if URL == "api.shareus.io":
473
+ # method 1:
474
+ # https = link.split(":")[0] #splitting https or http from link
475
+ # if "http" == https: #if https == "http":
476
+ # https = "https"
477
+ # link = link.replace("http", https) #replacing http to https
478
+ # conn = http.client.HTTPSConnection("api.shareus.io")
479
+ # payload = json.dumps({
480
+ # "api_key": "4c1YTBacB6PTuwogBiEIFvZN5TI3",
481
+ # "monetization": True,
482
+ # "destination": link,
483
+ # "ad_page": 3,
484
+ # "category": "Entertainment",
485
+ # "tags": ["trendinglinks"],
486
+ # "monetize_with_money": False,
487
+ # "price": 0,
488
+ # "currency": "INR",
489
+ # "purchase_note":""
490
+
491
+ # })
492
+ # headers = {
493
+ # 'Keep-Alive': '',
494
+ # 'Content-Type': 'application/json'
495
+ # }
496
+ # conn.request("POST", "/generate_link", payload, headers)
497
+ # res = conn.getresponse()
498
+ # data = res.read().decode("utf-8")
499
+ # parsed_data = json.loads(data)
500
+ # if parsed_data["status"] == "success":
501
+ # return parsed_data["link"]
502
+ #method 2
503
+ url = f'https://{URL}/easy_api'
504
+ params = {
505
+ "key": API,
506
+ "link": link,
507
+ }
508
+ try:
509
+ async with aiohttp.ClientSession() as session:
510
+ async with session.get(url, params=params, raise_for_status=True, ssl=False) as response:
511
+ data = await response.text()
512
+ return data
513
+ except Exception as e:
514
+ logger.error(e)
515
+ return link
516
+ else:
517
+ shortzy = Shortzy(api_key=API, base_site=URL)
518
+ link = await shortzy.convert(link)
519
+ return link
520
+
521
+ # async def get_shortlink(chat_id, link, second=False):
522
+ # if not second:
523
+ # settings = await get_settings(chat_id) #fetching settings for group
524
+ # if 'shortlink' in settings.keys():
525
+ # URL = settings['shortlink']
526
+ # API = settings['shortlink_api']
527
+ # else:
528
+ # URL = SHORTLINK_URL
529
+ # API = SHORTLINK_API
530
+ # if URL.startswith("shorturllink"):
531
+ # URL = SECOND_SHORTLINK_URL
532
+ # API = SECOND_SHORTLINK_API
533
+ # # if 'shortlink_api' in settings.keys():
534
+ # # API = settings['shortlink_api']
535
+ # # elif URL.startswith("shorturllink"):
536
+ # # URL = SECOND_SHORTLINK_URL
537
+ # # else:
538
+ # # API = SHORTLINK_API
539
+ # https = link.split(":")[0] #splitting https or http from link
540
+ # if "http" == https: #if https == "http":
541
+ # https = "https"
542
+ # link = link.replace("http", https) #replacing http to https
543
+ # if URL == "api.shareus.in":
544
+ # url = f'https://{URL}/shortLink'
545
+ # params = {
546
+ # "token": API,
547
+ # "format": "json",
548
+ # "link": link,
549
+ # }
550
+ # try:
551
+ # async with aiohttp.ClientSession() as session:
552
+ # async with session.get(url, params=params, raise_for_status=True, ssl=False) as response:
553
+ # data = await response.json(content_type="text/html")
554
+ # if data["status"] == "success":
555
+ # return data["shortlink"]
556
+ # else:
557
+ # logger.error(f"Error: {data['message']}")
558
+ # return f'https://{URL}/shortLink?token={API}&format=json&link={link}'
559
+ # except Exception as e:
560
+ # logger.error(e)
561
+ # return f'https://{URL}/shortLink?token={API}&format=json&link={link}'
562
+ # else:
563
+ # url = f'https://{URL}/api'
564
+ # params = {
565
+ # "api": API,
566
+ # "url": link,
567
+ # }
568
+ # try:
569
+ # async with aiohttp.ClientSession() as session:
570
+ # async with session.get(url, params=params, raise_for_status=True, ssl=False) as response:
571
+ # data = await response.json()
572
+ # if data["status"] == "success":
573
+ # return data["shortenedUrl"]
574
+ # else:
575
+ # logger.error(f"Error: {data['message']}")
576
+ # if URL == 'clicksfly.com':
577
+ # return f'https://{URL}/api?api={API}&url={link}'
578
+ # else:
579
+ # return f'https://{URL}/api?api={API}&link={link}'
580
+ # except Exception as e:
581
+ # SECOND_SHORTENER[chat_id] = URL
582
+ # logger.error(e)
583
+ # await get_shortlink(chat_id, link, second=True)
584
+ # # return f'https://{URL}/api?api={API}&link={link}'
585
+ # else:
586
+ # if SECOND_SHORTENER.get(chat_id).startswith('shorturllink'):
587
+ # URL = SECOND_SHORTLINK_URL
588
+ # API = SECOND_SHORTLINK_API
589
+ # else:
590
+ # URL = SHORTLINK_URL
591
+ # API = SHORTLINK_API
592
+ # url = f'https://{URL}/api'
593
+ # params = {
594
+ # "api": API,
595
+ # "url": link,
596
+ # }
597
+ # try:
598
+ # async with aiohttp.ClientSession() as session:
599
+ # async with session.get(url, params=params, raise_for_status=True, ssl=False) as response:
600
+ # data = await response.json()
601
+ # if data["status"] == "success":
602
+ # return data["shortenedUrl"]
603
+ # else:
604
+ # logger.error(f"Error: {data['message']}")
605
+ # return f'https://{URL}/api?api={API}&link={link}'
606
+ # except Exception as e:
607
+ # logger.error(e)
608
+ # return f'https://{URL}/api?api={API}&link={link}'
609
+ # # settings = await get_settings(chat_id) #fetching settings for group
610
+ # # if 'shortlink' in settings.keys():
611
+ # # URL = settings['shortlink']
612
+ # # API = settings['shortlink_api']
613
+ # # else:
614
+ # # URL = SHORTLINK_URL
615
+ # # API = SHORTLINK_API
616
+ # # if URL.startswith("shorturllink"):
617
+ # # URL = SECOND_SHORTLINK_URL
618
+ # # API = SECOND_SHORTLINK_API
619
+ # # # url = settings['url']
620
+ # # # api = settings['api']
621
+ # # shortzy = Shortzy(api_key=API, base_site=URL)
622
+
623
+ # # link = await shortzy.convert(link)
624
+ # # return link
625
+
626
+ async def get_tutorial(chat_id):
627
+ settings = await get_settings(chat_id) #fetching settings for group
628
+ if 'tutorial' in settings.keys():
629
+ if settings['is_tutorial']:
630
+ TUTORIAL_URL = settings['tutorial']
631
+ else:
632
+ TUTORIAL_URL = TUTORIAL
633
+ else:
634
+ TUTORIAL_URL = TUTORIAL
635
+ return TUTORIAL_URL
636
+
637
+ async def get_verify_shorted_link(link):
638
+ API = SHORTLINK_API
639
+ URL = SHORTLINK_URL
640
+ https = link.split(":")[0]
641
+ if "http" == https:
642
+ https = "https"
643
+ link = link.replace("http", https)
644
+
645
+ if URL == "api.shareus.in":
646
+ url = f"https://{URL}/shortLink"
647
+ params = {"token": API,
648
+ "format": "json",
649
+ "link": link,
650
+ }
651
+ try:
652
+ async with aiohttp.ClientSession() as session:
653
+ async with session.get(url, params=params, raise_for_status=True, ssl=False) as response:
654
+ data = await response.json(content_type="text/html")
655
+ if data["status"] == "success":
656
+ return data["shortlink"]
657
+ else:
658
+ logger.error(f"Error: {data['message']}")
659
+ return f'https://{URL}/shortLink?token={API}&format=json&link={link}'
660
+
661
+ except Exception as e:
662
+ logger.error(e)
663
+ return f'https://{URL}/shortLink?token={API}&format=json&link={link}'
664
+ else:
665
+ url = f'https://{URL}/api'
666
+ params = {'api': API,
667
+ 'url': link,
668
+ }
669
+ try:
670
+ async with aiohttp.ClientSession() as session:
671
+ async with session.get(url, params=params, raise_for_status=True, ssl=False) as response:
672
+ data = await response.json()
673
+ if data["status"] == "success":
674
+ return data['shortenedUrl']
675
+ else:
676
+ logger.error(f"Error: {data['message']}")
677
+ return f'https://{URL}/api?api={API}&link={link}'
678
+
679
+ except Exception as e:
680
+ logger.error(e)
681
+ return f'{URL}/api?api={API}&link={link}'
682
+
683
+ async def check_token(bot, userid, token):
684
+ user = await bot.get_users(userid)
685
+ if not await db.is_user_exist(user.id):
686
+ await db.add_user(user.id, user.first_name)
687
+ await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention))
688
+ if user.id in TOKENS.keys():
689
+ TKN = TOKENS[user.id]
690
+ if token in TKN.keys():
691
+ is_used = TKN[token]
692
+ if is_used == True:
693
+ return False
694
+ else:
695
+ return True
696
+ else:
697
+ return False
698
+
699
+ async def get_token(bot, userid, link):
700
+ user = await bot.get_users(userid)
701
+ if not await db.is_user_exist(user.id):
702
+ await db.add_user(user.id, user.first_name)
703
+ await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention))
704
+ token = ''.join(random.choices(string.ascii_letters + string.digits, k=7))
705
+ TOKENS[user.id] = {token: False}
706
+ link = f"{link}verify-{user.id}-{token}"
707
+ shortened_verify_url = await get_verify_shorted_link(link)
708
+ return str(shortened_verify_url)
709
+
710
+ async def verify_user(bot, userid, token):
711
+ user = await bot.get_users(userid)
712
+ if not await db.is_user_exist(user.id):
713
+ await db.add_user(user.id, user.first_name)
714
+ await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention))
715
+ TOKENS[user.id] = {token: True}
716
+ tz = pytz.timezone('Asia/Kolkata')
717
+ today = date.today()
718
+ VERIFIED[user.id] = str(today)
719
+
720
+ async def check_verification(bot, userid):
721
+ user = await bot.get_users(userid)
722
+ if not await db.is_user_exist(user.id):
723
+ await db.add_user(user.id, user.first_name)
724
+ await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(user.id, user.mention))
725
+ tz = pytz.timezone('Asia/Kolkata')
726
+ today = date.today()
727
+ if user.id in VERIFIED.keys():
728
+ EXP = VERIFIED[user.id]
729
+ years, month, day = EXP.split('-')
730
+ comp = date(int(years), int(month), int(day))
731
+ if comp<today:
732
+ return False
733
+ else:
734
+ return True
735
+ else:
736
+ return False
737
+
738
+
739
+ async def send_all(bot, userid, files, ident, chat_id, user_name, query):
740
+ settings = await get_settings(chat_id)
741
+ if 'is_shortlink' in settings.keys():
742
+ ENABLE_SHORTLINK = settings['is_shortlink']
743
+ else:
744
+ await save_group_settings(message.chat.id, 'is_shortlink', False)
745
+ ENABLE_SHORTLINK = False
746
+ try:
747
+ if ENABLE_SHORTLINK:
748
+ for file in files:
749
+ title = file.file_name
750
+ size = get_size(file.file_size)
751
+ await bot.send_message(chat_id=userid, text=f"<b>Hᴇʏ ᴛʜᴇʀᴇ {user_name} 👋🏽 \n\n✅ Sᴇᴄᴜʀᴇ ʟɪɴᴋ ᴛᴏ ʏᴏᴜʀ ғɪʟᴇ ʜᴀs sᴜᴄᴄᴇssғᴜʟʟʏ ʙᴇᴇɴ ɢᴇɴᴇʀᴀᴛᴇᴅ ᴘʟᴇᴀsᴇ ᴄʟɪᴄᴋ ᴅᴏᴡɴʟᴏᴀᴅ ʙᴜᴛᴛᴏɴ\n\n🗃️ Fɪʟᴇ Nᴀᴍᴇ : {title}\n🔖 Fɪʟᴇ Sɪᴢᴇ : {size}</b>", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("📤 Dᴏᴡɴʟᴏᴀᴅ 📥", url=await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}"))]]))
752
+ else:
753
+ for file in files:
754
+ f_caption = file.caption
755
+ title = file.file_name
756
+ size = get_size(file.file_size)
757
+ if CUSTOM_FILE_CAPTION:
758
+ try:
759
+ f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title,
760
+ file_size='' if size is None else size,
761
+ file_caption='' if f_caption is None else f_caption)
762
+ except Exception as e:
763
+ print(e)
764
+ f_caption = f_caption
765
+ if f_caption is None:
766
+ f_caption = f"{title}"
767
+ await bot.send_cached_media(
768
+ chat_id=userid,
769
+ file_id=file.file_id,
770
+ caption=f_caption,
771
+ protect_content=True if ident == "filep" else False,
772
+ reply_markup=InlineKeyboardMarkup(
773
+ [
774
+ [
775
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK),
776
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
777
+ ],[
778
+ InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/Kgashok04")
779
+ ]
780
+ ]
781
+ )
782
+ )
783
+ except UserIsBlocked:
784
+ await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True)
785
+ except PeerIdInvalid:
786
+ await query.answer('Hᴇʏ, Sᴛᴀʀᴛ Bᴏᴛ Fɪʀsᴛ Aɴᴅ Cʟɪᴄᴋ Sᴇɴᴅ Aʟʟ', show_alert=True)
787
+ except Exception as e:
788
+ await query.answer('Hᴇʏ, Sᴛᴀʀᴛ Bᴏᴛ Fɪʀsᴛ Aɴᴅ Cʟɪᴄᴋ Sᴇɴᴅ Aʟʟ', show_alert=True)
789
+ '''if IS_SHORTLINK == True:
790
+ for file in files:
791
+ title = file.file_name
792
+ size = get_size(file.file_size)
793
+ await bot.send_message(chat_id=userid, text=f"<b>Hᴇʏ ᴛʜᴇʀᴇ {user_name} 👋🏽 \n\n✅ Sᴇᴄᴜʀᴇ ʟɪɴᴋ ᴛᴏ ʏᴏᴜʀ ғɪʟᴇ ʜᴀs sᴜᴄᴄᴇssғᴜʟʟʏ ʙᴇᴇɴ ɢᴇɴᴇʀᴀᴛᴇᴅ ᴘʟᴇᴀsᴇ ᴄʟɪᴄᴋ ᴅᴏᴡɴʟᴏᴀᴅ ʙᴜᴛᴛᴏɴ\n\n🗃️ Fɪʟᴇ Nᴀᴍᴇ : {title}\n🔖 Fɪʟᴇ Sɪᴢᴇ : {size}</b>", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("📤 Dᴏᴡɴʟᴏᴀᴅ 📥", url=await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}"))]])
794
+ )
795
+ else:
796
+ for file in files:
797
+ f_caption = file.caption
798
+ title = file.file_name
799
+ size = get_size(file.file_size)
800
+ if CUSTOM_FILE_CAPTION:
801
+ try:
802
+ f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title,
803
+ file_size='' if size is None else size,
804
+ file_caption='' if f_caption is None else f_caption)
805
+ except Exception as e:
806
+ print(e)
807
+ f_caption = f_caption
808
+ if f_caption is None:
809
+ f_caption = f"{title}"
810
+ await bot.send_cached_media(
811
+ chat_id=userid,
812
+ file_id=file.file_id,
813
+ caption=f_caption,
814
+ protect_content=True if ident == "filep" else False,
815
+ reply_markup=InlineKeyboardMarkup(
816
+ [
817
+ [
818
+ InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK),
819
+ InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
820
+ ],[
821
+ InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/Kgashok04")
822
+ ]
823
+ ]
824
+ )
825
+ )'''
826
+