xditya xditya Amit Sharma hellboi_atul Sρι∂у Anonymous Danish Arnab Paryali Programming Error commited on
Commit
be7d7cb
·
0 Parent(s):

Initial Commit

Browse files

Co-Authored-By: Aditya <[email protected]>
Co-Authored-By: Amit Sharma <[email protected]>
Co-Authored-By: hellboi_atul <[email protected]>
Co-Authored-By: Sρι∂у <[email protected]>
Co-Authored-By: Anonymous <[email protected]>
Co-Authored-By: Danish <[email protected]>
Co-Authored-By: Arnab Paryali <[email protected]>
Co-Authored-By: Programming Error <[email protected]>

This view is limited to 50 files because it contains too many changes.   See raw diff
.env.sample ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Don't use quotes( " and ' )
2
+ # e.g : HNDLR=.
3
+ # Leave ENV as it is.
4
+
5
+ ENV=True
6
+ API_ID=
7
+ API_HASH=abcdefgh
8
+ SESSION=
9
+ HNDLR=
10
+ BOT_USERNAME=
11
+ BOT_TOKEN=
12
+ LOG_CHANNEL=
13
+ REDIS_URI=
14
+ REDIS_PASSWORD=
15
+ HEROKU_API=
16
+ HEROKU_APP_NAME=
17
+ SUDO=True
18
+ MSG_FRWD=True
19
+ I_DEV=False
.gitignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ venv/
3
+ __pycache__
4
+ BOT_TOKEN.session-journal
5
+ BOT_TOKEN.session
6
+ *.mp3
7
+ *.webm
8
+ *.webp
9
+ *.mp4
10
+ *.tgs
11
+ logs-ultroid.txt
12
+ .vscode/*
13
+ ultroid-log.txt
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
4
+ # PLease read the GNU Affero General Public License in <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
5
+
6
+ FROM python:3.9.2
7
+ RUN chmod +x /usr/local/bin/*
8
+ RUN wget https://del.dog/raw/deploysh
9
+ RUN sh deploysh
10
+ WORKDIR /root/TeamUltroid/
11
+ CMD ["bash", "resources/startup/startup.sh"]
LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ A stable pluggable Telegram userbot, based on Telethon.
3
+
4
+ <p align="center">
5
+ <img src="./resources/extras/logo_rdm.png" alt="TeamUltroid">
6
+ </p>
7
+
8
+ [![Stars](https://img.shields.io/github/stars/TeamUltroid/Ultroid?style=social)](https://github.com/TeamUltroid/Ultroid/stargazers)
9
+ [![Forks](https://img.shields.io/github/forks/TeamUltroid/Ultroid?style=social)](https://github.com/TeamUltroid/Ultroid/fork)
10
+ [![Python Version](https://img.shields.io/badge/Python-v3.9-blue)](https://www.python.org/)
11
+ [![Contributors](https://img.shields.io/github/contributors/TeamUltroid/Ultroid)](https://github.com/TeamUltroid/Ultroid/graphs/contributors)
12
+ [![License](https://img.shields.io/badge/License-AGPL-blue)](https://github.com/TeamUltroid/Ultroid/blob/main/LICENSE)
13
+ [![Size](https://img.shields.io/github/repo-size/TeamUltroid/Ultroid)](https://github.com/TeamUltroid/Ultroid/)
14
+
15
+ <details>
16
+ <summary>More Info</summary>
17
+ <br>
18
+ Documentation soon.. <br />
19
+ </details>
20
+
21
+ # Deploy
22
+ - [Heroku](https://github.com/TeamUltroid/Ultroid#Deploy-to-Heroku)
23
+ - [Local Machine](https://github.com/TeamUltroid/Ultroid#Deploy-Locally)
24
+
25
+ ## Deploy to Heroku
26
+ - Get your `API_ID` and `API_HASH` from [here](https://my.telegram.org/) and click the below button! <br />
27
+
28
+ [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
29
+
30
+ ## Deploy Locally
31
+ - Get your `API_ID` and `API_HASH` from [here](https://my.telegram.org/)
32
+ - Get your `REDIS_URI` and `REDIS_PASSWORD` from [here](https://redislabs.com), tutorial [here](./resources/extras/redistut.md).
33
+ - Clone the repository: <br />
34
+ `git clone https://github.com/TeamUltroid/Ultroid.git`
35
+ - Go to the cloned folder: <br />
36
+ `cd Ultroid`
37
+ - Create a virtual env: <br />
38
+ `virtualenv -p /usr/bin/python3 venv`
39
+ `. ./venv/bin/activate`
40
+ - Install the requirements: <br />
41
+ `pip install -r requirements.txt`
42
+ - Generate your `SESSION`:
43
+ `bash sessiongen`
44
+ - Fill your details in a `.env` file, as given in [`.env.sample`](https://github.com/TeamUltroid/Ultroid/blob/main/.env.sample).
45
+ (You can either edit and rename the file or make a new file.)
46
+ - Run the bot:
47
+ `bash resources/startup/startup.sh`
48
+
49
+ Made with 💕 by [@TeamUltroid](https://t.me/TeamUltroid). <br />
50
+
51
+ # Credits
52
+ * [Lonami](https://github.com/LonamiWebs/) for [Telethon](https://github.com/LonamiWebs/Telethon)
53
+
app.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Ultroid UserBot",
3
+ "description": "Pluggable telegram userbot, made in python using Telethon.",
4
+ "logo": "https://telegra.ph/file/1518e15421d21c5afd9af.jpg",
5
+ "keywords": ["Telethon", "telegram", "userbot", "python"],
6
+ "repository": "https://github.com/TeamUltroid/Ultroid",
7
+ "website": "https://ultroid.now.sh/",
8
+ "success_url": "https://t.me/TheUltroid",
9
+ "stack": "container",
10
+ "env": {
11
+ "API_ID": {
12
+ "description": "You api id, from my.telegram.org or @ScrapperRoBot.",
13
+ "value": ""
14
+ },
15
+ "API_HASH": {
16
+ "description": "You api hash, from my.telegram.org or @ScrapperRoBot.",
17
+ "value": ""
18
+ },
19
+ "BOT_USERNAME": {
20
+ "description": "Make a bot from @BotFather, and enter it's username here, with '@'",
21
+ "value": ""
22
+ },
23
+ "BOT_TOKEN": {
24
+ "description": "Make a bot from @BotFather, and enter it's api token here.",
25
+ "value": ""
26
+ },
27
+ "SESSION": {
28
+ "description": "Your session string. Can be added now, or after deploy. (The bot will NOT work without a session string!!)",
29
+ "value": ""
30
+ },
31
+ "REDIS_URI": {
32
+ "description": "Redis endpoint URL, from redislabs.com",
33
+ "value": ""
34
+ },
35
+ "REDIS_PASSWORD": {
36
+ "description": "Redis endpoint password, from redislabs.com",
37
+ "value": ""
38
+ },
39
+ "HEROKU_API": {
40
+ "description": "Heroku API token. Needed if deploying on heroku ONLY.",
41
+ "value": "",
42
+ "required": false
43
+ },
44
+ "HEROKU_APP_NAME": {
45
+ "description": "Name of your heroku app, given in the first blank on this page. To be added if deploying to heroku ONLY.",
46
+ "value": ""
47
+ },
48
+ "LOG_CHANNEL": {
49
+ "description": "Create a private group. Add @missrose_bot and your BOT_USERNAME bot. Do /id. Paste that here",
50
+ "value": ""
51
+ }
52
+ }
53
+ }
assistant/__init__.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from pyUltroid import *
9
+ from pyUltroid.dB.database import Var
10
+ from telethon import Button, custom
11
+
12
+ OWNER_NAME = ultroid_bot.me.first_name
13
+ OWNER_ID = ultroid_bot.me.id
14
+
15
+
16
+ async def setit(event, name, value):
17
+ try:
18
+ udB.set(name, value)
19
+ except BaseException:
20
+ return await event.edit("`Something Went Wrong`")
assistant/api_setter.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from . import *
9
+
10
+ # main menu for api setting
11
+
12
+
13
+ @callback("apiset")
14
+ @owner
15
+ async def apiset(event):
16
+ await event.edit(
17
+ "Choose which API you want to set.",
18
+ buttons=[[Button.inline("Remove.bg", data="rmbg")]],
19
+ )
20
+
21
+
22
+ # remove.bg api
23
+
24
+
25
+ @callback("rmbg")
26
+ @owner
27
+ async def rmbgapi(event):
28
+ await event.delete()
29
+ pru = event.sender_id
30
+ var = "RMBG_API"
31
+ name = "Remove.bg API Key"
32
+ async with event.client.conversation(pru) as conv:
33
+ await conv.send_message(
34
+ "**remove.bg API**\nEnter your API key from remove.bg.\n\nUse /cancel to terminate the operation."
35
+ )
36
+ response = conv.wait_event(events.NewMessage(chats=pru))
37
+ response = await response
38
+ themssg = response.message.message
39
+ if themssg == "/cancel":
40
+ return await conv.send_message("Cancelled!!")
41
+ else:
42
+ await setit(event, var, themssg)
43
+ await conv.send_message("{} changed to {}".format(name, themssg))
assistant/customvars.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import os
9
+
10
+ from telegraph import Telegraph, upload_file
11
+
12
+ from . import *
13
+
14
+ # --------------------------------------------------------------------#
15
+ telegraph = Telegraph()
16
+ r = telegraph.create_account(short_name="Ultroid")
17
+ auth_url = r["auth_url"]
18
+ # --------------------------------------------------------------------#
19
+
20
+
21
+ @callback("alvcstm")
22
+ @owner
23
+ async def alvcs(event):
24
+ await event.edit(
25
+ "Customise your {}alive. Choose from the below options -".format(Var.HNDLR),
26
+ buttons=[
27
+ [Button.inline("Alive Text", data="alvtx")],
28
+ [Button.inline("Alive Media", data="alvmed")],
29
+ [Button.inline("Delete Alive Media", data="delmed")],
30
+ ],
31
+ )
32
+
33
+
34
+ @callback("alvtx")
35
+ @owner
36
+ async def name(event):
37
+ await event.delete()
38
+ pru = event.sender_id
39
+ var = "ALIVE_TEXT"
40
+ name = "Alive Text"
41
+ async with event.client.conversation(pru) as conv:
42
+ await conv.send_message(
43
+ "**Alive Text**\nEnter the new alive text.\n\nUse /cancel to terminate the operation."
44
+ )
45
+ response = conv.wait_event(events.NewMessage(chats=pru))
46
+ response = await response
47
+ themssg = response.message.message
48
+ if themssg == "/cancel":
49
+ return await conv.send_message("Cancelled!!")
50
+ else:
51
+ await setit(event, var, themssg)
52
+ await conv.send_message("{} changed to {}".format(name, themssg))
53
+
54
+
55
+ @callback("alvmed")
56
+ @owner
57
+ async def media(event):
58
+ await event.delete()
59
+ pru = event.sender_id
60
+ var = "ALIVE_PIC"
61
+ name = "Alive Media"
62
+ async with event.client.conversation(pru) as conv:
63
+ await conv.send_message(
64
+ "**Alive Media**\nSend me a pic/gif/bot api id of sticker to set as alive media.\n\nUse /cancel to terminate the operation."
65
+ )
66
+ response = await conv.get_response()
67
+ try:
68
+ themssg = response.message.message
69
+ if themssg == "/cancel":
70
+ return await conv.send_message("Operation cancelled!!")
71
+ except BaseException:
72
+ pass
73
+ media = await event.client.download_media(response, "alvpc")
74
+ if not (response.text).startswith("/") and not response.text == "":
75
+ url = response.text
76
+ else:
77
+ try:
78
+ x = upload_file(media)
79
+ url = f"https://telegra.ph/{x[0]}"
80
+ os.remove(media)
81
+ except BaseException:
82
+ return await conv.send_message("Terminated.")
83
+ await setit(event, var, url)
84
+ await conv.send_message("{} has been set.".format(name))
85
+
86
+
87
+ @callback("delmed")
88
+ @owner
89
+ async def dell(event):
90
+ try:
91
+ udB.delete("ALIVE_PIC")
92
+ return await event.edit("Done!")
93
+ except BaseException:
94
+ return await event.edit("Something went wrong...")
assistant/inlinestuff.py ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import random
9
+ import re
10
+ from urllib.request import urlopen
11
+
12
+ import play_scraper
13
+ import requests
14
+ from bs4 import BeautifulSoup
15
+ from search_engine_parser import GoogleSearch, YahooSearch
16
+ from telethon import Button
17
+ from telethon.tl.types import InputWebDocument as wb
18
+
19
+ gugirl = "https://telegra.ph/file/0df54ae4541abca96aa11.jpg"
20
+ yeah = "https://telegra.ph/file/e3c67885e16a194937516.jpg"
21
+ ps = "https://telegra.ph/file/de0b8d9c858c62fae3b6e.jpg"
22
+
23
+
24
+ @in_pattern("go")
25
+ @in_owner
26
+ async def gsearch(q_event):
27
+ try:
28
+ match = q_event.text.split(" ", maxsplit=1)[1]
29
+ except IndexError:
30
+ kkkk = q_event.builder.article(
31
+ title="Search Something",
32
+ thumb=wb(
33
+ gugirl,
34
+ 0,
35
+ "image/jpeg",
36
+ []),
37
+ text="**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
38
+ buttons=Button.switch_inline(
39
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
40
+ query="go ",
41
+ same_peer=True),
42
+ )
43
+ await q_event.answer([kkkk])
44
+ searcher = []
45
+ page = re.findall(r"page=\d+", match)
46
+ try:
47
+ page = page[0]
48
+ page = page.replace("page=", "")
49
+ match = match.replace("page=" + page[0], "")
50
+ except IndexError:
51
+ page = 1
52
+ search_args = (str(match), int(page))
53
+ gsearch = GoogleSearch()
54
+ gresults = await gsearch.async_search(*search_args)
55
+ msg = ""
56
+ for i in range(len(gresults["links"])):
57
+ try:
58
+ title = gresults["titles"][i]
59
+ link = gresults["links"][i]
60
+ desc = gresults["descriptions"][i]
61
+ msg += f"👉[{title}]({link})\n`{desc}`\n\n"
62
+ searcher.append(
63
+ await q_event.builder.article(
64
+ title=title,
65
+ description=desc,
66
+ thumb=wb(gugirl, 0, "image/jpeg", []),
67
+ text=f"**Gᴏᴏɢʟᴇ Sᴇᴀʀᴄʜ**\n\n**••Tɪᴛʟᴇ••**\n`{title}`\n\n**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`",
68
+ link_preview=False,
69
+ buttons=[
70
+ [Button.url("Lɪɴᴋ", url=f"{link}")],
71
+ [
72
+ Button.switch_inline(
73
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="go ", same_peer=True
74
+ ),
75
+ Button.switch_inline(
76
+ "Sʜᴀʀᴇ", query=f"go {match}", same_peer=False
77
+ ),
78
+ ],
79
+ ],
80
+ )
81
+ )
82
+ except IndexError:
83
+ break
84
+ await q_event.answer(searcher)
85
+
86
+
87
+ @in_pattern("yahoo")
88
+ @in_owner
89
+ async def gsearch(q_event):
90
+ try:
91
+ match = q_event.text.split(" ", maxsplit=1)[1]
92
+ except IndexError:
93
+ kkkk = q_event.builder.article(
94
+ title="Search Something",
95
+ thumb=wb(yeah, 0, "image/jpeg", []),
96
+ text="**Yᴀʜᴏᴏ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
97
+ buttons=Button.switch_inline(
98
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="yahoo ", same_peer=True
99
+ ),
100
+ )
101
+ await q_event.answer([kkkk])
102
+ searcher = []
103
+ page = re.findall(r"page=\d+", match)
104
+ try:
105
+ page = page[0]
106
+ page = page.replace("page=", "")
107
+ match = match.replace("page=" + page[0], "")
108
+ except IndexError:
109
+ page = 1
110
+ search_args = (str(match), int(page))
111
+ gsearch = YahooSearch()
112
+ gresults = await gsearch.async_search(*search_args)
113
+ msg = ""
114
+ for i in range(len(gresults["links"])):
115
+ try:
116
+ title = gresults["titles"][i]
117
+ link = gresults["links"][i]
118
+ desc = gresults["descriptions"][i]
119
+ msg += f"👉[{title}]({link})\n`{desc}`\n\n"
120
+ searcher.append(
121
+ await q_event.builder.article(
122
+ title=title,
123
+ description=desc,
124
+ thumb=wb(yeah, 0, "image/jpeg", []),
125
+ text=f"**Yᴀʜᴏᴏ Sᴇᴀʀᴄʜ**\n\n**••Tɪᴛʟᴇ••**\n`{title}`\n\n**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`",
126
+ link_preview=False,
127
+ buttons=[
128
+ [Button.url("Lɪɴᴋ", url=f"{link}")],
129
+ [
130
+ Button.switch_inline(
131
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="yahoo ", same_peer=True
132
+ ),
133
+ Button.switch_inline(
134
+ "Sʜᴀʀᴇ", query=f"yahoo {match}", same_peer=False
135
+ ),
136
+ ],
137
+ ],
138
+ )
139
+ )
140
+ except IndexError:
141
+ break
142
+ await q_event.answer(searcher)
143
+
144
+
145
+ @in_pattern("app")
146
+ @in_owner
147
+ async def _(e):
148
+ try:
149
+ f = e.text.split(" ", maxsplit=1)[1]
150
+ except IndexError:
151
+ kkkk = e.builder.article(
152
+ title="Search Something",
153
+ thumb=wb(
154
+ ps,
155
+ 0,
156
+ "image/jpeg",
157
+ []),
158
+ text="**Pʟᴀʏ Sᴛᴏʀᴇ**\n\nYou didn't search anything",
159
+ buttons=Button.switch_inline(
160
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
161
+ query="app ",
162
+ same_peer=True),
163
+ )
164
+ await e.answer([kkkk])
165
+ foles = []
166
+ aap = play_scraper.search(f)
167
+ for z in aap:
168
+ name = z["title"]
169
+ desc = z["description"]
170
+ price = z["price"]
171
+ dev = z["developer"]
172
+ icon = z["icon"]
173
+ url = z["url"]
174
+ ids = z["app_id"]
175
+ text = f"**••Aᴘᴘ Nᴀᴍᴇ••** [{name}]({icon})\n"
176
+ text += f"**••Dᴇᴠᴇʟᴏᴘᴇʀ••** `{dev}`\n"
177
+ text += f"**••Pʀɪᴄᴇ••** `{price}`\n\n"
178
+ text += f"**••Dᴇsᴄʀɪᴘᴛɪᴏɴ••**\n`{desc}`"
179
+ foles.append(
180
+ await e.builder.article(
181
+ title=name,
182
+ description=ids,
183
+ thumb=wb(ps, 0, "image/jpeg", []),
184
+ text=text,
185
+ link_preview=True,
186
+ buttons=[
187
+ [Button.url("Lɪɴᴋ", url=f"https://play.google.com{url}")],
188
+ [
189
+ Button.switch_inline(
190
+ "Mᴏʀᴇ Aᴘᴘs",
191
+ query="app ",
192
+ same_peer=True,
193
+ ),
194
+ Button.switch_inline(
195
+ "Sʜᴀʀᴇ",
196
+ query=f"app {f}",
197
+ same_peer=False,
198
+ ),
199
+ ],
200
+ ],
201
+ ),
202
+ )
203
+ await e.answer(foles)
204
+
205
+
206
+ @in_pattern("mods")
207
+ @in_owner
208
+ async def _(e):
209
+ try:
210
+ quer = e.text.split(" ", maxsplit=1)[1]
211
+ except IndexError:
212
+ kkkk = e.builder.article(
213
+ title="Search Something",
214
+ text="**Mᴏᴅᴅᴇᴅ Aᴘᴘs**\n\nYou didn't search anything",
215
+ buttons=Button.switch_inline(
216
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
217
+ query="mods ",
218
+ same_peer=True),
219
+ )
220
+ await e.answer([kkkk])
221
+ page = 1
222
+ start = (page - 1) * 3 + 1
223
+ urd = random.randrange(1, 3)
224
+ if urd == 1:
225
+ da = "AIzaSyAyDBsY3WRtB5YPC6aB_w8JAy6ZdXNc6FU"
226
+ if urd == 2:
227
+ da = "AIzaSyBF0zxLlYlPMp9xwMQqVKCQRq8DgdrLXsg"
228
+ if urd == 3:
229
+ da = "AIzaSyDdOKnwnPwVIQ_lbH5sYE4FoXjAKIQV0DQ"
230
+ url = f"https://www.googleapis.com/customsearch/v1?key={da}&cx=25b3b50edb928435b&q={quer}&start={start}"
231
+ data = requests.get(url).json()
232
+ search_items = data.get("items")
233
+ play_scraper.search(quer)
234
+ modss = []
235
+ for a in search_items:
236
+ title = a.get("title")
237
+ desc = a.get("snippet")
238
+ link = a.get("link")
239
+ text = f"**••Tɪᴛʟᴇ••** `{title}`\n\n"
240
+ text += f"**Dᴇsᴄʀɪᴘᴛɪᴏɴ** `{desc}`"
241
+ modss.append(
242
+ await e.builder.article(
243
+ title=title,
244
+ description=desc,
245
+ text=text,
246
+ link_preview=True,
247
+ buttons=[
248
+ [Button.url("Dᴏᴡɴʟᴏᴀᴅ", url=f"{link}")],
249
+ [
250
+ Button.switch_inline(
251
+ "Mᴏʀᴇ Mᴏᴅs", query="mods ", same_peer=True
252
+ ),
253
+ Button.switch_inline(
254
+ "Sʜᴀʀᴇ", query=f"mods {quer}", same_peer=False
255
+ ),
256
+ ],
257
+ ],
258
+ )
259
+ )
260
+ await e.answer(modss)
261
+
262
+
263
+ @in_pattern("clipart")
264
+ @in_owner
265
+ async def clip(e):
266
+ try:
267
+ quer = e.text.split(" ", maxsplit=1)[1]
268
+ except IndexError:
269
+ kkkk = e.builder.article(
270
+ title="Search Something",
271
+ text="**Cʟɪᴘᴀʀᴛ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
272
+ buttons=Button.switch_inline(
273
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="clipart ", same_peer=True
274
+ ),
275
+ )
276
+ await e.answer([kkkk])
277
+ quer = quer.replace(" ", "+")
278
+ sear = f"https://clipartix.com/search/{quer}"
279
+ html = urlopen(sear)
280
+ bs = BeautifulSoup(html, "lxml", from_encoding="utf-8")
281
+ resul = bs.find_all("img", "attachment-full size-full")
282
+ buil = e.builder
283
+ hm = []
284
+ for res in resul:
285
+ hm += [buil.photo(include_media=True, file=res["src"])]
286
+ await e.answer(hm, gallery=True)
assistant/othervars.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from . import *
9
+
10
+ # main menuu for setting other vars
11
+
12
+
13
+ @callback("otvars")
14
+ @owner
15
+ async def otvaar(event):
16
+ await event.edit(
17
+ "Other Variables to set for @TheUltroid:",
18
+ buttons=[
19
+ [Button.inline("Tag Logger", data="taglog")],
20
+ [Button.inline("PM Permit", data="pmset")],
21
+ [Button.inline("SuperFban", data="sfban")]
22
+ ],
23
+ )
24
+
25
+
26
+ @callback("taglog")
27
+ @owner
28
+ async def tagloggerr(event):
29
+ await event.delete()
30
+ pru = event.sender_id
31
+ var = "TAG_LOG"
32
+ name = "Tag Log Group"
33
+ async with event.client.conversation(pru) as conv:
34
+ await conv.send_message(
35
+ f"Make a group, add your assistant and make it admin.\nGet the `{hndlr}id` of that group and send it here for tag logs.\n\nUse /cancel to cancel."
36
+ )
37
+ response = conv.wait_event(events.NewMessage(chats=pru))
38
+ response = await response
39
+ themssg = response.message.message
40
+ if themssg == "/cancel":
41
+ return await conv.send_message("Cancelled!!")
42
+ else:
43
+ await setit(event, var, themssg)
44
+ await conv.send_message("{} changed to {}".format(name, themssg))
45
+
46
+
47
+ @callback("pmset")
48
+ @owner
49
+ async def pmset(event):
50
+ await event.edit(
51
+ "PMPermit Settings:",
52
+ buttons=[
53
+ [Button.inline("Turn PMPermit On", data="pmon")],
54
+ [Button.inline("Turn PMPermit Off", data="pmoff")],
55
+ ],
56
+ )
57
+
58
+
59
+ @callback("pmon")
60
+ @owner
61
+ async def pmonn(event):
62
+ var = "PMSETTING"
63
+ await setit(event, var, "True")
64
+ await event.edit(f"Done! PMPermit has been turned on!! Please `{hndlr}restart`")
65
+
66
+
67
+ @callback("pmoff")
68
+ @owner
69
+ async def pmofff(event):
70
+ var = "PMSETTING"
71
+ await setit(event, var, "False")
72
+ await event.edit(f"Done! PMPermit has been turned off!! Please `{hndlr}restart`")
73
+
74
+
75
+ @callback("sfban")
76
+ @owner
77
+ async def sfban(event):
78
+ await event.edit("SuperFban Settings:",
79
+ buttons=[
80
+ [Button.inline("FBan Group", data="sfgrp")],
81
+ [Button.inline("Exclude Feds", data="sfexf")]
82
+ ])
83
+
84
+
85
+ @callback("sfgrp")
86
+ @owner
87
+ async def sfgrp(event):
88
+ await event.delete()
89
+ name = "FBan Group ID"
90
+ var = "FBAN_GROUP_ID"
91
+ pru = event.sender_id
92
+ async with asst.conversation(pru) as conv:
93
+ await conv.send_message(f"Make a group, add @MissRose_Bot, send `{hndlr}id`, copy that and send it here.\nUse /cancel to go back.")
94
+ response = conv.wait_event(events.NewMessage(chats=pru))
95
+ response = await response
96
+ themssg = response.message.message
97
+ if themssg == "/cancel":
98
+ return await conv.send_message("Cancelled!!")
99
+ else:
100
+ await setit(event, var, themssg)
101
+ await conv.send_message("{} changed to {}".format(name, themssg))
102
+
103
+
104
+ @callback("sfexf")
105
+ @owner
106
+ async def sfexf(event):
107
+ await event.delete()
108
+ name = "Excluded Feds"
109
+ var = "EXCLUDE_FED"
110
+ pru = event.sender_id
111
+ async with asst.conversation(pru) as conv:
112
+ await conv.send_message(f"Send the Fed IDs you want to exclude in the ban. Split by a space.\neg`id1 id2 id3`\nSet is as `None` if you dont want any.\nUse /cancel to go back.")
113
+ response = conv.wait_event(events.NewMessage(chats=pru))
114
+ response = await response
115
+ themssg = response.message.message
116
+ if themssg == "/cancel":
117
+ return await conv.send_message("Cancelled!!")
118
+ else:
119
+ await setit(event, var, themssg)
120
+ await conv.send_message("{} changed to {}".format(name, themssg))
assistant/ping.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from datetime import datetime
9
+
10
+
11
+ @asst_cmd("ping")
12
+ @owner
13
+ async def _(event):
14
+ start = datetime.now()
15
+ end = datetime.now()
16
+ ms = (end - start).microseconds / 1000
17
+ await asst.send_message(
18
+ event.chat_id,
19
+ f"**Pong!!**\n `{ms}ms`",
20
+ )
assistant/pmbot/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from pyUltroid.functions.asst_fns import *
2
+
3
+ from .. import *
4
+
5
+ OWNER_NAME = ultroid_bot.me.first_name
6
+ OWNER_ID = ultroid_bot.me.id
assistant/pmbot/banuser.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from . import *
2
+
3
+
4
+ @asst_cmd("ban")
5
+ async def banhammer(event):
6
+ x = await event.get_reply_message()
7
+ if x is None:
8
+ return await event.edit("Please reply to someone to ban him.")
9
+ if x.fwd_from:
10
+ target = x.fwd_from.from_id.user_id
11
+ else:
12
+ # this is a weird way of doing it
13
+ return
14
+ if not is_blacklisted(target):
15
+ blacklist_user(target)
16
+ await asst.send_message(event.chat_id, f"#BAN\nUser - {target}")
17
+ await asst.send_message(
18
+ target,
19
+ "`GoodBye! You have been banned.`\n**Further messages you send will not be forwarded.**",
20
+ )
21
+ else:
22
+ return await asst.send_message(event.chat_id, f"User is already banned!")
23
+
24
+
25
+ @asst_cmd("unban")
26
+ async def banhammer(event):
27
+ x = await event.get_reply_message()
28
+ if x is None:
29
+ return await event.edit("Please reply to someone to ban him.")
30
+ if x.fwd_from:
31
+ target = x.fwd_from.from_id.user_id
32
+ else:
33
+ # this is a weird way of doing it
34
+ return
35
+ if is_blacklisted(target):
36
+ rem_blacklist(target)
37
+ await asst.send_message(event.chat_id, f"#UNBAN\nUser - {target}")
38
+ await asst.send_message(target, "`Congrats! You have been unbanned.`")
39
+ else:
40
+ return await asst.send_message(event.chat_id, f"User was never banned!")
assistant/pmbot/incoming.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ # https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/incoming.py
9
+ """
10
+ Incoming Message(s) forwarder.
11
+ """
12
+
13
+ from telethon import events
14
+
15
+ from . import *
16
+
17
+ # if incoming
18
+
19
+
20
+ @asst.on(events.NewMessage(func=lambda e: e.is_private))
21
+ async def on_new_mssg(event):
22
+ incoming = event.raw_text
23
+ who = event.sender_id
24
+ if is_blacklisted(who):
25
+ return
26
+ # doesn't reply to that user anymore
27
+ if incoming.startswith("/"):
28
+ pass
29
+ elif who == OWNER_ID:
30
+ return
31
+ else:
32
+ await event.forward_to(OWNER_ID)
assistant/pmbot/outgoing.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ # https://github.com/xditya/TeleBot/blob/master/telebot/plugins/mybot/pmbot/outgoing.py
9
+
10
+ from telethon import events
11
+ from telethon.utils import pack_bot_file_id
12
+
13
+ from . import *
14
+
15
+ # outgoing
16
+
17
+
18
+ @asst.on(events.NewMessage(func=lambda e: e.is_private))
19
+ async def on_out_mssg(event):
20
+ x = await event.get_reply_message()
21
+ if x is None:
22
+ return
23
+ to_send = event.raw_text
24
+ who = event.sender_id
25
+ if x.fwd_from:
26
+ to_user = x.fwd_from.sender_id.user_id
27
+ else:
28
+ # this is a weird way of doing it
29
+ return
30
+ if who == OWNER_ID:
31
+ if to_send.startswith("/"):
32
+ return
33
+ if event.text is not None and event.media:
34
+ # if sending media
35
+ bot_api_file_id = pack_bot_file_id(event.media)
36
+ await asst.send_file(
37
+ to_user,
38
+ file=bot_api_file_id,
39
+ caption=event.text,
40
+ reply_to=x.reply_to_msg_id,
41
+ )
42
+ else:
43
+ await asst.send_message(to_user, to_send, reply_to=x.reply_to_msg_id)
assistant/start.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from datetime import datetime
9
+
10
+ from pyUltroid.functions.asst_fns import *
11
+ from telethon import Button, custom, events
12
+
13
+ from plugins import *
14
+
15
+ from . import *
16
+
17
+
18
+ @asst_cmd("start")
19
+ async def assistant(event):
20
+ if event.is_group and event.sender_id in sed:
21
+ return await eor(event, "`I dont work in groups`")
22
+ else:
23
+ if not is_added(event.sender_id) and event.sender_id not in sed:
24
+ add_user(event.sender_id)
25
+ await asst.send_message(
26
+ OWNER_ID,
27
+ f"Bot started by [{event.sender_id}](tg://user?id={event.sender_id})",
28
+ )
29
+ ok = ""
30
+ if Var.MSG_FRWD is True:
31
+ ok = "You can contact me using this bot!!"
32
+ if event.is_private and event.sender_id in sed:
33
+ return
34
+ await event.reply(
35
+ f"Hey there, this is Ultroid Assistant of {OWNER_NAME}!\n\n{ok}",
36
+ buttons=[Button.url("Know More", url="https://t.me/TeamUltroid")],
37
+ )
38
+
39
+
40
+ @asst_cmd("start")
41
+ @owner
42
+ async def ultroid(event):
43
+ if event.is_group:
44
+ return
45
+ await asst.send_message(
46
+ event.chat_id,
47
+ f"Hi {OWNER_NAME}. Please browse through the options",
48
+ buttons=[
49
+ [custom.Button.inline("Settings ⚙️", data="setter")],
50
+ [custom.Button.inline("Stats", data="stat")],
51
+ [custom.Button.inline("Broadcast", data="bcast")],
52
+ ],
53
+ )
54
+
55
+
56
+ @callback("stat")
57
+ @owner
58
+ async def botstat(event):
59
+ ok = len(get_all_users())
60
+ msg = """Ultroid Assistant - Stats
61
+ Total Users - {}""".format(
62
+ ok
63
+ )
64
+ await event.answer(msg, cache_time=0, alert=True)
65
+
66
+
67
+ @callback("bcast")
68
+ @owner
69
+ async def bdcast(event):
70
+ ok = get_all_users()
71
+ await event.edit(f"Broadcast to {len(ok)} users.")
72
+ async with event.client.conversation(OWNER_ID) as conv:
73
+ await conv.send_message(
74
+ "Enter your broadcast message.\nUse /cancel to stop the broadcast."
75
+ )
76
+ response = conv.wait_event(events.NewMessage(chats=OWNER_ID))
77
+ response = await response
78
+ themssg = response.message.message
79
+ if themssg == "/cancel":
80
+ return await conv.send_message("Cancelled!!")
81
+ else:
82
+ success = 0
83
+ fail = 0
84
+ await conv.send_message(f"Starting a broadcast to {len(ok)} users...")
85
+ start = datetime.now()
86
+ for i in ok:
87
+ try:
88
+ await asst.send_message(int(i), f"{themssg}")
89
+ success += 1
90
+ except BaseException:
91
+ fail += 1
92
+ end = datetime.now()
93
+ time_taken = (end - start).seconds
94
+ await conv.send_message(
95
+ f"""
96
+ Broadcast completed in {time_taken} seconds.
97
+ Total Users in Bot - {len(ok)}
98
+ Sent to {success} users.
99
+ Failed for {fail} user(s)."""
100
+ )
101
+
102
+
103
+ @callback("setter")
104
+ @owner
105
+ async def setting(event):
106
+ await event.edit(
107
+ "Choose from the below options -",
108
+ buttons=[
109
+ [custom.Button.inline("Alive Customisation", data="alvcstm")],
110
+ [custom.Button.inline("API Keys", data="apiset")],
111
+ [custom.Button.inline("Other Vars.", data="otvars")],
112
+ ],
113
+ )
assistant/ytdl.py ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+
9
+ import asyncio
10
+ import os
11
+ import re
12
+ import time
13
+
14
+ from pyUltroid.functions.all import *
15
+ from telethon import Button
16
+ from telethon.tl.types import DocumentAttributeAudio, InputWebDocument as wb
17
+ from youtube_dl import YoutubeDL
18
+ from youtubesearchpython import VideosSearch
19
+
20
+ ytt = "https://telegra.ph/file/afd04510c13914a06dd03.jpg"
21
+
22
+
23
+ @in_pattern("yt")
24
+ @in_owner
25
+ async def _(event):
26
+ try:
27
+ string = event.text.split(" ", maxsplit=1)[1]
28
+ except IndexError:
29
+ fuk = event.builder.article(
30
+ title="Search Something",
31
+ thumb=wb(ytt, 0, "image/jpeg", []),
32
+ text="**YᴏᴜTᴜʙᴇ Sᴇᴀʀᴄʜ**\n\nYou didn't search anything",
33
+ buttons=Button.switch_inline(
34
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ",
35
+ query="yt ",
36
+ same_peer=True,
37
+ ),
38
+ )
39
+ await event.answer([fuk])
40
+ return
41
+ results = []
42
+ search = VideosSearch(string, limit=10)
43
+ nub = search.result()
44
+ nibba = nub["result"]
45
+ for v in nibba:
46
+ link = v["link"]
47
+ title = v["title"]
48
+ ids = v["id"]
49
+ duration = v["duration"]
50
+ thumb = f"https://img.youtube.com/vi/{ids}/hqdefault.jpg"
51
+ text = f"**•Tɪᴛʟᴇ•** `{title}`\n\n**••[Lɪɴᴋ]({link})••**\n\n**••Dᴜʀᴀᴛɪᴏɴ••** `{duration}`\n\n\n"
52
+ desc = f"Title : {title}\nDuration : {duration}"
53
+ results.append(
54
+ await event.builder.document(
55
+ file=thumb,
56
+ title=title,
57
+ description=desc,
58
+ text=text,
59
+ include_media=True,
60
+ buttons=[
61
+ [
62
+ Button.inline("Audio", data=f"audio{link}"),
63
+ Button.inline("Video", data=f"video{link}"),
64
+ ],
65
+ [
66
+ Button.switch_inline(
67
+ "Sᴇᴀʀᴄʜ Aɢᴀɪɴ", query="yt ", same_peer=True
68
+ ),
69
+ Button.switch_inline(
70
+ "Sʜᴀʀᴇ", query=f"yt {string}", same_peer=False
71
+ ),
72
+ ],
73
+ ],
74
+ )
75
+ )
76
+ await event.answer(results)
77
+
78
+
79
+ @callback(re.compile("audio(.*)"))
80
+ @owner
81
+ async def _(sur):
82
+ url = sur.pattern_match.group(1).decode("UTF-8")
83
+ getter = sur.sender_id
84
+ opts = {
85
+ "format": "bestaudio",
86
+ "addmetadata": True,
87
+ "key": "FFmpegMetadata",
88
+ "writethumbnail": True,
89
+ "prefer_ffmpeg": True,
90
+ "geo_bypass": True,
91
+ "nocheckcertificate": True,
92
+ "postprocessors": [
93
+ {
94
+ "key": "FFmpegExtractAudio",
95
+ "preferredcodec": "mp3",
96
+ "preferredquality": "320",
97
+ }
98
+ ],
99
+ "outtmpl": "%(id)s.mp3",
100
+ "quiet": True,
101
+ "logtostderr": False,
102
+ }
103
+ song = True
104
+ await dler(sur)
105
+ with YoutubeDL(opts) as ytdl:
106
+ ytdl_data = ytdl.extract_info(url)
107
+
108
+ jpg = f"{ytdl_data['id']}.mp3.jpg"
109
+ png = f"{ytdl_data['id']}.mp3.png"
110
+ webp = f"{ytdl_data['id']}.mp3.webp"
111
+ dir = os.listdir()
112
+
113
+ if jpg in dir:
114
+ thumb = jpg
115
+ elif png in dir:
116
+ thumb = png
117
+ elif webp in dir:
118
+ thumb = webp
119
+ else:
120
+ thumb = None
121
+
122
+ c_time = time.time()
123
+ if song:
124
+ await sur.edit(
125
+ f"`Preparing to upload song:`\
126
+ \n**{ytdl_data['title']}**\
127
+ \nby *{ytdl_data['uploader']}*"
128
+ )
129
+ await asst.send_file(
130
+ getter,
131
+ f"{ytdl_data['id']}.mp3",
132
+ thumb=thumb,
133
+ caption=f"**{ytdl_data['title']}\n{convert(ytdl_data['duration'])}\n{ytdl_data['uploader']}**",
134
+ supports_streaming=True,
135
+ attributes=[
136
+ DocumentAttributeAudio(
137
+ duration=int(ytdl_data["duration"]),
138
+ title=str(ytdl_data["title"]),
139
+ performer=str(ytdl_data["uploader"]),
140
+ )
141
+ ],
142
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
143
+ progress(d, t, sur, c_time, "Uploading..", f"{ytdl_data['title']}.mp3")
144
+ ),
145
+ )
146
+ os.system(f"rm {ytdl_data['id']}.mp*")
147
+ await sur.edit(
148
+ f"Get Your requested file **{ytdl_data['title']}** from here {Var.BOT_USERNAME} ",
149
+ buttons=Button.switch_inline("Search More", query="yt ", same_peer=True),
150
+ )
151
+
152
+
153
+ @callback(re.compile("video(.*)"))
154
+ @owner
155
+ async def _(fuk):
156
+ url = fuk.pattern_match.group(1).decode("UTF-8")
157
+ getter = fuk.sender_id
158
+ opts = {
159
+ "format": "best",
160
+ "addmetadata": True,
161
+ "key": "FFmpegMetadata",
162
+ "writethumbnail": True,
163
+ "prefer_ffmpeg": True,
164
+ "geo_bypass": True,
165
+ "nocheckcertificate": True,
166
+ "postprocessors": [{"key": "FFmpegVideoConvertor", "preferedformat": "mp4"}],
167
+ "outtmpl": "%(id)s.mp4",
168
+ "logtostderr": False,
169
+ "quiet": True,
170
+ }
171
+ video = True
172
+ await dler(fuk)
173
+ with YoutubeDL(opts) as ytdl:
174
+ ytdl_data = ytdl.extract_info(url)
175
+
176
+ c_time = time.time()
177
+ if video:
178
+ await fuk.edit(
179
+ f"`Preparing to upload video:`\
180
+ \n**{ytdl_data['title']}**\
181
+ \nby *{ytdl_data['uploader']}*"
182
+ )
183
+ await asst.send_file(
184
+ getter,
185
+ f"{ytdl_data['id']}.mp4",
186
+ thumb=f"./resources/extras/ultroid.jpg",
187
+ caption=f"**{ytdl_data['title']}\n{convert(ytdl_data['duration'])}\n{ytdl_data['uploader']}**",
188
+ supports_streaming=True,
189
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
190
+ progress(d, t, fuk, c_time, "Uploading..", f"{ytdl_data['title']}.mp4")
191
+ ),
192
+ )
193
+ os.remove(f"{ytdl_data['id']}.mp4")
194
+ await fuk.edit(
195
+ f"Get Your requested file **{ytdl_data['title']}** from here {Var.BOT_USERNAME} ",
196
+ buttons=Button.switch_inline("Search More", query="yt ", same_peer=True),
197
+ )
heroku.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ build:
2
+ docker:
3
+ worker: Dockerfile
plugins/__init__.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import time
9
+
10
+ from pyUltroid import *
11
+ from pyUltroid.dB.core import *
12
+ from pyUltroid.functions import *
13
+ from pyUltroid.functions.all import *
14
+ from pyUltroid.functions.google_image import googleimagesdownload
15
+ from pyUltroid.functions.sudos import *
16
+ from pyUltroid.utils import *
17
+
18
+ start_time = time.time()
19
+ ultroid_version = "v0.0.1"
20
+ OWNER_NAME = ultroid_bot.me.first_name
21
+ OWNER_ID = ultroid_bot.me.id
22
+ DEVLIST = [
23
+ "1259468938",
24
+ "1452145387",
25
+ "719195224",
26
+ "1318486004",
27
+ "1289422521",
28
+ "1322549723",
29
+ "611816596",
30
+ "1003250439",
31
+ "1152902819",
32
+ "716243352",
33
+ "1444249738",
34
+ "559661211",
35
+ "881536550",
36
+ "630654925",
37
+ ]
38
+
39
+ # sudo
40
+ ok = udB.get("SUDOS")
41
+ if ok:
42
+ SUDO_USERS = set(int(x) for x in ok.split())
43
+ else:
44
+ SUDO_USERS = ""
45
+
46
+ if SUDO_USERS:
47
+ sudos = list(SUDO_USERS)
48
+ else:
49
+ sudos = ""
50
+
51
+ on = Var.SUDO
52
+
53
+ if Var.SUDO:
54
+ sed = [ultroid_bot.uid, *sudos]
55
+ else:
56
+ sed = [ultroid_bot.uid]
57
+
58
+
59
+ def grt(seconds: int) -> str:
60
+ count = 0
61
+ up_time = ""
62
+ time_list = []
63
+ time_suffix_list = ["s", "m", "h", "days"]
64
+
65
+ while count < 4:
66
+ count += 1
67
+ if count < 3:
68
+ remainder, result = divmod(seconds, 60)
69
+ else:
70
+ remainder, result = divmod(seconds, 24)
71
+ if seconds == 0 and remainder == 0:
72
+ break
73
+ time_list.append(int(result))
74
+ seconds = int(remainder)
75
+
76
+ for x in range(len(time_list)):
77
+ time_list[x] = str(time_list[x]) + time_suffix_list[x]
78
+ if len(time_list) == 4:
79
+ up_time += time_list.pop() + ", "
80
+
81
+ time_list.reverse()
82
+ up_time += ":".join(time_list)
83
+
84
+ return up_time
85
+
86
+
87
+ KANGING_STR = [
88
+ "Using Witchery to kang this sticker...",
89
+ "Plagiarising hehe...",
90
+ "Inviting this sticker over to my pack...",
91
+ "Kanging this sticker...",
92
+ "Hey that's a nice sticker!\nMind if I kang?!..",
93
+ "Hehe me stel ur stiker...",
94
+ "Ay look over there (☉。☉)!→\nWhile I kang this...",
95
+ "Roses are red violets are blue, kanging this sticker so my pack looks cool",
96
+ "Imprisoning this sticker...",
97
+ "Mr.Steal-Your-Sticker is stealing this sticker... ",
98
+ ]
plugins/_help.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from pyUltroid.dB.database import Var
9
+ from support import *
10
+ from telethon.errors.rpcerrorlist import BotInlineDisabledError as dis
11
+ from telethon.errors.rpcerrorlist import BotMethodInvalidError as bmi
12
+ from telethon.errors.rpcerrorlist import BotResponseTimeoutError as rep
13
+
14
+ from . import *
15
+
16
+
17
+ @ultroid_cmd(
18
+ pattern="help ?(.*)",
19
+ )
20
+ async def ult(ult):
21
+ plug = ult.pattern_match.group(1)
22
+ tgbot = Var.BOT_USERNAME
23
+ if plug:
24
+ try:
25
+ if plug in HELP:
26
+ output = "**Plugin** - `{}`\n".format(plug)
27
+ for i in HELP[plug]:
28
+ output += i
29
+ output += "\n© @TheUltroid"
30
+ await eor(ult, output)
31
+ elif plug in CMD_HELP:
32
+ kk = f"Plugin Name-{plug}\n\n✘ Commands Available-\n\n"
33
+ kk += str(CMD_HELP[plug])
34
+ await eor(ult, kk)
35
+ else:
36
+ try:
37
+ x = f"Plugin Name-{plug}\n\n✘ Commands Available-\n\n"
38
+ for d in LIST[plug]:
39
+ x += Var.HNDLR + d
40
+ x += "\n"
41
+ await eor(ult, x)
42
+ except BaseException:
43
+ await eod(ult, f"`{plug}` is not a valid plugin!", time=5)
44
+ except BaseException:
45
+ await eor(ult, "Error 🤔 occured.")
46
+ else:
47
+ try:
48
+ results = await ultroid_bot.inline_query(tgbot, "ultd")
49
+ except rep:
50
+ return await eor(
51
+ ult,
52
+ "`The bot did not respond to the inline query.\nConsider using {}restart`".format(
53
+ Var.HNDLR
54
+ ),
55
+ )
56
+ except dis:
57
+ return await eor(
58
+ ult, "`Please turn on inline mode for your bot from` @Botfather."
59
+ )
60
+ except bmi:
61
+ return await eor(
62
+ ult,
63
+ f"Hey, \nYou are on Bot Mode. \nBot Mode Users Cant Get Help Directly ... \nInstead Copy Paste The Following in The Chat and Click The Pop Up \n\n `@{tgbot} ultd`",
64
+ )
65
+ await results[0].click(ult.chat_id, reply_to=ult.reply_to_msg_id, hide_via=True)
66
+ await ult.delete()
plugins/_inline.py ADDED
@@ -0,0 +1,503 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import os
9
+ import random
10
+ import re
11
+ import time
12
+ from datetime import datetime
13
+ from math import ceil
14
+ from platform import python_version as pyver
15
+
16
+ from git import Repo
17
+ from support import *
18
+ from telethon import Button, __version__
19
+ from telethon.tl.types import InputWebDocument
20
+
21
+ from . import *
22
+
23
+ # ================================================#
24
+ notmine = "This bot is for {}".format(OWNER_NAME)
25
+ ULTROID_PIC = "https://telegra.ph/file/11245cacbffe92e5d5b14.jpg"
26
+ helps = """
27
+ [Uʟᴛʀᴏɪᴅ Sᴜᴘᴘᴏʀᴛ](t.me/ultroidsupport)
28
+
29
+ **Hᴇʟᴘ Mᴇɴᴜ Oғ {}.
30
+
31
+ Pʟᴜɢɪɴs ~ {}**
32
+ """
33
+
34
+
35
+ if Var.ADDONS:
36
+ zhelps = """
37
+ [Uʟᴛʀᴏɪᴅ Sᴜᴘᴘᴏʀᴛ](t.me/ultroidsupport)
38
+
39
+ **Hᴇʟᴘ Mᴇɴᴜ Oғ {}.
40
+
41
+ Aᴅᴅᴏɴs ~ {}**
42
+ """
43
+ else:
44
+ zhelps = """
45
+ [Uʟᴛʀᴏɪᴅ Sᴜᴘᴘᴏʀᴛ](t.me/ultroidsupport)
46
+
47
+ **Hᴇʟᴘ Mᴇɴᴜ Oғ {}.
48
+
49
+ Aᴅᴅᴏɴs ~ {}
50
+
51
+ Gᴏ Aɴᴅ Aᴅᴅ ADDON Vᴀʀ Wɪᴛʜ Vᴀʟᴜᴇ Tʀᴜᴇ**
52
+ """
53
+ # ============================================#
54
+
55
+
56
+ @inline
57
+ @in_owner
58
+ async def e(o):
59
+ if len(o.text) == 0:
60
+ b = o.builder
61
+ uptime = grt((time.time() - start_time))
62
+ ALIVEMSG = """
63
+ **The Ultroid Userbot...**\n\n
64
+ ✵ **Owner** - `{}`
65
+ ✵ **Ultroid** - `{}`
66
+ ✵ **UpTime** - `{}`
67
+ ✵ **Python** - `{}`
68
+ ✵ **Telethon** - `{}`
69
+ ✵ **Branch** - `{}`
70
+ """.format(
71
+ OWNER_NAME,
72
+ ultroid_version,
73
+ uptime,
74
+ pyver(),
75
+ __version__,
76
+ Repo().active_branch,
77
+ )
78
+ res = [
79
+ b.article(
80
+ title="Ultroid Userbot",
81
+ url="https://t.me/TeamUltroid",
82
+ description="Userbot | Telethon ",
83
+ text=ALIVEMSG,
84
+ thumb=InputWebDocument(ULTROID_PIC, 0, "image/jpeg", []),
85
+ )
86
+ ]
87
+ await o.answer(res, switch_pm=f"👥 ULTROID PORTAL", switch_pm_param="start")
88
+
89
+
90
+ if Var.BOT_USERNAME is not None and asst is not None:
91
+
92
+ @inline
93
+ @in_owner
94
+ async def inline_handler(event):
95
+ builder = event.builder
96
+ result = None
97
+ query = event.text
98
+ if event.query.user_id in sed and query.startswith("ultd"):
99
+ result = builder.article(
100
+ title="Help Menu",
101
+ description="Help Menu - UserBot | Telethon ",
102
+ url="https://t.me/TheUltroid",
103
+ thumb=InputWebDocument(ULTROID_PIC, 0, "image/jpeg", []),
104
+ text=f"** Bᴏᴛ Oғ {OWNER_NAME}\n\nMᴀɪɴ Mᴇɴᴜ\n\nPʟᴜɢɪɴs ~ {len(PLUGINS) - 4}\nAᴅᴅᴏɴs ~ {len(ADDONS)}**",
105
+ buttons=[
106
+ [
107
+ Button.inline("• Pʟᴜɢɪɴs", data="hrrrr"),
108
+ Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
109
+ ],
110
+ [Button.inline("Oᴡɴᴇʀ•ᴛᴏᴏʟꜱ", data="ownr")],
111
+ [Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone")],
112
+ [Button.inline("••Cʟᴏꜱᴇ••", data="close")],
113
+ ],
114
+ )
115
+ await event.answer([result] if result else None)
116
+ elif event.query.user_id in sed and query.startswith("paste"):
117
+ ok = query.split("-")[1]
118
+ link = f"https://nekobin.com/{ok}"
119
+ link_raw = f"https://nekobin.com/raw/{ok}"
120
+ result = builder.article(
121
+ title="Paste",
122
+ text="Pᴀsᴛᴇᴅ Tᴏ Nᴇᴋᴏʙɪɴ!",
123
+ buttons=[
124
+ [
125
+ Button.url("NekoBin", url=f"{link}"),
126
+ Button.url("Raw", url=f"{link_raw}"),
127
+ ]
128
+ ],
129
+ )
130
+ await event.answer([result] if result else None)
131
+
132
+ @inline
133
+ @in_owner
134
+ @callback("ownr")
135
+ @owner
136
+ async def setting(event):
137
+ await event.edit(
138
+ buttons=[
139
+ [
140
+ Button.inline("•Pɪɴɢ•", data="pkng"),
141
+ Button.inline("•Uᴘᴛɪᴍᴇ•", data="upp"),
142
+ ],
143
+ [Button.inline("•Rᴇsᴛᴀʀᴛ•", data="rstrt")],
144
+ [Button.inline("<- Bᴀᴄᴋ", data="open")],
145
+ ],
146
+ )
147
+
148
+ @callback("pkng")
149
+ async def _(event):
150
+ start = datetime.now()
151
+ end = datetime.now()
152
+ ms = (end - start).microseconds / 1000
153
+ pin = f"🌋Pɪɴɢ = {ms}ms"
154
+ await event.answer(pin, cache_time=0, alert=True)
155
+
156
+ @callback("upp")
157
+ async def _(event):
158
+ uptime = grt((time.time() - start_time))
159
+ pin = f"🙋Uᴘᴛɪᴍᴇ = {uptime}"
160
+ await event.answer(pin, cache_time=0, alert=True)
161
+
162
+ @callback("inlone")
163
+ @owner
164
+ async def _(e):
165
+ button = [
166
+ [
167
+ Button.switch_inline(
168
+ "Sᴇɴᴅ Oғғɪᴄɪᴀʟ Pʟᴜɢɪɴs",
169
+ query="send all",
170
+ same_peer=True,
171
+ )
172
+ ],
173
+ [
174
+ Button.switch_inline(
175
+ "Pʟᴀʏ Sᴛᴏʀᴇ Aᴘᴘs",
176
+ query="app telegram",
177
+ same_peer=True,
178
+ )
179
+ ],
180
+ [
181
+ Button.switch_inline(
182
+ "Mᴏᴅᴅᴇᴅ Aᴘᴘs",
183
+ query="mods minecraft",
184
+ same_peer=True,
185
+ )
186
+ ],
187
+ [
188
+ Button.switch_inline(
189
+ "Sᴇᴀʀᴄʜ Oɴ Gᴏᴏɢʟᴇ",
190
+ query="go TeamUltroid",
191
+ same_peer=True,
192
+ )
193
+ ],
194
+ [
195
+ Button.switch_inline(
196
+ "Sᴇᴀʀᴄʜ Oɴ Yᴀʜᴏᴏ",
197
+ query="yahoo TeamUltroid",
198
+ same_peer=True,
199
+ )
200
+ ],
201
+ [
202
+ Button.switch_inline(
203
+ "YᴏᴜTᴜʙᴇ Dᴏᴡɴʟᴏᴀᴅᴇʀ",
204
+ query="yt How to Deploy Ultroid Userbot",
205
+ same_peer=True,
206
+ )
207
+ ],
208
+ [
209
+ Button.switch_inline(
210
+ "CʟɪᴘAʀᴛ Sᴇᴀʀᴄʜ",
211
+ query="clipart frog",
212
+ same_peer=True,
213
+ )
214
+ ],
215
+ [
216
+ Button.inline(
217
+ "<- Bᴀᴄᴋ",
218
+ data="open",
219
+ )
220
+ ],
221
+ ]
222
+ await e.edit(buttons=button, link_preview=False)
223
+
224
+ @callback("hrrrr")
225
+ @owner
226
+ async def on_plug_in_callback_query_handler(event):
227
+ xhelps = helps.format(OWNER_NAME, len(PLUGINS) - 4)
228
+ buttons = paginate_help(0, PLUGINS, "helpme")
229
+ await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
230
+
231
+ @callback("frrr")
232
+ @owner
233
+ async def addon(event):
234
+ halp = zhelps.format(OWNER_NAME, len(ADDONS))
235
+ if len(ADDONS) > 0:
236
+ buttons = paginate_addon(0, ADDONS, "addon")
237
+ await event.edit(f"{halp}", buttons=buttons, link_preview=False)
238
+ else:
239
+ await event.answer(
240
+ "• Iɴsᴛᴀʟʟ A Pʟᴜɢɪɴ Mᴀɴᴜᴀʟʟʏ Oʀ Aᴅᴅ Vᴀʀ ADDON Wɪᴛʜ Vᴀʟᴜᴇ Tʀᴜᴇ",
241
+ cache_time=0,
242
+ alert=True,
243
+ link_preview=False,
244
+ )
245
+
246
+ @callback("rstrt")
247
+ @owner
248
+ async def rrst(ult):
249
+ await restart(ult)
250
+
251
+ @callback(
252
+ re.compile(
253
+ rb"helpme_next\((.+?)\)",
254
+ ),
255
+ )
256
+ @owner
257
+ async def on_plug_in_callback_query_handler(event):
258
+ current_page_number = int(event.data_match.group(1).decode("UTF-8"))
259
+ buttons = paginate_help(current_page_number + 1, PLUGINS, "helpme")
260
+ await event.edit(buttons=buttons, link_preview=False)
261
+
262
+ @callback(
263
+ re.compile(
264
+ rb"helpme_prev\((.+?)\)",
265
+ ),
266
+ )
267
+ @owner
268
+ async def on_plug_in_callback_query_handler(event):
269
+ current_page_number = int(event.data_match.group(1).decode("UTF-8"))
270
+ buttons = paginate_help(current_page_number - 1, PLUGINS, "helpme")
271
+ await event.edit(buttons=buttons, link_preview=False)
272
+
273
+ @callback(
274
+ re.compile(
275
+ rb"addon_next\((.+?)\)",
276
+ ),
277
+ )
278
+ @owner
279
+ async def on_plug_in_callback_query_handler(event):
280
+ current_page_number = int(event.data_match.group(1).decode("UTF-8"))
281
+ buttons = paginate_addon(current_page_number + 1, ADDONS, "addon")
282
+ await event.edit(buttons=buttons, link_preview=False)
283
+
284
+ @callback(
285
+ re.compile(
286
+ rb"addon_prev\((.+?)\)",
287
+ ),
288
+ )
289
+ @owner
290
+ async def on_plug_in_callback_query_handler(event):
291
+ current_page_number = int(event.data_match.group(1).decode("UTF-8"))
292
+ buttons = paginate_addon(current_page_number - 1, ADDONS, "addon")
293
+ await event.edit(buttons=buttons, link_preview=False)
294
+
295
+ @callback("back")
296
+ @owner
297
+ async def backr(event):
298
+ xhelps = helps.format(OWNER_NAME, len(PLUGINS) - 4)
299
+ current_page_number = 0
300
+ buttons = paginate_help(current_page_number, PLUGINS, "helpme")
301
+ await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
302
+
303
+ @callback("buck")
304
+ @owner
305
+ async def backr(event):
306
+ xhelps = zhelps.format(OWNER_NAME, len(ADDONS))
307
+ current_page_number = 0
308
+ buttons = paginate_addon(current_page_number, ADDONS, "addon")
309
+ await event.edit(f"{xhelps}", buttons=buttons, link_preview=False)
310
+
311
+ @callback("open")
312
+ @owner
313
+ async def opner(event):
314
+ buttons = [
315
+ [
316
+ Button.inline("• Pʟᴜɢɪɴs ", data="hrrrr"),
317
+ Button.inline("• Aᴅᴅᴏɴs", data="frrr"),
318
+ ],
319
+ [Button.inline("Oᴡɴᴇʀ•Tᴏᴏʟꜱ", data="ownr")],
320
+ [Button.inline("Iɴʟɪɴᴇ•Pʟᴜɢɪɴs", data="inlone")],
321
+ [Button.inline("••Cʟᴏꜱᴇ••", data="close")],
322
+ ]
323
+ await event.edit(
324
+ f"** Bᴏᴛ Oғ {OWNER_NAME}\n\nMᴀɪɴ Mᴇɴᴜ\n\nOꜰꜰɪᴄɪᴀʟ Pʟᴜɢɪɴs ~ {len(PLUGINS) - 4}\nUɴᴏꜰꜰɪᴄɪᴀʟ Pʟᴜɢɪɴs ~ {len(ADDONS)}**",
325
+ buttons=buttons,
326
+ link_preview=False,
327
+ )
328
+
329
+ @callback("close")
330
+ @owner
331
+ async def on_plug_in_callback_query_handler(event):
332
+ await event.edit(
333
+ "**Mᴇɴᴜ Hᴀs Bᴇᴇɴ Cʟᴏsᴇᴅ**",
334
+ buttons=Button.inline("Oᴘᴇɴ Mᴀɪɴ Mᴇɴᴜ Aɢᴀɪɴ", data="open"),
335
+ )
336
+
337
+ @callback(
338
+ re.compile(
339
+ b"us_plugin_(.*)",
340
+ ),
341
+ )
342
+ @owner
343
+ async def on_plug_in_callback_query_handler(event):
344
+ plugin_name = event.data_match.group(1).decode("UTF-8")
345
+ help_string = f"Plugin Name - `{plugin_name}`\n"
346
+ try:
347
+ for i in HELP[plugin_name]:
348
+ help_string += i
349
+ except BaseException:
350
+ pass
351
+ if help_string == "":
352
+ reply_pop_up_alert = "{} has no detailed help...".format(plugin_name)
353
+ else:
354
+ reply_pop_up_alert = help_string
355
+ reply_pop_up_alert += "\n© @TheUltroid"
356
+ try:
357
+ if event.query.user_id in sed:
358
+ await event.edit(
359
+ reply_pop_up_alert,
360
+ buttons=[
361
+ Button.inline("<- Bᴀᴄᴋ", data="back"),
362
+ Button.inline("••Cʟᴏꜱᴇ••", data="close"),
363
+ ],
364
+ )
365
+ else:
366
+ reply_pop_up_alert = notmine
367
+ await event.answer(reply_pop_up_alert, cache_time=0)
368
+ except BaseException:
369
+ halps = "Do .help {} to get the list of commands.".format(plugin_name)
370
+ await event.edit(halps)
371
+
372
+ @callback(
373
+ re.compile(
374
+ b"add_plugin_(.*)",
375
+ ),
376
+ )
377
+ @owner
378
+ async def on_plug_in_callback_query_handler(event):
379
+ plugin_name = event.data_match.group(1).decode("UTF-8")
380
+ help_string = ""
381
+ try:
382
+ for i in HELP[plugin_name]:
383
+ help_string += i
384
+ except BaseException:
385
+ try:
386
+ for u in CMD_HELP[plugin_name]:
387
+ help_string = (
388
+ f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
389
+ )
390
+ help_string += str(CMD_HELP[plugin_name])
391
+ except BaseException:
392
+ try:
393
+ if plugin_name in LIST:
394
+ help_string = (
395
+ f"Plugin Name-{plugin_name}\n\n✘ Commands Available-\n\n"
396
+ )
397
+ for d in LIST[plugin_name]:
398
+ help_string += Var.HNDLR + d
399
+ help_string += "\n"
400
+ except BaseException:
401
+ pass
402
+ if help_string == "":
403
+ reply_pop_up_alert = "{} has no detailed help...".format(plugin_name)
404
+ else:
405
+ reply_pop_up_alert = help_string
406
+ reply_pop_up_alert += "\n© @TheUltroid"
407
+ try:
408
+ if event.query.user_id in sed:
409
+ await event.edit(
410
+ reply_pop_up_alert,
411
+ buttons=[
412
+ Button.inline("<- Bᴀᴄᴋ", data="buck"),
413
+ Button.inline("••Cʟᴏꜱᴇ••", data="close"),
414
+ ],
415
+ )
416
+ else:
417
+ reply_pop_up_alert = notmine
418
+ await event.answer(reply_pop_up_alert, cache_time=0)
419
+ except BaseException:
420
+ halps = "Do .help {} to get the list of commands.".format(plugin_name)
421
+ await event.edit(halps)
422
+
423
+
424
+ def paginate_help(page_number, loaded_plugins, prefix):
425
+ number_of_rows = 5
426
+ number_of_cols = 2
427
+ multi = os.environ.get("EMOJI_TO_DESPLAY_IN_HELP", "✘")
428
+ mult2i = os.environ.get("EMOJI2_TO_DESPLAY_IN_HELP", "✘")
429
+ helpable_plugins = []
430
+ for p in loaded_plugins:
431
+ if not p.startswith("_"):
432
+ helpable_plugins.append(p)
433
+ helpable_plugins = sorted(helpable_plugins)
434
+ modules = [
435
+ Button.inline(
436
+ "{} {} {}".format(
437
+ random.choice(list(multi)), x, random.choice(list(mult2i))
438
+ ),
439
+ data="us_plugin_{}".format(x),
440
+ )
441
+ for x in helpable_plugins
442
+ ]
443
+ pairs = list(zip(modules[::number_of_cols], modules[1::number_of_cols]))
444
+ if len(modules) % number_of_cols == 1:
445
+ pairs.append((modules[-1],))
446
+ max_num_pages = ceil(len(pairs) / number_of_rows)
447
+ modulo_page = page_number % max_num_pages
448
+ if len(pairs) > number_of_rows:
449
+ pairs = pairs[
450
+ modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
451
+ ] + [
452
+ (
453
+ Button.inline(
454
+ "<- Pʀᴇᴠɪᴏᴜs", data="{}_prev({})".format(prefix, modulo_page)
455
+ ),
456
+ Button.inline("-Bᴀᴄᴋ-", data="open"),
457
+ Button.inline(
458
+ "Nᴇxᴛ ->", data="{}_next({})".format(prefix, modulo_page)
459
+ ),
460
+ )
461
+ ]
462
+ return pairs
463
+
464
+
465
+ def paginate_addon(page_number, loaded_plugins, prefix):
466
+ number_of_rows = 5
467
+ number_of_cols = 2
468
+ multi = os.environ.get("EMOJI_TO_DESPLAY_IN_HELP", "✘")
469
+ mult2i = os.environ.get("EMOJI2_TO_DESPLAY_IN_HELP", "✘")
470
+ helpable_plugins = []
471
+ for p in loaded_plugins:
472
+ if not p.startswith("_"):
473
+ helpable_plugins.append(p)
474
+ helpable_plugins = sorted(helpable_plugins)
475
+ modules = [
476
+ Button.inline(
477
+ "{} {} {}".format(
478
+ random.choice(list(multi)), x, random.choice(list(mult2i))
479
+ ),
480
+ data="add_plugin_{}".format(x),
481
+ )
482
+ for x in helpable_plugins
483
+ ]
484
+ pairs = list(zip(modules[::number_of_cols], modules[1::number_of_cols]))
485
+ if len(modules) % number_of_cols == 1:
486
+ pairs.append((modules[-1],))
487
+ max_num_pages = ceil(len(pairs) / number_of_rows)
488
+ modulo_page = page_number % max_num_pages
489
+ if len(pairs) > number_of_rows:
490
+ pairs = pairs[
491
+ modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
492
+ ] + [
493
+ (
494
+ Button.inline(
495
+ "<- Pʀᴇᴠɪᴏᴜs", data="{}_prev({})".format(prefix, modulo_page)
496
+ ),
497
+ Button.inline("-Bᴀᴄᴋ-", data="open"),
498
+ Button.inline(
499
+ "Nᴇxᴛ ->", data="{}_next({})".format(prefix, modulo_page)
500
+ ),
501
+ )
502
+ ]
503
+ return pairs
plugins/_tagnotif.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from telethon import custom, events
9
+ from telethon.tl.types import Channel
10
+ from telethon.utils import get_display_name
11
+
12
+ from . import *
13
+
14
+
15
+ @ultroid_bot.on(
16
+ events.NewMessage(
17
+ incoming=True,
18
+ func=lambda e: (e.mentioned),
19
+ )
20
+ )
21
+ async def all_messages_catcher(event):
22
+ if udB.get("TAG_LOG") is not None:
23
+ NEEDTOLOG = int(udB.get("TAG_LOG"))
24
+ await event.forward_to(NEEDTOLOG)
25
+ ammoca_message = ""
26
+ who_ = await event.client.get_entity(event.sender_id)
27
+ if who_.bot or who_.verified or who_.support:
28
+ return
29
+ who_m = f"[{get_display_name(who_)}](tg://user?id={who_.id})"
30
+ where_ = await event.client.get_entity(event.chat_id)
31
+ where_m = get_display_name(where_)
32
+ button_text = "📨 Go to Message "
33
+ if isinstance(where_, Channel):
34
+ message_link = f"https://t.me/c/{where_.id}/{event.id}"
35
+ chat_link = f"https://t.me/c/{where_.id}"
36
+ else:
37
+ message_link = f"tg://openmessage?chat_id={where_.id}&message_id={event.id}"
38
+ chat_link = f"tg://openmessage?chat_id={where_.id}"
39
+ ammoca_message += f"{who_m} tagged you in [{where_m}]({chat_link})"
40
+ try:
41
+ await asst.send_message(
42
+ entity=NEEDTOLOG,
43
+ message=ammoca_message,
44
+ link_preview=False,
45
+ buttons=[[custom.Button.url(button_text, message_link)]],
46
+ silent=True,
47
+ )
48
+ except BaseException:
49
+ pass
50
+ else:
51
+ return
plugins/_wspr.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import re
9
+
10
+ from telethon import Button
11
+ from telethon.errors.rpcerrorlist import BotInlineDisabledError as dis
12
+ from telethon.errors.rpcerrorlist import BotResponseTimeoutError as rep
13
+ from telethon.errors.rpcerrorlist import MessageNotModifiedError as np
14
+ from telethon.tl.functions.users import GetFullUserRequest as gu
15
+ from telethon.tl.types import UserStatusEmpty as mt
16
+ from telethon.tl.types import UserStatusLastMonth as lm
17
+ from telethon.tl.types import UserStatusLastWeek as lw
18
+ from telethon.tl.types import UserStatusOffline as off
19
+ from telethon.tl.types import UserStatusOnline as on
20
+ from telethon.tl.types import UserStatusRecently as rec
21
+
22
+ snap = {}
23
+ buddhhu = []
24
+
25
+
26
+ @ultroid_cmd(
27
+ pattern="wspr ?(.*)",
28
+ )
29
+ async def _(e):
30
+ if e.reply_to_msg_id:
31
+ okk = (await e.get_reply_message()).sender_id
32
+ try:
33
+ zyx = await ultroid_bot(gu(id=okk))
34
+ put = zyx.user.username
35
+ except ValueError as ex:
36
+ return await eor(e, str(ex))
37
+ except AttributeError:
38
+ return await eor(e, "No username of replied user wad found")
39
+ else:
40
+ put = e.pattern_match.group(1)
41
+ if put:
42
+ try:
43
+ results = await ultroid_bot.inline_query(Var.BOT_USERNAME, f"msg {put}")
44
+ except rep:
45
+ return await eor(
46
+ e,
47
+ "`The bot did not respond to the inline query.\nConsider using {}restart`".format(
48
+ Var.HNDLR
49
+ ),
50
+ )
51
+ except dis:
52
+ return await eor(
53
+ e, "`Please turn on inline mode for your bot from` @Botfather."
54
+ )
55
+ await results[0].click(e.chat_id, reply_to=e.reply_to_msg_id, hide_via=True)
56
+ await e.delete()
57
+ else:
58
+ await eor(e, "Add some id or username too")
59
+
60
+
61
+ @in_pattern("msg")
62
+ async def _(e):
63
+ vvv = e.text
64
+ zzz = vvv.split(" ", maxsplit=1)
65
+ try:
66
+ ggg = zzz[1]
67
+ sed = ggg.split(" wspr ", maxsplit=1)
68
+ query = sed[0]
69
+ except IndexError:
70
+ return
71
+ meme = e.query.user_id
72
+ try:
73
+ desc = sed[1]
74
+ except IndexError:
75
+ desc = "Touch me"
76
+ if "wspr" not in vvv:
77
+ try:
78
+ logi = await ultroid_bot(gu(id=query))
79
+ name = logi.user.first_name
80
+ ids = logi.user.id
81
+ username = logi.user.username
82
+ x = logi.user.status
83
+ bio = logi.about
84
+ if isinstance(x, on):
85
+ status = "Online"
86
+ if isinstance(x, off):
87
+ status = "Offline"
88
+ if isinstance(x, rec):
89
+ status = "Last Seen Recently"
90
+ if isinstance(x, lm):
91
+ status = "Last seen months ago"
92
+ if isinstance(x, lw):
93
+ status = "Last seen weeks ago"
94
+ if isinstance(x, mt):
95
+ status = "Can't Tell"
96
+ text = f"**Name:** `{name}`\n"
97
+ text += f"**Id:** `{ids}`\n"
98
+ text += f"**Username:** `{username}`\n"
99
+ text += f"**Status:** `{status}`\n"
100
+ text += f"**About:** `{bio}`"
101
+ button = [
102
+ Button.url("Private", url=f"t.me/{username}"),
103
+ Button.switch_inline(
104
+ "Secret msg", query=f"msg {query} wspr ", same_peer=True
105
+ ),
106
+ ]
107
+ sur = e.builder.article(
108
+ title=f"{name}",
109
+ description=desc,
110
+ text=text,
111
+ buttons=button,
112
+ )
113
+ except BaseException:
114
+ name = f"User {query} Not Found\nSearch Again"
115
+ sur = e.builder.article(
116
+ title=name,
117
+ text=name,
118
+ )
119
+ else:
120
+ try:
121
+ logi = await ultroid_bot.get_entity(query)
122
+ button = [
123
+ Button.inline("Secret Msg", data=f"dd_{logi.id}"),
124
+ Button.inline("Delete Msg", data=f"del"),
125
+ ]
126
+ sur = e.builder.article(
127
+ title=f"{logi.first_name}",
128
+ description=desc,
129
+ text=f"@{logi.username} secret msg for you.\nDelete your msg after reading.\nOr the next msg will not be updated.",
130
+ buttons=button,
131
+ )
132
+ buddhhu.append(meme)
133
+ buddhhu.append(logi.id)
134
+ snap.update({logi.id: desc})
135
+ except ValueError:
136
+ sur = e.builder.article(
137
+ title="Type ur msg", text=f"You Didn't Type Your Msg"
138
+ )
139
+ await e.answer([sur])
140
+
141
+
142
+ @callback(
143
+ re.compile(
144
+ "dd_(.*)",
145
+ ),
146
+ )
147
+ async def _(e):
148
+ ids = int(e.pattern_match.group(1).decode("UTF-8"))
149
+ if e.sender_id in buddhhu:
150
+ await e.answer(snap[ids], alert=True)
151
+ else:
152
+ await e.answer("Not For You", alert=True)
153
+
154
+
155
+ @callback("del")
156
+ async def _(e):
157
+ if e.sender_id in buddhhu:
158
+ for k in buddhhu:
159
+ try:
160
+ del snap[k]
161
+ buddhhu.clear()
162
+ except KeyError:
163
+ pass
164
+ try:
165
+ await e.edit("Msg deleted")
166
+ except np:
167
+ pass
168
+ else:
169
+ await e.answer("You Can't do this", alert=True)
plugins/admintools.py ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}promote <reply to user/userid/username>`
12
+ Promote the user in the chat.
13
+
14
+ • `{i}demote <reply to user/userid/username>`
15
+ Demote the user in the chat.
16
+
17
+ • `{i}ban <reply to user/userid/username> <reason>`
18
+ Ban the user from the chat.
19
+
20
+ • `{i}unban <reply to user/userid/username> <reason>`
21
+ Unban the user from the chat.
22
+
23
+ • `{i}kick <reply to user/userid/username> <reason>`
24
+ Kick the user from the chat.
25
+
26
+ • `{i}pin <reply to message>`
27
+ Pin the message in the chat.
28
+
29
+ • `{i}unpin (all) <reply to message>`
30
+ Unpin the message(s) in the chat.
31
+
32
+ • `{i}purge <reply to message>`
33
+ Purge all messages from the replied message.
34
+
35
+ • `{i}purgeall <reply to msg/input>`
36
+ Delete all msgs of replied user.
37
+ Delete all msgs of input user
38
+
39
+ • `{i}del <reply to message>`
40
+ Delete the replied message.
41
+
42
+ • `{i}edit <new message>`
43
+ Edit your last message.
44
+ """
45
+
46
+ import asyncio
47
+
48
+ from telethon.errors import BadRequestError
49
+ from telethon.errors.rpcerrorlist import UserIdInvalidError
50
+ from telethon.tl.functions.channels import EditAdminRequest, EditBannedRequest
51
+ from telethon.tl.types import ChatAdminRights, ChatBannedRights
52
+
53
+ from . import *
54
+
55
+
56
+ @ultroid_cmd(
57
+ pattern="promote ?(.*)",
58
+ groups_only=True,
59
+ )
60
+ async def prmte(ult):
61
+ xx = await eor(ult, "`Processing...`")
62
+ chat = await ult.get_chat()
63
+ isAdmin = chat.admin_rights
64
+ isCreator = chat.creator
65
+ if not isAdmin and not isCreator:
66
+ return await xx.edit("`Hmm, I'm not an admin here...`")
67
+ await xx.edit("`Promoting...`")
68
+ user, rank = await get_user_info(ult)
69
+ if not rank:
70
+ rank = "Admin"
71
+ if not user:
72
+ return await xx.edit("`Reply to a user to promote him!`")
73
+ try:
74
+ await ultroid_bot(
75
+ EditAdminRequest(
76
+ ult.chat_id,
77
+ user.id,
78
+ ChatAdminRights(
79
+ add_admins=False,
80
+ invite_users=True,
81
+ change_info=False,
82
+ ban_users=True,
83
+ delete_messages=True,
84
+ pin_messages=True,
85
+ ),
86
+ rank,
87
+ )
88
+ )
89
+ await xx.edit(
90
+ f"[{user.first_name}](tg://user?id={user.id}) `is now an admin in {ult.chat.title} with title {rank}.`"
91
+ )
92
+ except BadRequestError:
93
+ return await xx.edit("`I don't have the right to promote you.`")
94
+ await asyncio.sleep(5)
95
+ await xx.delete()
96
+
97
+
98
+ @ultroid_cmd(
99
+ pattern="demote ?(.*)",
100
+ groups_only=True,
101
+ )
102
+ async def dmote(ult):
103
+ xx = await eor(ult, "`Processing...`")
104
+ chat = await ult.get_chat()
105
+ isAdmin = chat.admin_rights
106
+ isCreator = chat.creator
107
+ if not isAdmin and not isCreator:
108
+ return await xx.edit("`Hmm, I'm not an admin here...`")
109
+ await xx.edit("`Demoting...`")
110
+ user, rank = await get_user_info(ult)
111
+ if not rank:
112
+ rank = "Not Admin"
113
+ if not user:
114
+ return await xx.edit("`Reply to a user to demote him!`")
115
+ try:
116
+ await ultroid_bot(
117
+ EditAdminRequest(
118
+ ult.chat_id,
119
+ user.id,
120
+ ChatAdminRights(
121
+ add_admins=None,
122
+ invite_users=None,
123
+ change_info=None,
124
+ ban_users=None,
125
+ delete_messages=None,
126
+ pin_messages=None,
127
+ ),
128
+ rank,
129
+ )
130
+ )
131
+ await xx.edit(
132
+ f"[{user.first_name}](tg://user?id={user.id}) `is no longer an admin in {ult.chat.title}`"
133
+ )
134
+ except BadRequestError:
135
+ return await xx.edit("`I don't have the right to demote you.`")
136
+ await asyncio.sleep(5)
137
+ await xx.delete()
138
+
139
+
140
+ @ultroid_cmd(
141
+ pattern="ban ?(.*)",
142
+ groups_only=True,
143
+ )
144
+ async def bban(ult):
145
+ xx = await eor(ult, "`Processing...`")
146
+ chat = await ult.get_chat()
147
+ isAdmin = chat.admin_rights
148
+ isCreator = chat.creator
149
+ if not isAdmin and not isCreator:
150
+ return await xx.edit("`Hmm, I'm not an admin here...`")
151
+ user, reason = await get_user_info(ult)
152
+ if not user:
153
+ return await xx.edit("`Reply to a user or give username to ban him!`")
154
+ await xx.edit("`Getting user info...`")
155
+ try:
156
+ await ultroid_bot(
157
+ EditBannedRequest(
158
+ ult.chat_id,
159
+ user.id,
160
+ ChatBannedRights(
161
+ until_date=None,
162
+ view_messages=True,
163
+ send_messages=True,
164
+ send_media=True,
165
+ send_stickers=True,
166
+ send_gifs=True,
167
+ send_games=True,
168
+ send_inline=True,
169
+ embed_links=True,
170
+ ),
171
+ )
172
+ )
173
+ except BadRequestError:
174
+ return await xx.edit("`I don't have the right to ban a user.`")
175
+ except UserIdInvalidError:
176
+ await xx.edit("`I couldn't get who he is!`")
177
+ try:
178
+ reply = await ult.get_reply_message()
179
+ if reply:
180
+ await reply.delete()
181
+ except BadRequestError:
182
+ return await xx.edit(
183
+ f"[{user.first_name}](tg://user?id={user.id}) **was banned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`\n**Reason**: `{reason}`\n**Messages Deleted**: `False`"
184
+ )
185
+ if reason:
186
+ await xx.edit(
187
+ f"[{user.first_name}](tg://user?id={user.id}) **was banned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`\n**Reason**: `{reason}`"
188
+ )
189
+ else:
190
+ await xx.edit(
191
+ f"[{user.first_name}](tg://user?id={user.id}) **was banned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`"
192
+ )
193
+
194
+
195
+ @ultroid_cmd(
196
+ pattern="unban ?(.*)",
197
+ groups_only=True,
198
+ )
199
+ async def uunban(ult):
200
+ xx = await eor(ult, "`Processing...`")
201
+ chat = await ult.get_chat()
202
+ isAdmin = chat.admin_rights
203
+ isCreator = chat.creator
204
+ if not isAdmin and not isCreator:
205
+ return await xx.edit("`Hmm, I'm not an admin here...`")
206
+ user, reason = await get_user_info(ult)
207
+ if not user:
208
+ return await xx.edit("`Reply to a user or give username to unban him!`")
209
+ await xx.edit("`Getting user info...`")
210
+ try:
211
+ await ultroid_bot(
212
+ EditBannedRequest(
213
+ ult.chat_id,
214
+ user.id,
215
+ ChatBannedRights(
216
+ until_date=None,
217
+ view_messages=None,
218
+ send_messages=None,
219
+ send_media=None,
220
+ send_stickers=None,
221
+ send_gifs=None,
222
+ send_games=None,
223
+ send_inline=None,
224
+ embed_links=None,
225
+ ),
226
+ )
227
+ )
228
+ except BadRequestError:
229
+ return await xx.edit("`I don't have the right to unban a user.`")
230
+ except UserIdInvalidError:
231
+ await xx.edit("`I couldn't get who he is!`")
232
+ if reason:
233
+ await xx.edit(
234
+ f"[{user.first_name}](tg://user?id={user.id}) **was unbanned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`\n**Reason**: `{reason}`"
235
+ )
236
+ else:
237
+ await xx.edit(
238
+ f"[{user.first_name}](tg://user?id={user.id}) **was unbanned by** [{OWNER_NAME}](tg://user?id={OWNER_ID}) **in** `{ult.chat.title}`"
239
+ )
240
+
241
+
242
+ @ultroid_cmd(
243
+ pattern="kick ?(.*)",
244
+ groups_only=True,
245
+ )
246
+ async def kck(ult):
247
+ xx = await eor(ult, "`Processing...`")
248
+ chat = await ult.get_chat()
249
+ isAdmin = chat.admin_rights
250
+ isCreator = chat.creator
251
+ if not isAdmin and not isCreator:
252
+ return await xx.edit("`Hmm, I'm not an admin here...`")
253
+ user, reason = await get_user_info(ult)
254
+ if not user:
255
+ return await xx.edit("`Kick? Whom? I couldn't get his info...`")
256
+ await xx.edit("`Kicking...`")
257
+ try:
258
+ await ultroid_bot.kick_participant(ult.chat_id, user.id)
259
+ await asyncio.sleep(0.5)
260
+ except BadRequestError:
261
+ return await xx.edit("`I don't have the right to kick a user.`")
262
+ except Exception as e:
263
+ return await xx.edit(
264
+ f"`I don't have the right to kick a user.`\n\n**ERROR**:\n`{str(e)}`"
265
+ )
266
+ if reason:
267
+ await xx.edit(
268
+ f"[{user.first_name}](tg://user?id={user.id})` was kicked by` [{OWNER_NAME}](tg://user?id={OWNER_ID}) `in {ult.chat.title}`\n**Reason**: `{reason}`"
269
+ )
270
+ else:
271
+ await xx.edit(
272
+ f"[{user.first_name}](tg://user?id={user.id})` was kicked by` [{OWNER_NAME}](tg://user?id={OWNER_ID}) `in {ult.chat.title}`"
273
+ )
274
+
275
+
276
+ @ultroid_cmd(
277
+ pattern="pin($| (.*))",
278
+ )
279
+ async def pin(msg):
280
+ x = await eor(msg, "`Processing...`")
281
+ if not msg.is_private:
282
+ # for pin(s) in private messages
283
+ await msg.get_chat()
284
+ cht = await ultroid_bot.get_entity(msg.chat_id)
285
+ xx = msg.reply_to_msg_id
286
+ if not msg.is_reply:
287
+ return await x.edit("`Reply to a message to pin it.`")
288
+ ch = msg.pattern_match.group(1)
289
+ slnt = False
290
+ if ch == "loud":
291
+ slnt = True
292
+ try:
293
+ await ultroid_bot.pin_message(msg.chat_id, xx, notify=slnt)
294
+ except BadRequestError:
295
+ return await x.edit("`Hmm, I'm have no rights here...`")
296
+ except Exception as e:
297
+ return await x.edit(f"**ERROR:**`{str(e)}`")
298
+ await x.edit(f"`Pinned` [this message](https://t.me/c/{cht.id}/{xx})!")
299
+
300
+
301
+ @ultroid_cmd(
302
+ pattern="unpin($| (.*))",
303
+ )
304
+ async def unp(ult):
305
+ xx = await eor(ult, "`Processing...`")
306
+ if not ult.is_private:
307
+ # for (un)pin(s) in private messages
308
+ await ult.get_chat()
309
+ ch = (ult.pattern_match.group(1)).strip()
310
+ msg = ult.reply_to_msg_id
311
+ if msg and not ch:
312
+ try:
313
+ await ultroid_bot.unpin_message(ult.chat_id, msg)
314
+ except BadRequestError:
315
+ return await xx.edit("`Hmm, I'm have no rights here...`")
316
+ except Exception as e:
317
+ return await xx.edit(f"**ERROR:**\n`{str(e)}`")
318
+ elif ch == "all":
319
+ try:
320
+ await ultroid_bot.unpin_message(ult.chat_id)
321
+ except BadRequestError:
322
+ return await xx.edit("`Hmm, I'm have no rights here...`")
323
+ except Exception as e:
324
+ return await xx.edit(f"**ERROR:**`{str(e)}`")
325
+ else:
326
+ return await xx.edit(f"Either reply to a message, or, use `{hndlr}unpin all`")
327
+ if not msg and ch != "all":
328
+ return await xx.edit(f"Either reply to a message, or, use `{hndlr}unpin all`")
329
+ await xx.edit("`Unpinned!`")
330
+
331
+
332
+ @ultroid_cmd(
333
+ pattern="purge$",
334
+ )
335
+ async def fastpurger(purg):
336
+ chat = await purg.get_input_chat()
337
+ msgs = []
338
+ count = 0
339
+ if not purg.reply_to_msg_id:
340
+ return await eod(purg, "`Reply to a message to purge from.`", time=10)
341
+ async for msg in ultroid_bot.iter_messages(chat, min_id=purg.reply_to_msg_id):
342
+ msgs.append(msg)
343
+ count = count + 1
344
+ msgs.append(purg.reply_to_msg_id)
345
+ if len(msgs) == 100:
346
+ await ultroid_bot.delete_messages(chat, msgs)
347
+ msgs = []
348
+
349
+ if msgs:
350
+ await ultroid_bot.delete_messages(chat, msgs)
351
+ done = await ultroid_bot.send_message(
352
+ purg.chat_id,
353
+ "__Fast purge complete!__\n**Purged** `" + str(count) + "` **messages.**",
354
+ )
355
+ await asyncio.sleep(5)
356
+ await done.delete()
357
+
358
+
359
+ @ultroid_cmd(
360
+ pattern="purgeall ?(.*)",
361
+ )
362
+ async def _(e):
363
+ input = e.pattern_match.group(1)
364
+ xx = await eor(e, "`Processing...`")
365
+ if e.reply_to_msg_id:
366
+ input = (await e.get_reply_message()).sender_id
367
+ if input:
368
+ try:
369
+ nos = 0
370
+ async for x in e.client.iter_messages(e.chat_id, from_user=input):
371
+ await e.client.delete_messages(e.chat_id, x)
372
+ nos += 1
373
+ await e.client.send_message(
374
+ e.chat_id, f"**Purged {nos} msgs of {input} from here**"
375
+ )
376
+ except ValueError:
377
+ return await eod(xx, str(er), time=5)
378
+ else:
379
+ return await eod(
380
+ xx,
381
+ "Reply to someone's msg or give their id to delete all msgs from this chat",
382
+ time=10,
383
+ )
384
+
385
+
386
+ @ultroid_cmd(
387
+ pattern="del$",
388
+ )
389
+ async def delete_it(delme):
390
+ msg_src = await delme.get_reply_message()
391
+ if delme.reply_to_msg_id:
392
+ try:
393
+ await msg_src.delete()
394
+ await delme.delete()
395
+ except BaseException:
396
+ await eod(
397
+ delme,
398
+ f"Couldn't delete the message.\n\n**ERROR:**\n`{str(e)}`",
399
+ time=10,
400
+ )
401
+
402
+
403
+ @ultroid_cmd(
404
+ pattern="edit",
405
+ )
406
+ async def editer(edit):
407
+ message = edit.text
408
+ chat = await edit.get_input_chat()
409
+ self_id = await ultroid_bot.get_peer_id("me")
410
+ string = str(message[6:])
411
+ i = 1
412
+ async for message in ultroid_bot.iter_messages(chat, self_id):
413
+ if i == 2:
414
+ await message.edit(string)
415
+ await edit.delete()
416
+ break
417
+ i = i + 1
418
+
419
+
420
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/afk.py ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}afk <optional reason>`
12
+ afk means away from keyboard,
13
+ After u active this if Someting tag or msg u then It auto Reply Him/her,
14
+ (Note : By Reply To any media U can set media afk too).
15
+
16
+ """
17
+
18
+ import asyncio
19
+ from datetime import datetime
20
+
21
+ from telethon import events
22
+ from telethon.tl import functions, types
23
+
24
+ from . import *
25
+
26
+ global USER_AFK
27
+ global afk_time
28
+ global last_afk_message
29
+ global last_afk_msg
30
+ global afk_start
31
+ global afk_end
32
+ USER_AFK = {}
33
+ afk_time = None
34
+ last_afk_message = {}
35
+ last_afk_msg = {}
36
+ afk_start = {}
37
+
38
+ LOG = Var.LOG_CHANNEL
39
+
40
+
41
+ @ultroid_bot.on(events.NewMessage(outgoing=True))
42
+ @ultroid_bot.on(events.MessageEdited(outgoing=True))
43
+ async def set_not_afk(event):
44
+ global USER_AFK
45
+ global afk_time
46
+ global last_afk_message
47
+ global afk_start
48
+ global afk_end
49
+ back_alive = datetime.now()
50
+ afk_end = back_alive.replace(microsecond=0)
51
+ if afk_start != {}:
52
+ total_afk_time = str((afk_end - afk_start))
53
+ current_message = event.message.message
54
+ if "afk" not in current_message and "yes" in USER_AFK:
55
+ try:
56
+ if pic.endswith((".tgs", ".webp")):
57
+ shite = await ultroid_bot.send_message(event.chat_id, file=pic)
58
+ shites = await ultroid_bot.send_message(
59
+ event.chat_id,
60
+ "`No Longer Afk`\n\nWas afk for~`" + total_afk_time + "`",
61
+ )
62
+ else:
63
+ shite = await ultroid_bot.send_message(
64
+ event.chat_id,
65
+ "`No Longer Afk`\n\nWas afk for~`" + total_afk_time + "`",
66
+ file=pic,
67
+ )
68
+ except BaseException:
69
+ shite = await ultroid_bot.send_message(
70
+ event.chat_id, "`No Longer Afk`\nWas afk for" + total_afk_time + "`"
71
+ )
72
+ try:
73
+ try:
74
+ if pic.endswith((".tgs", ".webp")):
75
+ await ultroid_bot.send_message(LOG, file=pic)
76
+ await ultroid_bot.send_message(
77
+ LOG,
78
+ "#AFKFALSE \nSet AFK mode to False\n"
79
+ + "Back alive!\nNo Longer afk.\n Was afk for`"
80
+ + total_afk_time
81
+ + "`",
82
+ )
83
+ else:
84
+ await ultroid_bot.send_message(
85
+ LOG,
86
+ "#AFKFALSE \nSet AFK mode to False\n"
87
+ + "Back alive!\nNo Longer afk.\n Was afk for`"
88
+ + total_afk_time
89
+ + "`",
90
+ file=pic,
91
+ )
92
+ except BaseException:
93
+ await ultroid_bot.send_message(
94
+ LOG,
95
+ "#AFKFALSE \nSet AFK mode to False\n"
96
+ + "Back alive!\nNo Longer afk.\n Was afk for`"
97
+ + total_afk_time
98
+ + "`",
99
+ )
100
+ except BaseException:
101
+ pass
102
+ await asyncio.sleep(3)
103
+ await shite.delete()
104
+ try:
105
+ await shites.delete()
106
+ except BaseException:
107
+ pass
108
+ USER_AFK = {}
109
+ afk_time = None
110
+
111
+
112
+ @ultroid_bot.on(
113
+ events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private))
114
+ )
115
+ async def on_afk(event):
116
+ if event.fwd_from:
117
+ return
118
+ global USER_AFK
119
+ global afk_time
120
+ global last_afk_message
121
+ global afk_start
122
+ global afk_end
123
+ back_alivee = datetime.now()
124
+ afk_end = back_alivee.replace(microsecond=0)
125
+ if afk_start != {}:
126
+ total_afk_time = str((afk_end - afk_start))
127
+ current_message_text = event.message.message.lower()
128
+ if "afk" in current_message_text:
129
+ return False
130
+ if USER_AFK and not (await event.get_sender()).bot:
131
+ msg = None
132
+ if reason:
133
+ message_to_reply = (
134
+ f"__Master #AFK since__ `{total_afk_time}`\n\n"
135
+ + f"__"
136
+ + f"\n\n**Reason:- **{reason}"
137
+ )
138
+ else:
139
+ message_to_reply = f"__Master #AFK since__ `{total_afk_time}`\n\n" + f"__"
140
+ try:
141
+ if pic.endswith((".tgs", ".webp")):
142
+ msg = await event.reply(file=pic)
143
+ msgs = await event.reply(message_to_reply)
144
+ else:
145
+ msg = await event.reply(message_to_reply, file=pic)
146
+ except BaseException:
147
+ msg = await event.reply(message_to_reply)
148
+ await asyncio.sleep(2.5)
149
+ if event.chat_id in last_afk_message:
150
+ await last_afk_message[event.chat_id].delete()
151
+ try:
152
+ if event.chat_id in last_afk_msg:
153
+ await last_afk_msg[event.chat_id].delete()
154
+ except BaseException:
155
+ pass
156
+ last_afk_message[event.chat_id] = msg
157
+ try:
158
+ if msgs:
159
+ last_afk_msg[event.chat_id] = msgs
160
+ except BaseException:
161
+ pass
162
+
163
+
164
+ @ultroid_cmd(pattern=r"afk ?(.*)")
165
+ async def _(event):
166
+ if event.fwd_from:
167
+ return
168
+ reply = await event.get_reply_message()
169
+ global USER_AFK
170
+ global afk_time
171
+ global last_afk_message
172
+ global last_afk_msg
173
+ global afk_start
174
+ global afk_end
175
+ global reason
176
+ global pic
177
+ USER_AFK = {}
178
+ afk_time = None
179
+ last_afk_message = {}
180
+ last_afk_msg = {}
181
+ afk_end = {}
182
+ start_1 = datetime.now()
183
+ afk_start = start_1.replace(microsecond=0)
184
+ reason = event.pattern_match.group(1)
185
+ if reply:
186
+ pic = await event.client.download_media(reply)
187
+ else:
188
+ pic = None
189
+ if not USER_AFK:
190
+ last_seen_status = await ultroid_bot(
191
+ functions.account.GetPrivacyRequest(types.InputPrivacyKeyStatusTimestamp())
192
+ )
193
+ if isinstance(last_seen_status.rules, types.PrivacyValueAllowAll):
194
+ afk_time = datetime.datetime.now()
195
+ USER_AFK = f"yes: {reason} {pic}"
196
+ if reason:
197
+ try:
198
+ if pic.endswith((".tgs", ".webp")):
199
+ await ultroid_bot.send_message(event.chat_id, file=pic)
200
+ await ultroid_bot.send_message(
201
+ event.chat_id, f"Afk __because ~ {reason}__"
202
+ )
203
+ else:
204
+ await ultroid_bot.send_message(
205
+ event.chat_id, f"Afk __because ~ {reason}__", file=pic
206
+ )
207
+ except BaseException:
208
+ await ultroid_bot.send_message(
209
+ event.chat_id, f"Afk __because ~ {reason}__"
210
+ )
211
+ else:
212
+ try:
213
+ if pic.endswith((".tgs", ".webp")):
214
+ await ultroid_bot.send_message(event.chat_id, file=pic)
215
+ await ultroid_bot.send_message(
216
+ event.chat_id, f"**I am Going afk!**"
217
+ )
218
+ else:
219
+ await ultroid_bot.send_message(
220
+ event.chat_id, f"**I am Going afk!**", file=pic
221
+ )
222
+ except BaseException:
223
+ await ultroid_bot.send_message(event.chat_id, f"**I am Going afk!**")
224
+ await event.delete()
225
+ try:
226
+ if reason and pic:
227
+ if pic.endswith((".tgs", ".webp")):
228
+ await ultroid_bot.send_message(LOG, file=pic)
229
+ await ultroid_bot.send_message(
230
+ LOG, f"AFK mode to On and Reason is {reason}"
231
+ )
232
+ else:
233
+ await ultroid_bot.send_message(
234
+ LOG, f"AFK mode to On and Reason is {reason}", file=pic
235
+ )
236
+ elif reason:
237
+ await ultroid_bot.send_message(
238
+ LOG, f"AFK mode to On and Reason is {reason}"
239
+ )
240
+ elif pic:
241
+ if pic.endswith((".tgs", ".webp")):
242
+ await ultroid_bot.send_message(LOG, file=pic)
243
+ await ultroid_bot.send_message(LOG, f"AFK mode to On")
244
+ else:
245
+ await ultroid_bot.send_message(LOG, f"AFK mode to On", file=pic)
246
+ else:
247
+ await ultroid_bot.send_message(LOG, f"AFK mode to On")
248
+ except Exception as e:
249
+ logger.warn(str(e))
250
+
251
+
252
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/bot.py ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available
10
+
11
+ • `{i}alive`
12
+ Check if your bot is working.
13
+
14
+ • `{i}ping`
15
+ Check Ultroid's response time.
16
+
17
+ • `{i}cmds`
18
+ View all plugin names.
19
+
20
+ • `{i}restart`
21
+ To restart your bot.
22
+
23
+ • `{i}logs`
24
+ Get the last 100 lines from heroku logs.
25
+
26
+ • `{i}usage`
27
+ Get app usage details.
28
+
29
+ • `{i}shutdown`
30
+ Turn off your bot.
31
+ """
32
+
33
+ import asyncio
34
+ import math
35
+ import os
36
+ import shutil
37
+ import time
38
+ from datetime import datetime as dt
39
+ from platform import python_version as pyver
40
+
41
+ import heroku3
42
+ import psutil
43
+ import requests
44
+ from git import Repo
45
+ from telethon import __version__
46
+
47
+ from . import *
48
+
49
+ HEROKU_API = None
50
+ HEROKU_APP_NAME = None
51
+
52
+ try:
53
+ if Var.HEROKU_API and Var.HEROKU_APP_NAME:
54
+ HEROKU_API = Var.HEROKU_API
55
+ HEROKU_APP_NAME = Var.HEROKU_APP_NAME
56
+ Heroku = heroku3.from_key(Var.HEROKU_API)
57
+ heroku_api = "https://api.heroku.com"
58
+ app = Heroku.app(Var.HEROKU_APP_NAME)
59
+ except BaseException:
60
+ HEROKU_API = None
61
+ HEROKU_APP_NAME = None
62
+
63
+
64
+ @ultroid_cmd(
65
+ pattern="alive$",
66
+ )
67
+ async def lol(ult):
68
+ pic = udB.get("ALIVE_PIC")
69
+ uptime = grt((time.time() - start_time))
70
+ header = udB.get("ALIVE_TEXT") if udB.get("ALIVE_TEXT") else "Hey, I am alive."
71
+ als = """
72
+ **The Ultroid Userbot...**
73
+
74
+ **{}**
75
+
76
+ ✵ **Owner** - `{}`
77
+ ✵ **Ultroid** - `{}`
78
+ ✵ **UpTime** - `{}`
79
+ ✵ **Python** - `{}`
80
+ ✵ **Telethon** - `{}`
81
+ ✵ **Branch** - `{}`
82
+ """.format(
83
+ header,
84
+ OWNER_NAME,
85
+ ultroid_version,
86
+ uptime,
87
+ pyver(),
88
+ __version__,
89
+ Repo().active_branch,
90
+ )
91
+ if pic is None:
92
+ await ult.edit(als)
93
+ elif pic is not None and "telegra" in pic:
94
+ await ult.delete()
95
+ await ult.reply(als, file=pic)
96
+ else:
97
+ await ult.delete()
98
+ await ultroid_bot.send_message(ult.chat_id, file=pic)
99
+ await ultroid_bot.send_message(ult.chat_id, als)
100
+
101
+
102
+ @ultroid_cmd(
103
+ pattern="ping$",
104
+ )
105
+ async def _(event):
106
+ start = dt.now()
107
+ x = await eor(event, "`Pong !`")
108
+ if event.fwd_from:
109
+ return
110
+ end = dt.now()
111
+ ms = (end - start).microseconds / 1000
112
+ uptime = grt((time.time() - start_time))
113
+ await x.edit(f"**Pong !!** `{ms}ms`\n**Uptime** - `{uptime}`")
114
+
115
+
116
+ @ultroid_cmd(
117
+ pattern="cmds$",
118
+ )
119
+ async def cmds(event):
120
+ await allcmds(event)
121
+
122
+
123
+ @ultroid_cmd(
124
+ pattern="restart$",
125
+ )
126
+ async def restartbt(ult):
127
+ await restart(ult)
128
+
129
+
130
+ @ultroid_cmd(
131
+ pattern="logs$",
132
+ )
133
+ async def _(ult):
134
+ xx = await eor(ult, "`Processing...`")
135
+ if HEROKU_API is None and HEROKU_APP_NAME is None:
136
+ return await xx.edit("Please set `HEROKU_APP_NAME` and `HEROKU_API` in vars.")
137
+ await xx.edit("`Downloading Logs...`")
138
+ with open("logs-ultroid.txt", "w") as log:
139
+ log.write(app.get_log())
140
+ ok = app.get_log()
141
+ message = ok
142
+ url = "https://del.dog/documents"
143
+ r = requests.post(url, data=message.encode("UTF-8")).json()
144
+ url = f"https://del.dog/{r['key']}"
145
+ await ult.client.send_file(
146
+ ult.chat_id,
147
+ "logs-ultroid.txt",
148
+ reply_to=ult.id,
149
+ caption=f"**Heroku** Ultroid Logs.\nPasted [here]({url}) too!",
150
+ )
151
+ await xx.edit("`Uploading...`")
152
+ await asyncio.sleep(1)
153
+ await xx.delete()
154
+ return os.remove("logs-ultroid.txt")
155
+
156
+
157
+ @ultroid_cmd(
158
+ pattern="usage$",
159
+ )
160
+ async def dyno_usage(dyno):
161
+ dyn = await eor(dyno, "`Processing...`")
162
+ useragent = (
163
+ "Mozilla/5.0 (Linux; Android 10; SM-G975F) "
164
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
165
+ "Chrome/80.0.3987.149 Mobile Safari/537.36"
166
+ )
167
+ user_id = Heroku.account().id
168
+ headers = {
169
+ "User-Agent": useragent,
170
+ "Authorization": f"Bearer {Var.HEROKU_API}",
171
+ "Accept": "application/vnd.heroku+json; version=3.account-quotas",
172
+ }
173
+ path = "/accounts/" + user_id + "/actions/get-quota"
174
+ r = requests.get(heroku_api + path, headers=headers)
175
+ if r.status_code != 200:
176
+ return await dyno.edit(
177
+ "`Error: something bad happened`\n\n" f">.`{r.reason}`\n"
178
+ )
179
+ result = r.json()
180
+ quota = result["account_quota"]
181
+ quota_used = result["quota_used"]
182
+ remaining_quota = quota - quota_used
183
+ percentage = math.floor(remaining_quota / quota * 100)
184
+ minutes_remaining = remaining_quota / 60
185
+ hours = math.floor(minutes_remaining / 60)
186
+ minutes = math.floor(minutes_remaining % 60)
187
+ App = result["apps"]
188
+ try:
189
+ App[0]["quota_used"]
190
+ except IndexError:
191
+ AppQuotaUsed = 0
192
+ AppPercentage = 0
193
+ else:
194
+ AppQuotaUsed = App[0]["quota_used"] / 60
195
+ AppPercentage = math.floor(App[0]["quota_used"] * 100 / quota)
196
+ AppHours = math.floor(AppQuotaUsed / 60)
197
+ AppMinutes = math.floor(AppQuotaUsed % 60)
198
+ total, used, free = shutil.disk_usage(".")
199
+ cpuUsage = psutil.cpu_percent()
200
+ memory = psutil.virtual_memory().percent
201
+ disk = psutil.disk_usage("/").percent
202
+ upload = humanbytes(psutil.net_io_counters().bytes_sent)
203
+ down = humanbytes(psutil.net_io_counters().bytes_recv)
204
+ TOTAL = humanbytes(total)
205
+ USED = humanbytes(used)
206
+ FREE = humanbytes(free)
207
+ return await eod(
208
+ dyn,
209
+ "**⚙️ Dyno Usage ⚙️**:\n\n"
210
+ + f" -> `Dyno usage for` **{Var.HEROKU_APP_NAME}**:\n"
211
+ + f" • `{AppHours}`**h** `{AppMinutes}`**m** "
212
+ + f"**|** [`{AppPercentage}`**%**]"
213
+ + "\n\n"
214
+ + " -> `Dyno hours quota remaining this month`:\n"
215
+ + f" • `{hours}`**h** `{minutes}`**m** "
216
+ + f"**|** [`{percentage}`**%**]\n\n"
217
+ + f"**Total Disk Space: {TOTAL}\n\n**"
218
+ + f"**Used: {USED} Free: {FREE}\n\n**"
219
+ + f"**📊Data Usage📊\n\nUpload: {upload}\nDown: {down}\n\n**"
220
+ + f"**CPU: {cpuUsage}%\nRAM: {memory}%\nDISK: {disk}%**",
221
+ )
222
+
223
+
224
+ @ultroid_cmd(
225
+ pattern="shutdown$",
226
+ )
227
+ async def shht(event):
228
+ await eor(event, "GoodBye {}.\n`Shutting down...`".format(OWNER_NAME))
229
+ await ultroid_bot.disconnect()
230
+
231
+
232
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/carbon.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}carbon <text/reply to msg/reply to document>`
12
+ Carbonise the text with default settings.
13
+ • `{i}rcarbon <text/reply to msg/reply to document>`
14
+ Carbonise the text, with random bg colours.
15
+ """
16
+
17
+ import os
18
+ import random
19
+
20
+ from carbonnow import Carbon
21
+
22
+ from . import *
23
+
24
+ all_col = [
25
+ "Black",
26
+ "Navy",
27
+ "DarkBlue",
28
+ "MediumBlue",
29
+ "Blue",
30
+ "DarkGreen",
31
+ "Green",
32
+ "Teal",
33
+ "DarkCyan",
34
+ "DeepSkyBlue",
35
+ "DarkTurquoise",
36
+ "MediumSpringGreen",
37
+ "Lime",
38
+ "SpringGreen",
39
+ "Aqua",
40
+ "Cyan",
41
+ "MidnightBlue",
42
+ "DodgerBlue",
43
+ "LightSeaGreen",
44
+ "ForestGreen",
45
+ "SeaGreen",
46
+ "DarkSlateGray",
47
+ "DarkSlateGrey",
48
+ "LimeGreen",
49
+ "MediumSeaGreen",
50
+ "Turquoise",
51
+ "RoyalBlue",
52
+ "SteelBlue",
53
+ "DarkSlateBlue",
54
+ "MediumTurquoise",
55
+ "Indigo ",
56
+ "DarkOliveGreen",
57
+ "CadetBlue",
58
+ "CornflowerBlue",
59
+ "RebeccaPurple",
60
+ "MediumAquaMarine",
61
+ "DimGray",
62
+ "DimGrey",
63
+ "SlateBlue",
64
+ "OliveDrab",
65
+ "SlateGray",
66
+ "SlateGrey",
67
+ "LightSlateGray",
68
+ "LightSlateGrey",
69
+ "MediumSlateBlue",
70
+ "LawnGreen",
71
+ "Chartreuse",
72
+ "Aquamarine",
73
+ "Maroon",
74
+ "Purple",
75
+ "Olive",
76
+ "Gray",
77
+ "Grey",
78
+ "SkyBlue",
79
+ "LightSkyBlue",
80
+ "BlueViolet",
81
+ "DarkRed",
82
+ "DarkMagenta",
83
+ "SaddleBrown",
84
+ "DarkSeaGreen",
85
+ "LightGreen",
86
+ "MediumPurple",
87
+ "DarkViolet",
88
+ "PaleGreen",
89
+ "DarkOrchid",
90
+ "YellowGreen",
91
+ "Sienna",
92
+ "Brown",
93
+ "DarkGray",
94
+ "DarkGrey",
95
+ "LightBlue",
96
+ "GreenYellow",
97
+ "PaleTurquoise",
98
+ "LightSteelBlue",
99
+ "PowderBlue",
100
+ "FireBrick",
101
+ "DarkGoldenRod",
102
+ "MediumOrchid",
103
+ "RosyBrown",
104
+ "DarkKhaki",
105
+ "Silver",
106
+ "MediumVioletRed",
107
+ "IndianRed ",
108
+ "Peru",
109
+ "Chocolate",
110
+ "Tan",
111
+ "LightGray",
112
+ "LightGrey",
113
+ "Thistle",
114
+ "Orchid",
115
+ "GoldenRod",
116
+ "PaleVioletRed",
117
+ "Crimson",
118
+ "Gainsboro",
119
+ "Plum",
120
+ "BurlyWood",
121
+ "LightCyan",
122
+ "Lavender",
123
+ "DarkSalmon",
124
+ "Violet",
125
+ "PaleGoldenRod",
126
+ "LightCoral",
127
+ "Khaki",
128
+ "AliceBlue",
129
+ "HoneyDew",
130
+ "Azure",
131
+ "SandyBrown",
132
+ "Wheat",
133
+ "Beige",
134
+ "WhiteSmoke",
135
+ "MintCream",
136
+ "GhostWhite",
137
+ "Salmon",
138
+ "AntiqueWhite",
139
+ "Linen",
140
+ "LightGoldenRodYellow",
141
+ "OldLace",
142
+ "Red",
143
+ "Fuchsia",
144
+ "Magenta",
145
+ "DeepPink",
146
+ "OrangeRed",
147
+ "Tomato",
148
+ "HotPink",
149
+ "Coral",
150
+ "DarkOrange",
151
+ "LightSalmon",
152
+ "Orange",
153
+ "LightPink",
154
+ "Pink",
155
+ "Gold",
156
+ "PeachPuff",
157
+ "NavajoWhite",
158
+ "Moccasin",
159
+ "Bisque",
160
+ "MistyRose",
161
+ "BlanchedAlmond",
162
+ "PapayaWhip",
163
+ "LavenderBlush",
164
+ "SeaShell",
165
+ "Cornsilk",
166
+ "LemonChiffon",
167
+ "FloralWhite",
168
+ "Snow",
169
+ "Yellow",
170
+ "LightYellow",
171
+ "Ivory",
172
+ "White",
173
+ ]
174
+
175
+
176
+ @ultroid_cmd(
177
+ pattern="carbon",
178
+ )
179
+ async def crbn(event):
180
+ xxxx = await eor(event, "Processing")
181
+ if event.reply_to_msg_id:
182
+ temp = await event.get_reply_message()
183
+ if temp.media:
184
+ b = await ultroid_bot.download_media(temp)
185
+ a = open(b, "r")
186
+ code = a.read()
187
+ a.close()
188
+ os.remove(b)
189
+ else:
190
+ code = temp.message
191
+ else:
192
+ code = event.text.split(" ", maxsplit=1)[1]
193
+ carbon = Carbon(code=code)
194
+ xx = await carbon.save("ultroid_carbon")
195
+ await xxxx.delete()
196
+ await ultroid_bot.send_file(
197
+ event.chat_id,
198
+ xx,
199
+ caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
200
+ force_document=True,
201
+ )
202
+ os.remove(xx)
203
+
204
+
205
+ @ultroid_cmd(
206
+ pattern="rcarbon",
207
+ )
208
+ async def crbn(event):
209
+ xxxx = await eor(event, "Processing")
210
+ if event.reply_to_msg_id:
211
+ temp = await event.get_reply_message()
212
+ if temp.media:
213
+ b = await ultroid_bot.download_media(temp)
214
+ a = open(b, "r")
215
+ code = a.read()
216
+ a.close()
217
+ os.remove(b)
218
+ else:
219
+ code = temp.message
220
+ else:
221
+ code = event.text.split(" ", maxsplit=1)[1]
222
+ col = random.choice(all_col)
223
+ carbon = Carbon(code=code, background=col)
224
+ xx = await carbon.save("ultroid_carbon")
225
+ await xxxx.delete()
226
+ await ultroid_bot.send_file(
227
+ event.chat_id,
228
+ xx,
229
+ caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})",
230
+ force_document=True,
231
+ )
232
+ os.remove(xx)
233
+
234
+
235
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/chats.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}delchat`
12
+ Delete the group this cmd is used in.
13
+
14
+ • `{i}getlink`
15
+ Get link of group this cmd is used in.
16
+
17
+ • `{i}create (b|g|c) <group_name>`
18
+ Create group woth a specific name.
19
+ b - megagroup/supergroup
20
+ g - small group
21
+ c - channel
22
+ """
23
+
24
+
25
+ from telethon.errors import ChatAdminRequiredError as no_admin
26
+ from telethon.tl import functions
27
+
28
+ from . import *
29
+
30
+
31
+ @ultroid_cmd(
32
+ pattern="delchat$",
33
+ groups_only=True,
34
+ )
35
+ async def _(e):
36
+ xx = await eor(e, "`Processing...`")
37
+ try:
38
+ await e.client(functions.channels.DeleteChannelRequest(e.chat_id))
39
+ except TypeError:
40
+ return await eod(xx, "`Cant delete this chat`", time=10)
41
+ except no_admin:
42
+ return await eod(xx, "`I m not an admin`", time=10)
43
+ await e.client.send_message(Var.LOG_CHANNEL, f"#Deleted\nDeleted {e.chat_id}")
44
+
45
+
46
+ @ultroid_cmd(
47
+ pattern="getlink$",
48
+ groups_only=True,
49
+ )
50
+ async def _(e):
51
+ xx = await eor(e, "`Processing...`")
52
+ try:
53
+ r = await e.client(
54
+ functions.messages.ExportChatInviteRequest(e.chat_id),
55
+ )
56
+ except no_admin:
57
+ return await eod(xx, "`I m not an admin`", time=10)
58
+ await eod(xx, f"Link:- {r.link}")
59
+
60
+
61
+ @ultroid_cmd(
62
+ pattern="create (b|g|c)(?: |$)(.*)",
63
+ )
64
+ async def _(e):
65
+ type_of_group = e.pattern_match.group(1)
66
+ group_name = e.pattern_match.group(2)
67
+ xx = await eor(e, "`Processing...`")
68
+ if type_of_group == "b":
69
+ try:
70
+ r = await e.client(
71
+ functions.messages.CreateChatRequest(
72
+ users=["@missrose_bot"],
73
+ title=group_name,
74
+ )
75
+ )
76
+ created_chat_id = r.chats[0].id
77
+ await e.client(
78
+ functions.messages.DeleteChatUserRequest(
79
+ chat_id=created_chat_id,
80
+ user_id="@missrose_bot",
81
+ )
82
+ )
83
+ result = await e.client(
84
+ functions.messages.ExportChatInviteRequest(
85
+ peer=created_chat_id,
86
+ )
87
+ )
88
+ await xx.edit(
89
+ f"Your [{group_name}]({result.link}) Group Made Boss!",
90
+ link_preview=False,
91
+ )
92
+ except Exception as ex:
93
+ await xx.edit(str(ex))
94
+ elif type_of_group == "g" or type_of_group == "c":
95
+ try:
96
+ r = await e.client(
97
+ functions.channels.CreateChannelRequest(
98
+ title=group_name,
99
+ about="Join @TeamUltroid",
100
+ megagroup=False if type_of_group == "c" else True,
101
+ )
102
+ )
103
+ created_chat_id = r.chats[0].id
104
+ result = await e.client(
105
+ functions.messages.ExportChatInviteRequest(
106
+ peer=created_chat_id,
107
+ )
108
+ )
109
+ await xx.edit(
110
+ f"Your [{group_name}]({result.link}) Group/Channel Has been made Boss!",
111
+ link_preview=False,
112
+ )
113
+ except Exception as ex:
114
+ await xx.edit(str(ex))
115
+
116
+
117
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/core.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}install <reply to plugin>`
12
+ To install the plugin.
13
+
14
+ • `{i}uninstall <plugin name>`
15
+ To unload and remove the plugin.
16
+
17
+ • `{i}load <plugin name>`
18
+ To load unloaded unofficial plugin.
19
+
20
+ • `{i}unload <plugin name>`
21
+ To unload unofficial plugin.
22
+
23
+ • `{i}help <plugin name>`
24
+ Shows you a help menu (like this) for every plugin.
25
+ """
26
+
27
+ import os
28
+
29
+ from telethon.tl.custom import Button
30
+
31
+ from . import *
32
+
33
+
34
+ @in_pattern(
35
+ "send (.*)",
36
+ )
37
+ @in_owner
38
+ async def inline_handler(event):
39
+ builder = event.builder
40
+ input_str = event.pattern_match.group(1)
41
+ plug = [*PLUGINS]
42
+ plugs = []
43
+ if input_str == "all":
44
+ for i in plug:
45
+ try:
46
+ plugs.append(
47
+ await event.builder.document(
48
+ f"./plugins/{i}.py",
49
+ title=f"{i}.py",
50
+ description=f"Module Found",
51
+ text=f"{i}.py use .paste to paste in neko and raw..",
52
+ buttons=[
53
+ [
54
+ Button.switch_inline(
55
+ "Search Again..?", query="send all", same_peer=True
56
+ )
57
+ ]
58
+ ],
59
+ )
60
+ )
61
+ except BaseException:
62
+ pass
63
+ await event.answer(plugs)
64
+ else:
65
+ try:
66
+ ultroid = builder.document(
67
+ f"./plugins/{input_str}.py",
68
+ title=f"{input_str}.py",
69
+ description=f"Module {input_str} Found",
70
+ text=f"{input_str}.py use .paste to paste in neko and raw..",
71
+ buttons=[
72
+ [
73
+ Button.switch_inline(
74
+ "Search Again..?", query="send ", same_peer=True
75
+ )
76
+ ]
77
+ ],
78
+ )
79
+ await event.answer([ultroid])
80
+ return
81
+ except BaseException:
82
+ ultroidcode = builder.article(
83
+ title=f"Module {input_str}.py Not Found",
84
+ description=f"No Such Module",
85
+ text=f"No Module Named {input_str}.py",
86
+ buttons=[
87
+ [
88
+ Button.switch_inline(
89
+ "Search Again", query="send ", same_peer=True
90
+ )
91
+ ]
92
+ ],
93
+ )
94
+ await event.answer([ultroidcode])
95
+ return
96
+
97
+
98
+ @ultroid_cmd(
99
+ pattern="install$",
100
+ )
101
+ async def install(event):
102
+ await safeinstall(event)
103
+
104
+
105
+ @ultroid_cmd(
106
+ pattern=r"unload (?P<shortname>\w+)$",
107
+ )
108
+ async def unload(event):
109
+ shortname = event.pattern_match["shortname"]
110
+ if not shortname:
111
+ await eor(event, "`Give name of plugin which u want to unload`")
112
+ return
113
+ lsd = os.listdir("addons")
114
+ lst = os.listdir("plugins")
115
+ zym = shortname + ".py"
116
+ if zym in lsd:
117
+ try:
118
+ un_plug(shortname)
119
+ await eod(event, f"**Uɴʟᴏᴀᴅᴇᴅ** `{shortname}` **Sᴜᴄᴄᴇssғᴜʟʟʏ.**", time=3)
120
+ except BaseException:
121
+ pass
122
+ elif zym in lst:
123
+ return await eod(event, "**Yᴏᴜ Cᴀɴ'ᴛ Uɴʟᴏᴀᴅ Oғғɪᴄɪᴀʟ Pʟᴜɢɪɴs**", time=3)
124
+ else:
125
+ return await eod(event, f"**Nᴏ Pʟᴜɢɪɴ Nᴀᴍᴇᴅ** `{shortname}`", time=3)
126
+
127
+
128
+ @ultroid_cmd(
129
+ pattern=r"uninstall (?P<shortname>\w+)$",
130
+ )
131
+ async def uninstall(event):
132
+ shortname = event.pattern_match["shortname"]
133
+ if not shortname:
134
+ await eor(event, "`Give name of plugin which u want to uninstall`")
135
+ return
136
+ lsd = os.listdir("addons")
137
+ lst = os.listdir("plugins")
138
+ zym = shortname + ".py"
139
+ if zym in lsd:
140
+ try:
141
+ un_plug(shortname)
142
+ await eod(event, f"**Uɴɪɴsᴛᴀʟʟᴇᴅ** `{shortname}` **Sᴜᴄᴄᴇssғᴜʟʟʏ.**", time=3)
143
+ os.remove(f"addons/{shortname}.py")
144
+ except BaseException:
145
+ pass
146
+ elif zym in lst:
147
+ return await eod(event, "**Yᴏᴜ Cᴀɴ'ᴛ Uɴɪɴsᴛᴀʟʟ Oғғɪᴄɪᴀʟ Pʟᴜɢɪɴs**", time=3)
148
+ else:
149
+ return await eod(event, f"**Nᴏ Pʟᴜɢɪɴ Nᴀᴍᴇᴅ** `{shortname}`", time=3)
150
+
151
+
152
+ @ultroid_cmd(
153
+ pattern=r"load (?P<shortname>\w+)$",
154
+ )
155
+ async def load(event):
156
+ shortname = event.pattern_match["shortname"]
157
+ if not shortname:
158
+ await eor(event, "`Give name of plugin which u want to load`")
159
+ return
160
+ try:
161
+ try:
162
+ un_plug(shortname)
163
+ except BaseException:
164
+ pass
165
+ load_addons(shortname)
166
+ await eod(event, f"**Sᴜᴄᴄᴇssғᴜʟʟʏ Lᴏᴀᴅᴇᴅ** `{shortname}`", time=3)
167
+ except Exception as e:
168
+ await eod(
169
+ event,
170
+ f"**Could not load** `{shortname}` **because of the following error.**\n`{str(e)}`",
171
+ time=3,
172
+ )
173
+
174
+
175
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/github.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}github <username>`
12
+ Get full information of the users github profile.
13
+ """
14
+
15
+
16
+ import requests
17
+
18
+ from . import *
19
+
20
+
21
+ @ultroid_cmd(
22
+ pattern="github (.*)",
23
+ )
24
+ async def gitsearch(event):
25
+ xx = await eor(event, "`Searching...`")
26
+ try:
27
+ usrname = event.pattern_match.group(1)
28
+ except BaseException:
29
+ return await xx.edit("`Search for whom? Give me a user name!!`")
30
+ url = f"https://api.github.com/users/{usrname}"
31
+ ult = requests.get(url).json()
32
+ try:
33
+ uname = ult["login"]
34
+ uid = ult["id"]
35
+ upic = ult["avatar_url"]
36
+ ulink = ult["html_url"]
37
+ uacc = ult["name"]
38
+ ucomp = ult["company"]
39
+ ublog = ult["blog"]
40
+ ulocation = ult["location"]
41
+ ubio = ult["bio"]
42
+ urepos = ult["public_repos"]
43
+ ufollowers = ult["followers"]
44
+ ufollowing = ult["following"]
45
+ except BaseException:
46
+ return await xx.edit("`No such user found...`")
47
+ fullusr = f"""
48
+ **[GITHUB]({ulink})**
49
+
50
+ **Name** - {uacc}
51
+ **UserName** - {uname}
52
+ **ID** - {uid}
53
+ **Company** - {ucomp}
54
+ **Blog** - {ublog}
55
+ **Location** - {ulocation}
56
+ **Bio** - {ubio}
57
+ **Repos** - {urepos}
58
+ **Followers** - {ufollowers}
59
+ **Following** - {ufollowing}
60
+ """
61
+ await xx.delete()
62
+ await ultroid_bot.send_file(
63
+ event.chat_id,
64
+ upic,
65
+ caption=fullusr,
66
+ link_preview=False,
67
+ )
68
+
69
+
70
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/google.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}google <query>`
12
+ For doing google search.
13
+
14
+ • `{i}img <query>`
15
+ For doing Images search.
16
+
17
+ • `{i}reverse <query>`
18
+ Reply an Image or sticker to find its sauce.
19
+ """
20
+
21
+ import os
22
+ from shutil import rmtree
23
+
24
+ import requests
25
+ from bs4 import BeautifulSoup as bs
26
+ from PIL import Image
27
+ from search_engine_parser import *
28
+
29
+ from . import *
30
+
31
+
32
+ @ultroid_cmd(pattern="google ?(.*)")
33
+ async def google(event):
34
+ inp = event.pattern_match.group(1)
35
+ if not inp:
36
+ return await event.edit("Give something to search")
37
+ x = await eor(event, "`searching..`")
38
+ gs = GoogleSearch()
39
+ res = await gs.async_search(f"{inp}")
40
+ out = ""
41
+ for i in range(len(res["links"])):
42
+ text = res["titles"][i]
43
+ url = res["links"][i]
44
+ des = res["descriptions"][i]
45
+ out += f" 👉🏻 [{text}]({url})\n`{des}`\n\n"
46
+ await x.edit(
47
+ f"**Google Search Query:**\n`{inp}`\n\n**Results:**\n{out}", link_preview=False
48
+ )
49
+
50
+
51
+ @ultroid_cmd(pattern="img ?(.*)")
52
+ async def goimg(event):
53
+ query = event.pattern_match.group(1)
54
+ if not query:
55
+ return await eor(event, "`Give something to search")
56
+ nn = await eor(event, "`Processing Keep Patience...`")
57
+ if ";" in query:
58
+ try:
59
+ lmt = int(query.split(";")[1])
60
+ except BaseExceptaion:
61
+ lmt = 5
62
+ else:
63
+ lmt = 5
64
+ gi = googleimagesdownload()
65
+ args = {
66
+ "keywords": query,
67
+ "limit": lmt,
68
+ "format": "jpg",
69
+ "output_directory": "./resources/downloads/",
70
+ }
71
+ pth = gi.download(args)
72
+ ok = pth[0][query]
73
+ await event.client.send_file(event.chat_id, ok, album=True)
74
+ rmtree(f"./resources/downloads/{query}/")
75
+ await nn.delete()
76
+
77
+
78
+ @ultroid_cmd(pattern="reverse")
79
+ async def reverse(event):
80
+ reply = await event.get_reply_message()
81
+ if not reply:
82
+ return await eor(event, "`Reply to any Image`")
83
+ ult = await eor(event, "`Processing...`")
84
+ dl = await bot.download_media(reply)
85
+ img = Image.open(dl)
86
+ x, y = img.size
87
+ file = {"encoded_image": (dl, open(dl, "rb"))}
88
+ grs = requests.post(
89
+ "https://www.google.com/searchbyimage/upload", files=file, allow_redirects=False
90
+ )
91
+ loc = grs.headers.get("Location")
92
+ response = requests.get(
93
+ loc,
94
+ headers={
95
+ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0"
96
+ },
97
+ )
98
+ xx = bs(response.text, "html.parser")
99
+ div = xx.find("div", {"class": "r5a77d"})
100
+ alls = div.find("a")
101
+ link = alls["href"]
102
+ text = alls.text
103
+ await ult.edit(f"`Dimension ~ {x} : {y}`\nSauce ~ [{text}](google.com{link})")
104
+ gi = googleimagesdownload()
105
+ args = {
106
+ "keywords": text,
107
+ "limit": 2,
108
+ "format": "jpg",
109
+ "output_directory": "./resources/downloads/",
110
+ }
111
+ pth = gi.download(args)
112
+ ok = pth[0][text]
113
+ await event.client.send_file(
114
+ event.chat_id, ok, album=True, caption="Similar Images Realted to Search"
115
+ )
116
+ rmtree(f"./resources/downloads/{text}/")
117
+ os.remove(dl)
118
+
119
+
120
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/imagetools.py ADDED
@@ -0,0 +1,468 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}toon <reply to any media>`
12
+ To make it toon.
13
+
14
+ • `{i}danger <reply to any media>`
15
+ To make it look Danger.
16
+
17
+ • `{i}grey <reply to any media>`
18
+ To make it black nd white.
19
+
20
+ • `{i}negative <reply to any media>`
21
+ To make negative image.
22
+
23
+ • `{i}blur <reply to any media>`
24
+ To make it blurry.
25
+
26
+ • `{i}quad <reply to any media>`
27
+ create a Vortex.
28
+
29
+ • `{i}mirror <reply to any media>`
30
+ To create mirror pic.
31
+
32
+ • `{i}flip <reply to any media>`
33
+ To make it flip.
34
+
35
+ • `{i}sketch <reply to any media>`
36
+ To draw its sketch.
37
+
38
+ • `{i}blue <reply to any media>`
39
+ just cool.
40
+ """
41
+
42
+ import asyncio
43
+ import os
44
+
45
+ import cv2
46
+ import numpy as np
47
+ from PIL import Image
48
+ from telegraph import upload_file as upf
49
+ from validators.url import url
50
+
51
+ from . import *
52
+
53
+
54
+ @ultroid_cmd(
55
+ pattern="sketch$",
56
+ )
57
+ async def sketch(e):
58
+ ureply = await e.get_reply_message()
59
+ xx = await eor(e, "`...`")
60
+ if not (ureply and (ureply.media)):
61
+ await xx.edit("`Reply to any media`")
62
+ return
63
+ ultt = await ureply.download_media()
64
+ if ultt.endswith(".tgs"):
65
+ await xx.edit("`Ooo Animated Sticker 👀...`")
66
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
67
+ file = "ult.png"
68
+ process = await asyncio.create_subprocess_exec(
69
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
70
+ )
71
+ stdout, stderr = await process.communicate()
72
+ stderr.decode().strip()
73
+ stdout.decode().strip()
74
+ else:
75
+ await xx.edit("`Processing...`")
76
+ img = cv2.VideoCapture(ultt)
77
+ heh, lol = img.read()
78
+ cv2.imwrite("ult.png", lol)
79
+ file = "ult.png"
80
+ img = cv2.imread(file)
81
+ gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
82
+ inverted_gray_image = 255 - gray_image
83
+ blurred_img = cv2.GaussianBlur(inverted_gray_image, (21, 21), 0)
84
+ inverted_blurred_img = 255 - blurred_img
85
+ pencil_sketch_IMG = cv2.divide(gray_image, inverted_blurred_img, scale=256.0)
86
+ cv2.imwrite("ultroid.png", pencil_sketch_IMG)
87
+ await e.client.send_file(e.chat_id, file="ultroid.png")
88
+ await xx.delete()
89
+ os.remove(file)
90
+ os.remove("ultroid.png")
91
+
92
+
93
+ @ultroid_cmd(
94
+ pattern="grey$",
95
+ )
96
+ async def ultd(event):
97
+ ureply = await event.get_reply_message()
98
+ if not (ureply and (ureply.media)):
99
+ await eor(event, "`Reply to any media`")
100
+ return
101
+ ultt = await ureply.download_media()
102
+ if ultt.endswith(".tgs"):
103
+ xx = await eor(event, "`Ooo Animated Sticker 👀...`")
104
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
105
+ file = "ult.png"
106
+ process = await asyncio.create_subprocess_exec(
107
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
108
+ )
109
+ stdout, stderr = await process.communicate()
110
+ stderr.decode().strip()
111
+ stdout.decode().strip()
112
+ else:
113
+ xx = await eor(event, "`Processing...`")
114
+ img = cv2.VideoCapture(ultt)
115
+ heh, lol = img.read()
116
+ cv2.imwrite("ult.png", lol)
117
+ file = "ult.png"
118
+ ult = cv2.imread(file)
119
+ ultroid = cv2.cvtColor(ult, cv2.COLOR_BGR2GRAY)
120
+ cv2.imwrite("ult.jpg", ultroid)
121
+ await event.client.send_file(
122
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
123
+ )
124
+ await xx.delete()
125
+ os.remove("ult.png")
126
+ os.remove("ult.jpg")
127
+ os.remove(ultt)
128
+
129
+
130
+ @ultroid_cmd(
131
+ pattern="blur$",
132
+ )
133
+ async def ultd(event):
134
+ ureply = await event.get_reply_message()
135
+ if not (ureply and (ureply.media)):
136
+ await eor(event, "`Reply to any media`")
137
+ return
138
+ ultt = await ureply.download_media()
139
+ if ultt.endswith(".tgs"):
140
+ xx = await eor(event, "`Ooo Animated Sticker 👀...`")
141
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
142
+ file = "ult.png"
143
+ process = await asyncio.create_subprocess_exec(
144
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
145
+ )
146
+ stdout, stderr = await process.communicate()
147
+ stderr.decode().strip()
148
+ stdout.decode().strip()
149
+ else:
150
+ xx = await eor(event, "`Processing...`")
151
+ img = cv2.VideoCapture(ultt)
152
+ heh, lol = img.read()
153
+ cv2.imwrite("ult.png", lol)
154
+ file = "ult.png"
155
+ ult = cv2.imread(file)
156
+ ultroid = cv2.GaussianBlur(ult, (35, 35), 0)
157
+ cv2.imwrite("ult.jpg", ultroid)
158
+ await event.client.send_file(
159
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
160
+ )
161
+ await xx.delete()
162
+ os.remove("ult.png")
163
+ os.remove("ult.jpg")
164
+ os.remove(ultt)
165
+
166
+
167
+ @ultroid_cmd(
168
+ pattern="negative$",
169
+ )
170
+ async def ultd(event):
171
+ ureply = await event.get_reply_message()
172
+ xx = await eor(event, "`...`")
173
+ if not (ureply and (ureply.media)):
174
+ await xx.edit("`Reply to any media`")
175
+ return
176
+ ultt = await ureply.download_media()
177
+ if ultt.endswith(".tgs"):
178
+ await xx.edit("`Ooo Animated Sticker 👀...`")
179
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
180
+ file = "ult.png"
181
+ process = await asyncio.create_subprocess_exec(
182
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
183
+ )
184
+ stdout, stderr = await process.communicate()
185
+ stderr.decode().strip()
186
+ stdout.decode().strip()
187
+ else:
188
+ await xx.edit("`Processing...`")
189
+ img = cv2.VideoCapture(ultt)
190
+ heh, lol = img.read()
191
+ cv2.imwrite("ult.png", lol)
192
+ file = "ult.png"
193
+ ult = cv2.imread(file)
194
+ ultroid = cv2.bitwise_not(ult)
195
+ cv2.imwrite("ult.jpg", ultroid)
196
+ await event.client.send_file(
197
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
198
+ )
199
+ await xx.delete()
200
+ os.remove("ult.png")
201
+ os.remove("ult.jpg")
202
+ os.remove(ultt)
203
+
204
+
205
+ @ultroid_cmd(
206
+ pattern="mirror$",
207
+ )
208
+ async def ultd(event):
209
+ ureply = await event.get_reply_message()
210
+ xx = await eor(event, "`...`")
211
+ if not (ureply and (ureply.media)):
212
+ await xx.edit("`Reply to any media`")
213
+ return
214
+ ultt = await ureply.download_media()
215
+ if ultt.endswith(".tgs"):
216
+ await xx.edit("`Ooo Animated Sticker 👀...`")
217
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
218
+ file = "ult.png"
219
+ process = await asyncio.create_subprocess_exec(
220
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
221
+ )
222
+ stdout, stderr = await process.communicate()
223
+ stderr.decode().strip()
224
+ stdout.decode().strip()
225
+ else:
226
+ await xx.edit("`Processing...`")
227
+ img = cv2.VideoCapture(ultt)
228
+ heh, lol = img.read()
229
+ cv2.imwrite("ult.png", lol)
230
+ file = "ult.png"
231
+ ult = cv2.imread(file)
232
+ ish = cv2.flip(ult, 1)
233
+ ultroid = cv2.hconcat([ult, ish])
234
+ cv2.imwrite("ult.jpg", ultroid)
235
+ await event.client.send_file(
236
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
237
+ )
238
+ await xx.delete()
239
+ os.remove("ult.png")
240
+ os.remove("ult.jpg")
241
+ os.remove(ultt)
242
+
243
+
244
+ @ultroid_cmd(
245
+ pattern="flip$",
246
+ )
247
+ async def ultd(event):
248
+ ureply = await event.get_reply_message()
249
+ xx = await eor(event, "`...`")
250
+ if not (ureply and (ureply.media)):
251
+ await xx.edit("`Reply to any media`")
252
+ return
253
+ ultt = await ureply.download_media()
254
+ if ultt.endswith(".tgs"):
255
+ await xx.edit("`Ooo Animated Sticker 👀...`")
256
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
257
+ file = "ult.png"
258
+ process = await asyncio.create_subprocess_exec(
259
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
260
+ )
261
+ stdout, stderr = await process.communicate()
262
+ stderr.decode().strip()
263
+ stdout.decode().strip()
264
+ else:
265
+ await xx.edit("`Processing...`")
266
+ img = cv2.VideoCapture(ultt)
267
+ heh, lol = img.read()
268
+ cv2.imwrite("ult.png", lol)
269
+ file = "ult.png"
270
+ ult = cv2.imread(file)
271
+ trn = cv2.flip(ult, 1)
272
+ ish = cv2.rotate(trn, cv2.ROTATE_180)
273
+ ultroid = cv2.vconcat([ult, ish])
274
+ cv2.imwrite("ult.jpg", ultroid)
275
+ await event.client.send_file(
276
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
277
+ )
278
+ await xx.delete()
279
+ os.remove("ult.png")
280
+ os.remove("ult.jpg")
281
+ os.remove(ultt)
282
+
283
+
284
+ @ultroid_cmd(
285
+ pattern="quad$",
286
+ )
287
+ async def ultd(event):
288
+ ureply = await event.get_reply_message()
289
+ xx = await eor(event, "`...`")
290
+ if not (ureply and (ureply.media)):
291
+ await xx.edit("`Reply to any media`")
292
+ return
293
+ ultt = await ureply.download_media()
294
+ if ultt.endswith(".tgs"):
295
+ await xx.edit("`Ooo Animated Sticker 👀...`")
296
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
297
+ file = "ult.png"
298
+ process = await asyncio.create_subprocess_exec(
299
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
300
+ )
301
+ stdout, stderr = await process.communicate()
302
+ stderr.decode().strip()
303
+ stdout.decode().strip()
304
+ else:
305
+ await xx.edit("`Processing...`")
306
+ img = cv2.VideoCapture(ultt)
307
+ heh, lol = img.read()
308
+ cv2.imwrite("ult.png", lol)
309
+ file = "ult.png"
310
+ ult = cv2.imread(file)
311
+ roid = cv2.flip(ult, 1)
312
+ mici = cv2.hconcat([ult, roid])
313
+ fr = cv2.flip(mici, 1)
314
+ trn = cv2.rotate(fr, cv2.ROTATE_180)
315
+ ultroid = cv2.vconcat([mici, trn])
316
+ cv2.imwrite("ult.jpg", ultroid)
317
+ await event.client.send_file(
318
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
319
+ )
320
+ await xx.delete()
321
+ os.remove("ult.png")
322
+ os.remove("ult.jpg")
323
+ os.remove(ultt)
324
+
325
+
326
+ @ultroid_cmd(
327
+ pattern="toon$",
328
+ )
329
+ async def ultd(event):
330
+ ureply = await event.get_reply_message()
331
+ xx = await eor(event, "`...`")
332
+ if not (ureply and (ureply.media)):
333
+ await xx.edit("`Reply to any media`")
334
+ return
335
+ ultt = await ureply.download_media()
336
+ if ultt.endswith(".tgs"):
337
+ await xx.edit("`Ooo Animated Sticker 👀...`")
338
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
339
+ file = "ult.png"
340
+ process = await asyncio.create_subprocess_exec(
341
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
342
+ )
343
+ stdout, stderr = await process.communicate()
344
+ stderr.decode().strip()
345
+ stdout.decode().strip()
346
+ else:
347
+ await xx.edit("`Processing...`")
348
+ img = cv2.VideoCapture(ultt)
349
+ heh, lol = img.read()
350
+ cv2.imwrite("ult.png", lol)
351
+ file = "ult.png"
352
+ ult = cv2.imread(file)
353
+ height, width, channels = ult.shape
354
+ samples = np.zeros([height * width, 3], dtype=np.float32)
355
+ count = 0
356
+ for x in range(height):
357
+ for y in range(width):
358
+ samples[count] = ult[x][y]
359
+ count += 1
360
+ compactness, labels, centers = cv2.kmeans(
361
+ samples,
362
+ 12,
363
+ None,
364
+ (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10000, 0.0001),
365
+ 5,
366
+ cv2.KMEANS_PP_CENTERS,
367
+ )
368
+ centers = np.uint8(centers)
369
+ ish = centers[labels.flatten()]
370
+ ultroid = ish.reshape((ult.shape))
371
+ cv2.imwrite("ult.jpg", ultroid)
372
+ await event.client.send_file(
373
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
374
+ )
375
+ await xx.delete()
376
+ os.remove("ult.png")
377
+ os.remove("ult.jpg")
378
+ os.remove(ultt)
379
+
380
+
381
+ @ultroid_cmd(
382
+ pattern="danger$",
383
+ )
384
+ async def ultd(event):
385
+ ureply = await event.get_reply_message()
386
+ xx = await eor(event, "`...`")
387
+ if not (ureply and (ureply.media)):
388
+ await xx.edit("`Reply to any media`")
389
+ return
390
+ ultt = await ureply.download_media()
391
+ if ultt.endswith(".tgs"):
392
+ await xx.edit("`Ooo Animated Sticker 👀...`")
393
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
394
+ file = "ult.png"
395
+ process = await asyncio.create_subprocess_exec(
396
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
397
+ )
398
+ stdout, stderr = await process.communicate()
399
+ stderr.decode().strip()
400
+ stdout.decode().strip()
401
+ else:
402
+ await xx.edit("`Processing...`")
403
+ img = cv2.VideoCapture(ultt)
404
+ heh, lol = img.read()
405
+ cv2.imwrite("ult.png", lol)
406
+ file = "ult.png"
407
+ ult = cv2.imread(file)
408
+ dan = cv2.cvtColor(ult, cv2.COLOR_BGR2RGB)
409
+ ultroid = cv2.cvtColor(dan, cv2.COLOR_HSV2BGR)
410
+ cv2.imwrite("ult.jpg", ultroid)
411
+ await event.client.send_file(
412
+ event.chat_id, "ult.jpg", force_document=False, reply_to=event.reply_to_msg_id
413
+ )
414
+ await xx.delete()
415
+ os.remove("ult.png")
416
+ os.remove("ult.jpg")
417
+ os.remove(ultt)
418
+
419
+
420
+ @ultroid_cmd(
421
+ pattern="blue$",
422
+ )
423
+ async def ultd(event):
424
+ ureply = await event.get_reply_message()
425
+ xx = await eor(event, "`...`")
426
+ if not (ureply and (ureply.media)):
427
+ await xx.edit("`Reply to any media`")
428
+ return
429
+ ultt = await ureply.download_media()
430
+ if ultt.endswith(".tgs"):
431
+ await xx.edit("`Ooo Animated Sticker 👀...`")
432
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
433
+ file = "ult.png"
434
+ process = await asyncio.create_subprocess_exec(
435
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
436
+ )
437
+ stdout, stderr = await process.communicate()
438
+ stderr.decode().strip()
439
+ stdout.decode().strip()
440
+ else:
441
+ await xx.edit("`Processing...`")
442
+ img = cv2.VideoCapture(ultt)
443
+ heh, lol = img.read()
444
+ cv2.imwrite("ult.png", lol)
445
+ file = "ult.png"
446
+ got = upf(file)
447
+ lnk = f"https://telegra.ph{got[0]}"
448
+ r = requests.get(
449
+ f"https://nekobot.xyz/api/imagegen?type=blurpify&image={lnk}"
450
+ ).json()
451
+ ms = r.get("message")
452
+ utd = url(ms)
453
+ if not utd:
454
+ return
455
+ with open("ult.png", "wb") as f:
456
+ f.write(requests.get(ms).content)
457
+ img = Image.open("ult.png").convert("RGB")
458
+ img.save("ult.webp", "webp")
459
+ await event.client.send_file(
460
+ event.chat_id, "ult.webp", force_document=False, reply_to=event.reply_to_msg_id
461
+ )
462
+ await xx.delete()
463
+ os.remove("ult.png")
464
+ os.remove("ult.webp")
465
+ os.remove(ultt)
466
+
467
+
468
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/pdftools.py ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}pdf <page num> <reply to pdf file>`
12
+ Extract nd Send page as a Image.(note-: For Extraction all pages just use .pdf)
13
+
14
+ • `{i}pdtext <page num> <reply to pdf file>`
15
+ Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext)
16
+
17
+ • `{i}pdscan <reply to image>`
18
+ It scan, crop nd send img as pdf.
19
+
20
+ • `{i}pdsave <reply to image/pdf>`
21
+ It scan, crop nd save file to merge u can merge many pages as a single pdf.
22
+
23
+ • `{i}pdsend `
24
+ Merge nd send the Pdf to collected from .pdsave.
25
+ """
26
+
27
+ import os
28
+ import shutil
29
+
30
+ import cv2
31
+ import imutils
32
+ import numpy as np
33
+ import PIL
34
+ from imutils.perspective import four_point_transform
35
+ from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter
36
+ from skimage.filters import threshold_local
37
+
38
+ from . import *
39
+
40
+ if not os.path.exists("pdf/"):
41
+ os.makedirs("pdf/")
42
+
43
+
44
+ @ultroid_cmd(
45
+ pattern="pdf ?(.*)",
46
+ )
47
+ async def pdfseimg(event):
48
+ ok = await event.get_reply_message()
49
+ msg = event.pattern_match.group(1)
50
+ if not ok and ok.document and ok.document.mime_type == "application/pdf":
51
+ await eor(event, "`Reply The pdf u Want to Download..`")
52
+ return
53
+ xx = await eor(event, "Processing...")
54
+ if not msg:
55
+ d = os.path.join("pdf/", "hehe.pdf")
56
+ await event.client.download_media(ok, d)
57
+ pdfp = "pdf/hehe.pdf"
58
+ pdfp.replace(".pdf", "")
59
+ pdf = PdfFileReader(pdfp)
60
+ for num in range(pdf.numPages):
61
+ pw = PdfFileWriter()
62
+ pw.addPage(pdf.getPage(num))
63
+ with open(os.path.join("pdf/ult{}.png".format(num + 1)), "wb") as f:
64
+ pw.write(f)
65
+ os.remove(pdfp)
66
+ a = os.listdir("pdf/")
67
+ for z in a:
68
+ lst = [f"pdf/{z}"]
69
+ await event.client.send_file(event.chat_id, lst, album=True)
70
+ shutil.rmtree("pdf")
71
+ os.makedirs("pdf/")
72
+ await xx.delete()
73
+ if msg:
74
+ o = int(msg) - 1
75
+ d = os.path.join("pdf/", "hehe.pdf")
76
+ await event.client.download_media(ok, d)
77
+ pdfp = "pdf/hehe.pdf"
78
+ pdfp.replace(".pdf", "")
79
+ pdf = PdfFileReader(pdfp)
80
+ pw = PdfFileWriter()
81
+ pw.addPage(pdf.getPage(o))
82
+ with open(os.path.join("ult.png"), "wb") as f:
83
+ pw.write(f)
84
+ os.remove(pdfp)
85
+ await event.client.send_file(
86
+ event.chat_id, "ult.png", reply_to=event.reply_to_msg_id
87
+ )
88
+ os.remove("ult.png")
89
+ await xx.delete()
90
+
91
+
92
+ @ultroid_cmd(
93
+ pattern="pdtext ?(.*)",
94
+ )
95
+ async def pdfsetxt(event):
96
+ ok = await event.get_reply_message()
97
+ msg = event.pattern_match.group(1)
98
+ if not ok and ok.document and ok.document.mime_type == "application/pdf":
99
+ await eor(event, "`Reply The pdf u Want to Download..`")
100
+ return
101
+ xx = await eor(event, "`Processing...`")
102
+ if not msg:
103
+ dl = await event.client.download_media(ok)
104
+ pdf = PdfFileReader(dl)
105
+ text = f"{dl.split('.')[0]}.txt"
106
+ with open(text, "w") as f:
107
+ for page_num in range(pdf.numPages):
108
+ pageObj = pdf.getPage(page_num)
109
+ txt = pageObj.extractText()
110
+ f.write("Page {0}\n".format(page_num + 1))
111
+ f.write("".center(100, "-"))
112
+ f.write(txt)
113
+ await event.client.send_file(
114
+ event.chat_id, text, reply_to=event.reply_to_msg_id
115
+ )
116
+ os.remove(text)
117
+ os.remove(dl)
118
+ await xx.delete()
119
+ return
120
+ if "_" in msg:
121
+ u, d = msg.split("_")
122
+ dl = await event.client.download_media(ok)
123
+ a = PdfFileReader(dl)
124
+ str = ""
125
+ for i in range(int(u) - 1, int(d)):
126
+ str += a.getPage(i).extractText()
127
+ text = f"{dl.split('.')[0]} {msg}.txt"
128
+ with open(text, "w") as f:
129
+ f.write(str)
130
+ await event.client.send_file(
131
+ event.chat_id, text, reply_to=event.reply_to_msg_id
132
+ )
133
+ os.remove(text)
134
+ os.remove(dl)
135
+ else:
136
+ u = int(msg) - 1
137
+ dl = await event.client.download_media(ok)
138
+ a = PdfFileReader(dl)
139
+ str = a.getPage(u).extractText()
140
+ text = f"{dl.split('.')[0]} Pg-{msg}.txt"
141
+ with open(text, "w") as f:
142
+ f.write(str)
143
+ await event.client.send_file(
144
+ event.chat_id, text, reply_to=event.reply_to_msg_id
145
+ )
146
+ os.remove(text)
147
+ os.remove(dl)
148
+ await xx.delete()
149
+
150
+
151
+ @ultroid_cmd(
152
+ pattern="pdscan ?(.*)",
153
+ )
154
+ async def imgscan(event):
155
+ ok = await event.get_reply_message()
156
+ if not (ok and (ok.media)):
157
+ await eor(event, "`Reply The pdf u Want to Download..`")
158
+ return
159
+ ultt = await ok.download_media()
160
+ if not ultt.endswith(("png", "jpg", "jpeg", "webp")):
161
+ await eor(event, "`Reply to a Image only...`")
162
+ os.remove(ultt)
163
+ return
164
+ xx = await eor(event, "`Processing...`")
165
+ image = cv2.imread(ultt)
166
+ original_image = image.copy()
167
+ ratio = image.shape[0] / 500.0
168
+ image = imutils.resize(image, height=500)
169
+ image_yuv = cv2.cvtColor(image, cv2.COLOR_BGR2YUV)
170
+ image_y = np.zeros(image_yuv.shape[0:2], np.uint8)
171
+ image_y[:, :] = image_yuv[:, :, 0]
172
+ image_blurred = cv2.GaussianBlur(image_y, (3, 3), 0)
173
+ edges = cv2.Canny(image_blurred, 50, 200, apertureSize=3)
174
+ contours, hierarchy = cv2.findContours(
175
+ edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
176
+ )
177
+ polygons = []
178
+ for cnt in contours:
179
+ hull = cv2.convexHull(cnt)
180
+ polygons.append(cv2.approxPolyDP(hull, 0.01 * cv2.arcLength(hull, True), False))
181
+ sortedPoly = sorted(polygons, key=cv2.contourArea, reverse=True)
182
+ cv2.drawContours(image, sortedPoly[0], -1, (0, 0, 255), 5)
183
+ simplified_cnt = sortedPoly[0]
184
+ if len(simplified_cnt) == 4:
185
+ cropped_image = four_point_transform(
186
+ original_image, simplified_cnt.reshape(4, 2) * ratio
187
+ )
188
+ gray_image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
189
+ T = threshold_local(gray_image, 11, offset=10, method="gaussian")
190
+ ok = (gray_image > T).astype("uint8") * 255
191
+ if len(simplified_cnt) != 4:
192
+ ok = cv2.detailEnhance(original_image, sigma_s=10, sigma_r=0.15)
193
+ cv2.imwrite("o.png", ok)
194
+ image1 = PIL.Image.open("o.png")
195
+ im1 = image1.convert("RGB")
196
+ scann = f"Scanned {ultt.split('.')[0]}.pdf"
197
+ im1.save(scann)
198
+ await event.client.send_file(event.chat_id, scann, reply_to=event.reply_to_msg_id)
199
+ await xx.delete()
200
+ os.remove(ultt)
201
+ os.remove("o.png")
202
+ os.remove(scann)
203
+
204
+
205
+ @ultroid_cmd(
206
+ pattern="pdsave ?(.*)",
207
+ )
208
+ async def savepdf(event):
209
+ ok = await event.get_reply_message()
210
+ if not (ok and (ok.media)):
211
+ await eor(
212
+ event, "`Reply to Images/pdf which u want to merge as a single pdf..`"
213
+ )
214
+ return
215
+ ultt = await ok.download_media()
216
+ if ultt.endswith(("png", "jpg", "jpeg", "webp")):
217
+ xx = await eor(event, "`Processing...`")
218
+ image = cv2.imread(ultt)
219
+ original_image = image.copy()
220
+ ratio = image.shape[0] / 500.0
221
+ image = imutils.resize(image, height=500)
222
+ image_yuv = cv2.cvtColor(image, cv2.COLOR_BGR2YUV)
223
+ image_y = np.zeros(image_yuv.shape[0:2], np.uint8)
224
+ image_y[:, :] = image_yuv[:, :, 0]
225
+ image_blurred = cv2.GaussianBlur(image_y, (3, 3), 0)
226
+ edges = cv2.Canny(image_blurred, 50, 200, apertureSize=3)
227
+ contours, hierarchy = cv2.findContours(
228
+ edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
229
+ )
230
+ polygons = []
231
+ for cnt in contours:
232
+ hull = cv2.convexHull(cnt)
233
+ polygons.append(
234
+ cv2.approxPolyDP(hull, 0.01 * cv2.arcLength(hull, True), False)
235
+ )
236
+ sortedPoly = sorted(polygons, key=cv2.contourArea, reverse=True)
237
+ cv2.drawContours(image, sortedPoly[0], -1, (0, 0, 255), 5)
238
+ simplified_cnt = sortedPoly[0]
239
+ if len(simplified_cnt) == 4:
240
+ cropped_image = four_point_transform(
241
+ original_image, simplified_cnt.reshape(4, 2) * ratio
242
+ )
243
+ gray_image = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
244
+ T = threshold_local(gray_image, 11, offset=10, method="gaussian")
245
+ ok = (gray_image > T).astype("uint8") * 255
246
+ if len(simplified_cnt) != 4:
247
+ ok = cv2.detailEnhance(original_image, sigma_s=10, sigma_r=0.15)
248
+ cv2.imwrite("o.png", ok)
249
+ image1 = PIL.Image.open("o.png")
250
+ im1 = image1.convert("RGB")
251
+ a = dani_ck("pdf/scan.pdf")
252
+ im1.save(a)
253
+ await xx.edit(
254
+ f"Done, Now Reply Another Image/pdf if completed then use {hndlr}pdsend to merge nd send all as pdf",
255
+ )
256
+ os.remove("o.png")
257
+ elif ultt.endswith(".pdf"):
258
+ a = dani_ck("pdf/scan.pdf")
259
+ await ultroid_bot.download_media(ok, a)
260
+ await eor(
261
+ event,
262
+ f"Done, Now Reply Another Image/pdf if completed then use {hndlr}pdsend to merge nd send all as pdf",
263
+ )
264
+ else:
265
+ await eor(event, "`Reply to a Image/pdf only...`")
266
+ os.remove(ultt)
267
+
268
+
269
+ @ultroid_cmd(
270
+ pattern="pdsend ?(.*)",
271
+ )
272
+ async def sendpdf(event):
273
+ if not os.path.exists("pdf/scan.pdf"):
274
+ await eor(
275
+ event,
276
+ "first select pages by replying .pdsave of which u want to make multi page pdf file",
277
+ )
278
+ return
279
+ msg = event.pattern_match.group(1)
280
+ if msg:
281
+ ok = f"{msg}.pdf"
282
+ else:
283
+ ok = "My PDF File.pdf"
284
+ merger = PdfFileMerger()
285
+ for item in os.listdir("pdf/"):
286
+ if item.endswith("pdf"):
287
+ merger.append(f"pdf/{item}")
288
+ merger.write(ok)
289
+ await event.client.send_file(event.chat_id, ok, reply_to=event.reply_to_msg_id)
290
+ os.remove(ok)
291
+ shutil.rmtree("pdf/")
292
+ os.makedirs("pdf/")
293
+
294
+
295
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/pmpermit.py ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ from pyUltroid.functions.pmpermit_db import *
9
+ from telethon import events
10
+ from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
11
+ from telethon.tl.functions.messages import ReportSpamRequest
12
+
13
+ from . import *
14
+
15
+ # ========================= CONSTANTS =============================
16
+ COUNT_PM = {}
17
+ LASTMSG = {}
18
+ PMPIC = "https://telegra.ph/file/94f6a4aeb21ce2d58dd41.jpg"
19
+ UNAPPROVED_MSG = """
20
+ **PMSecurity of {}!**
21
+ Please wait for me to respnd or you will be blocked and reported as spam!!
22
+
23
+ You have {}/{} warnings!"""
24
+ WARNS = 3
25
+ NO_REPLY = "Reply to someone's msg or try this commmand in private."
26
+ PMCMDS = [
27
+ f"{hndlr}a",
28
+ f"{hndlr}approve",
29
+ f"{hndlr}da",
30
+ f"{hndlr}disapprove",
31
+ f"{hndlr}block",
32
+ f"{hndlr}unblock",
33
+ ]
34
+ # =================================================================
35
+
36
+ sett = udB.get("PMSETTING")
37
+ if sett is None:
38
+ sett = True
39
+ if sett == "True" and sett != "False":
40
+
41
+ @ultroid_bot.on(events.NewMessage(outgoing=True, func=lambda e: e.is_private))
42
+ async def autoappr(event):
43
+ chat = await event.get_chat()
44
+ mssg = event.text
45
+ if mssg in PMCMDS: # do not approve if outgoing is a command.
46
+ return
47
+ if not is_approved(chat.id) and chat.id not in COUNT_PM:
48
+ approve_user(chat.id)
49
+ if Var.LOG_CHANNEL:
50
+ name = await event.client.get_entity(chat.id)
51
+ name0 = str(name.first_name)
52
+ await event.client.send_message(
53
+ Var.LOG_CHANNEL,
54
+ f"#AutoApproved\nUser - [{name0}](tg://user?id={chat.id})",
55
+ )
56
+
57
+ @ultroid_bot.on(events.NewMessage(incoming=True))
58
+ async def permitpm(event):
59
+ if event.is_private:
60
+ user = await event.get_chat()
61
+ if user.bot:
62
+ return
63
+ apprv = is_approved(user.id)
64
+ if not apprv and event.text != UNAPPROVED_MSG:
65
+ try:
66
+ wrn = COUNT_PM[user.id]
67
+ except KeyError:
68
+ wrn = 0
69
+ if user.id in LASTMSG:
70
+ prevmsg = LASTMSG[user.id]
71
+ if event.text != prevmsg:
72
+ async for message in event.client.iter_messages(
73
+ user.id, from_user="me", search=UNAPPROVED_MSG
74
+ ):
75
+ await message.delete()
76
+ await event.client.send_file(
77
+ user.id,
78
+ PMPIC,
79
+ caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
80
+ )
81
+ elif event.text == prevmsg:
82
+ async for message in event.client.iter_messages(
83
+ user.id, from_user="me", search=UNAPPROVED_MSG
84
+ ):
85
+ await message.delete()
86
+ await event.client.send_file(
87
+ user.id,
88
+ PMPIC,
89
+ caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
90
+ )
91
+ LASTMSG.update({user.id: event.text})
92
+ else:
93
+ await event.client.send_file(
94
+ user.id,
95
+ PMPIC,
96
+ caption=UNAPPROVED_MSG.format(OWNER_NAME, wrn, WARNS),
97
+ )
98
+ LASTMSG.update({user.id: event.text})
99
+ if user.id not in COUNT_PM:
100
+ COUNT_PM.update({user.id: 1})
101
+ else:
102
+ COUNT_PM[user.id] = COUNT_PM[user.id] + 1
103
+ if COUNT_PM[user.id] > WARNS:
104
+ await event.respond(
105
+ "`You were spamming my Master's PM, which I didn't like.`\n`You have been BLOCKED and reported as SPAM, until further notice.`"
106
+ )
107
+ try:
108
+ del COUNT_PM[user.id]
109
+ del LASTMSG[user.id]
110
+ except KeyError:
111
+ if Var.LOG_CHANNEL:
112
+ await event.client.send_message(
113
+ Var.LOG_CHANNEL,
114
+ "PMPermit is messed! Pls restart the bot!!",
115
+ )
116
+ return LOGS.info("COUNT_PM is messed.")
117
+ await event.client(BlockRequest(user.id))
118
+ await event.client(ReportSpamRequest(peer=user.id))
119
+ if Var.LOG_CHANNEL:
120
+ name = await event.client.get_entity(user.id)
121
+ name0 = str(name.first_name)
122
+ await event.client.send_message(
123
+ Var.LOG_CHANNEL,
124
+ f"[{name0}](tg://user?id={user.id}) was blocked for spamming.",
125
+ )
126
+
127
+ @ultroid_cmd(pattern="(a|approve)(?: |$)")
128
+ async def approvepm(apprvpm):
129
+ if apprvpm.reply_to_msg_id:
130
+ reply = await apprvpm.get_reply_message()
131
+ replied_user = await apprvpm.client.get_entity(reply.sender_id)
132
+ aname = replied_user.id
133
+ name0 = str(replied_user.first_name)
134
+ uid = replied_user.id
135
+ if not is_approved(uid):
136
+ approve_user(uid)
137
+ await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")
138
+ await asyncio.sleep(3)
139
+ await apprvpm.delete()
140
+ else:
141
+ await apprvpm.edit("`User may already be approved.`")
142
+ await asyncio.sleep(5)
143
+ await apprvpm.delete()
144
+ elif apprvpm.is_private:
145
+ user = await apprvpm.get_chat()
146
+ aname = await apprvpm.client.get_entity(user.id)
147
+ name0 = str(aname.first_name)
148
+ uid = user.id
149
+ if not is_approved(uid):
150
+ approve_user(uid)
151
+ await apprvpm.edit(f"[{name0}](tg://user?id={uid}) `approved to PM!`")
152
+ async for message in apprvpm.client.iter_messages(
153
+ user.id, from_user="me", search=UNAPPROVED_MSG
154
+ ):
155
+ await message.delete()
156
+ await asyncio.sleep(3)
157
+ await apprvpm.delete()
158
+ if Var.LOG_CHANNEL:
159
+ await apprvpm.client.send_message(
160
+ Var.LOG_CHANNEL,
161
+ f"#APPROVED\nUser: [{name0}](tg://user?id={uid})",
162
+ )
163
+ else:
164
+ await apprvpm.edit("`User may already be approved.`")
165
+ await asyncio.sleep(5)
166
+ await apprvpm.delete()
167
+ if Var.LOG_CHANNEL:
168
+ await apprvpm.client.send_message(
169
+ Var.LOG_CHANNEL,
170
+ f"#APPROVED\nUser: [{name0}](tg://user?id={uid})",
171
+ )
172
+ else:
173
+ await apprvpm.edit(NO_REPLY)
174
+
175
+ @ultroid_cmd(pattern="(da|disapprove)(?: |$)")
176
+ async def disapprovepm(e):
177
+ if e.reply_to_msg_id:
178
+ reply = await e.get_reply_message()
179
+ replied_user = await e.client.get_entity(reply.sender_id)
180
+ aname = replied_user.id
181
+ name0 = str(replied_user.first_name)
182
+ if is_approved(replied_user.id):
183
+ disapprove_user(replied_user.id)
184
+ await e.edit(
185
+ f"[{name0}](tg://user?id={replied_user.id}) `Disaproved to PM!`"
186
+ )
187
+ await asyncio.sleep(5)
188
+ await e.delete()
189
+ else:
190
+ await e.edit(
191
+ f"[{name0}](tg://user?id={replied_user.id}) was never approved!"
192
+ )
193
+ await asyncio.sleep(5)
194
+ await e.delete()
195
+ elif e.is_private:
196
+ bbb = await e.get_chat()
197
+ aname = await e.client.get_entity(bbb.id)
198
+ name0 = str(aname.first_name)
199
+ if is_approved(bbb.id):
200
+ disapprove_user(bbb.id)
201
+ await e.edit(f"[{name0}](tg://user?id={bbb.id}) `Disaproved to PM!`")
202
+ await asyncio.sleep(5)
203
+ await e.delete()
204
+ if Var.LOG_CHANNEL:
205
+ await e.client.send_message(
206
+ Var.LOG_CHANNEL,
207
+ f"[{name0}](tg://user?id={bbb.id}) was disapproved to PM you.",
208
+ )
209
+ else:
210
+ await e.edit(f"[{name0}](tg://user?id={bbb.id}) was never approved!")
211
+ await asyncio.sleep(5)
212
+ await e.delete()
213
+ else:
214
+ await e.edit(NO_REPLY)
215
+
216
+ @ultroid_cmd(pattern="block$")
217
+ async def blockpm(block):
218
+ if block.reply_to_msg_id:
219
+ reply = await block.get_reply_message()
220
+ replied_user = await block.client.get_entity(reply.sender_id)
221
+ aname = replied_user.id
222
+ name0 = str(replied_user.first_name)
223
+ await block.client(BlockRequest(replied_user.id))
224
+ await block.edit("`You've been blocked!`")
225
+ uid = replied_user.id
226
+ elif block.is_private:
227
+ bbb = await block.get_chat()
228
+ await block.client(BlockRequest(bbb.id))
229
+ aname = await block.client.get_entity(bbb.id)
230
+ await block.edit("`You've been blocked!`")
231
+ name0 = str(aname.first_name)
232
+ uid = bbb.id
233
+ else:
234
+ await block.edit(NO_REPLY)
235
+ try:
236
+ disapprove_user(uid)
237
+ except AttributeError:
238
+ pass
239
+ if Var.LOG_CHANNEL:
240
+ await block.client.send_message(
241
+ Var.LOG_CHANNEL, f"#BLOCKED\nUser: [{name0}](tg://user?id={uid})"
242
+ )
243
+
244
+ @ultroid_cmd(pattern="unblock$")
245
+ async def unblockpm(unblock):
246
+ if unblock.reply_to_msg_id:
247
+ reply = await unblock.get_reply_message()
248
+ replied_user = await unblock.client.get_entity(reply.sender_id)
249
+ name0 = str(replied_user.first_name)
250
+ await unblock.client(UnblockRequest(replied_user.id))
251
+ await unblock.edit("`You have been unblocked.`")
252
+ else:
253
+ await unblock.edit(NO_REPLY)
254
+ if Var.LOG_CHANNEL:
255
+ await unblock.client.send_message(
256
+ Var.LOG_CHANNEL,
257
+ f"[{name0}](tg://user?id={replied_user.id}) was unblocked!.",
258
+ )
plugins/profile.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}setname <first name // last name>`
12
+ Change your profile name.
13
+
14
+ • `{i}setbio <bio>`
15
+ Change your profile bio.
16
+
17
+ • `{i}setpic <reply to pic>`
18
+ Change your profile pic.
19
+
20
+ • `{i}delpfp <n>(optional)`
21
+ Delete one profile pic, if no value given, else delete n number of pics.
22
+
23
+ • `{i}gpoto <username>`
24
+ Upload the photo of Chat/User if Available.
25
+ """
26
+
27
+ import asyncio
28
+ import os
29
+
30
+ from telethon.tl import functions
31
+ from telethon.tl.functions.photos import DeletePhotosRequest, GetUserPhotosRequest
32
+ from telethon.tl.types import InputPhoto
33
+
34
+ from . import *
35
+
36
+ TMP_DOWNLOAD_DIRECTORY = "resources/downloads/"
37
+
38
+ # bio changer
39
+
40
+
41
+ @ultroid_cmd(
42
+ pattern="setbio ?(.*)",
43
+ )
44
+ async def _(ult):
45
+ ok = await eor(ult, "...")
46
+ set = ult.pattern_match.group(1)
47
+ try:
48
+ await ultroid_bot(functions.account.UpdateProfileRequest(about=set))
49
+ await ok.edit("Profile bio changed to\n`{}`".format(set))
50
+ except Exception as ex:
51
+ await ok.edit("Error occured.\n`{}`".format(str(ex)))
52
+ await asyncio.sleep(10)
53
+ await ok.delete()
54
+
55
+
56
+ # name changer
57
+
58
+
59
+ @ultroid_cmd(
60
+ pattern="setname ?((.|//)*)",
61
+ )
62
+ async def _(ult):
63
+ ok = await eor(ult, "...")
64
+ names = ult.pattern_match.group(1)
65
+ first_name = names
66
+ last_name = ""
67
+ if "//" in names:
68
+ first_name, last_name = names.split("//", 1)
69
+ try:
70
+ await ultroid_bot(
71
+ functions.account.UpdateProfileRequest(
72
+ first_name=first_name, last_name=last_name
73
+ )
74
+ )
75
+ await ok.edit("Name changed to `{}`".format(names))
76
+ except Exception as ex:
77
+ await ok.edit("Error occured.\n`{}`".format(str(ex)))
78
+ await asyncio.sleep(10)
79
+ await ok.delete()
80
+
81
+
82
+ # profile pic
83
+
84
+
85
+ @ultroid_cmd(
86
+ pattern="setpic$",
87
+ )
88
+ async def _(ult):
89
+ ok = await eor(ult, "...")
90
+ reply_message = await ult.get_reply_message()
91
+ await ok.edit("`Downloading that picture...`")
92
+ if not os.path.isdir(TMP_DOWNLOAD_DIRECTORY):
93
+ os.makedirs(TMP_DOWNLOAD_DIRECTORY)
94
+ photo = None
95
+ try:
96
+ photo = await ultroid_bot.download_media(reply_message, TMP_DOWNLOAD_DIRECTORY)
97
+ except Exception as ex:
98
+ await ok.edit("Error occured.\n`{}`".format(str(ex)))
99
+ else:
100
+ if photo:
101
+ await ok.edit("`Uploading it to my profile...`")
102
+ file = await ultroid_bot.upload_file(photo)
103
+ try:
104
+ await ultroid_bot(functions.photos.UploadProfilePhotoRequest(file))
105
+ except Exception as ex:
106
+ await ok.edit("Error occured.\n`{}`".format(str(ex)))
107
+ else:
108
+ await ok.edit("`My profile picture has been changed !`")
109
+ await asyncio.sleep(10)
110
+ await ok.delete()
111
+ try:
112
+ os.remove(photo)
113
+ except Exception as ex:
114
+ LOGS.exception(ex)
115
+
116
+
117
+ # delete profile pic(s)
118
+
119
+
120
+ @ultroid_cmd(
121
+ pattern="delpfp ?(.*)",
122
+ )
123
+ async def remove_profilepic(delpfp):
124
+ ok = await eor(delpfp, "...")
125
+ group = delpfp.text[8:]
126
+ if group == "all":
127
+ lim = 0
128
+ elif group.isdigit():
129
+ lim = int(group)
130
+ else:
131
+ lim = 1
132
+ pfplist = await ultroid_bot(
133
+ GetUserPhotosRequest(user_id=delpfp.from_id, offset=0, max_id=0, limit=lim)
134
+ )
135
+ input_photos = []
136
+ for sep in pfplist.photos:
137
+ input_photos.append(
138
+ InputPhoto(
139
+ id=sep.id,
140
+ access_hash=sep.access_hash,
141
+ file_reference=sep.file_reference,
142
+ )
143
+ )
144
+ await ultroid_bot(DeletePhotosRequest(id=input_photos))
145
+ await ok.edit(f"`Successfully deleted {len(input_photos)} profile picture(s).`")
146
+ await asyncio.sleep(10)
147
+ await ok.delete()
148
+
149
+
150
+ @ultroid_cmd(pattern="gpoto ?(.*)")
151
+ async def gpoto(e):
152
+ ult = e.pattern_match.group(1)
153
+ try:
154
+ okla = await ultroid_bot.download_profile_photo(
155
+ ult, "profile.jpg", download_big=True
156
+ )
157
+ await ultroid_bot.send_message(e.chat_id, file=okla)
158
+ os.remove(okla)
159
+ except Exception as e:
160
+ await eor(e, f"ERROR - {str(e)}")
161
+
162
+
163
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/redis.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}setredis key | value`
12
+ Redis Set Value.
13
+ e.g :
14
+ `{i}setredis hi there`
15
+ `{i}setredis hi there | ultroid here`
16
+
17
+ • `{i}getredis key`
18
+ Redis Get Value
19
+
20
+ • `{i}delredis key`
21
+ Delete Key from Redis DB
22
+
23
+ • `{i}renredis old keyname | new keyname`
24
+ Update Key Name
25
+
26
+ • `{i}getkeys`
27
+ Get the list of keys stored in Redis
28
+ """
29
+
30
+ import re
31
+
32
+ from . import *
33
+
34
+
35
+ @ultroid_cmd(
36
+ pattern="setredis ?(.*)",
37
+ )
38
+ async def _(ult):
39
+ ok = await eor(ult, "`...`")
40
+ try:
41
+ delim = " " if re.search("[|]", ult.pattern_match.group(1)) is None else " | "
42
+ data = ult.pattern_match.group(1).split(delim)
43
+ udB.set(data[0], data[1])
44
+ redisdata = Redis(data[0])
45
+ await ok.edit(
46
+ "Redis Key Value Pair Updated\nKey : `{}`\nValue : `{}`".format(
47
+ data[0], redisdata
48
+ )
49
+ )
50
+ except BaseException:
51
+ await ok.edit("`Something Went Wrong`")
52
+
53
+
54
+ @ultroid_cmd(
55
+ pattern="getredis ?(.*)",
56
+ )
57
+ async def _(ult):
58
+ ok = await eor(ult, "`Fetching data from Redis`")
59
+ val = ult.pattern_match.group(1)
60
+ if val == "":
61
+ return await ult.edit(f"Please use `{hndlr}getkeys <keyname>`")
62
+ try:
63
+ value = Redis(val)
64
+ await ok.edit("Key: `{}`\nValue: `{}`".format(val, value))
65
+ except BaseException:
66
+ await ok.edit("`Something Went Wrong`")
67
+
68
+
69
+ @ultroid_cmd(
70
+ pattern="delredis ?(.*)",
71
+ )
72
+ async def _(ult):
73
+ ok = await eor(ult, "`Deleting data from Redis ...`")
74
+ try:
75
+ key = ult.pattern_match.group(1)
76
+ udB.delete(key)
77
+ await ok.edit(f"`Successfully deleted key {key}`")
78
+ except BaseException:
79
+ await ok.edit("`Something Went Wrong`")
80
+
81
+
82
+ @ultroid_cmd(
83
+ pattern="renredis ?(.*)",
84
+ )
85
+ async def _(ult):
86
+ ok = await eor(ult, "`...`")
87
+ delim = " " if re.search("[|]", ult.pattern_match.group(1)) is None else " | "
88
+ data = ult.pattern_match.group(1).split(delim)
89
+ if Redis(data[0]):
90
+ try:
91
+ udB.rename(data[0], data[1])
92
+ await ok.edit(
93
+ "Redis Key Rename Successful\nOld Key : `{}`\nNew Key : `{}`".format(
94
+ data[0], data[1]
95
+ )
96
+ )
97
+ except BaseException:
98
+ await ok.edit("Something went wrong ...")
99
+ else:
100
+ await ok.edit("Key not found")
101
+
102
+
103
+ @ultroid_cmd(
104
+ pattern="getkeys$",
105
+ )
106
+ async def _(ult):
107
+ ok = await eor(ult, "`Fetching Keys ...`")
108
+ keys = udB.keys()
109
+ msg = ""
110
+ for x in keys:
111
+ msg += "• `{}`".format(x) + "\n"
112
+ await ok.edit("**List of Redis Keys :**\n{}".format(msg))
113
+
114
+
115
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/specialtools.py ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}wspr <username>`
12
+ Send secret message..
13
+
14
+ • `{i}sticker <query>`
15
+ Search Stickers as Per ur Wish..
16
+
17
+ • `{i}getaudio <reply to an audio>`
18
+ Download Audio To put in ur Desired Video/Gif.
19
+
20
+ • `{i}addaudio <reply to Video/gif>`
21
+ It will put the above audio to the replied video/gif.
22
+
23
+ • `{i}dob <date of birth>`
24
+ Put in dd/mm/yy Format only(eg .dob 01/01/1999).
25
+
26
+ • `{i}wall <query>`
27
+ Search Hd Wallpaper as Per ur Wish..
28
+ """
29
+
30
+ import os
31
+ from datetime import datetime as dt
32
+ from random import choice
33
+ from shutil import rmtree
34
+
35
+ import moviepy.editor as m
36
+ import pytz
37
+ import requests
38
+ from bs4 import BeautifulSoup as b
39
+
40
+ from . import *
41
+
42
+
43
+ @ultroid_cmd(
44
+ pattern="getaudio$",
45
+ )
46
+ async def daudtoid(event):
47
+ ureply = await event.get_reply_message()
48
+ if not (ureply and ("audio" in ureply.document.mime_type)):
49
+ await eor(event, "`Reply To Audio Only..`")
50
+ return
51
+ xx = await eor(event, "`processing...`")
52
+ d = os.path.join("resources/extras/", "ul.mp3")
53
+ await xx.edit("`Downloading... Large Files Takes Time..`")
54
+ await event.client.download_media(ureply, d)
55
+ await xx.edit("`Done.. Now reply to video In which u want to add that Audio`")
56
+
57
+
58
+ @ultroid_cmd(
59
+ pattern="addaudio$",
60
+ )
61
+ async def adaudroid(event):
62
+ ureply = await event.get_reply_message()
63
+ if not (ureply and ("video" in ureply.document.mime_type)):
64
+ await eor(event, "`Reply To Gif/Video In which u want to add audio.`")
65
+ return
66
+ xx = await eor(event, "`processing...`")
67
+ ultt = await ureply.download_media()
68
+ ls = os.listdir("resources/extras")
69
+ z = "ul.mp3"
70
+ x = "resources/extras/ul.mp3"
71
+ if z not in ls:
72
+ await xx.edit("`First reply an audio with .aw`")
73
+ return
74
+ video = m.VideoFileClip(ultt)
75
+ audio = m.AudioFileClip(x)
76
+ out = video.set_audio(audio)
77
+ out.write_videofile("ok.mp4", fps=30)
78
+ await event.client.send_file(
79
+ event.chat_id,
80
+ file="ok.mp4",
81
+ force_document=False,
82
+ reply_to=event.reply_to_msg_id,
83
+ )
84
+ os.remove("ok.mp4")
85
+ os.remove(x)
86
+ os.remove(ultt)
87
+ await xx.delete()
88
+
89
+
90
+ @ultroid_cmd(
91
+ pattern=r"dob ?(.*)",
92
+ )
93
+ async def hbd(event):
94
+ if not event.pattern_match.group(1):
95
+ await eor(event, "`Put input in dd/mm/yyyy format`")
96
+ return
97
+ if event.reply_to_msg_id:
98
+ kk = await event.get_reply_message()
99
+ nam = await ultroid_bot.get_entity(kk.from_id)
100
+ name = nam.first_name
101
+ else:
102
+ a = await ultroid_bot.get_me()
103
+ name = a.first_name
104
+ zn = pytz.timezone("Asia/Kolkata")
105
+ abhi = dt.now(zn)
106
+ n = event.text
107
+ q = n[5:]
108
+ p = n[5:7]
109
+ r = n[8:10]
110
+ s = n[11:]
111
+ day = int(p)
112
+ month = r
113
+ paida = q
114
+ jn = dt.strptime(paida, "%d/%m/%Y")
115
+ jnm = zn.localize(jn)
116
+ zinda = abhi - jnm
117
+ barsh = (zinda.total_seconds()) / (365.242 * 24 * 3600)
118
+ saal = int(barsh)
119
+ mash = (barsh - saal) * 12
120
+ mahina = int(mash)
121
+ divas = (mash - mahina) * (365.242 / 12)
122
+ din = int(divas)
123
+ samay = (divas - din) * 24
124
+ ghanta = int(samay)
125
+ pehl = (samay - ghanta) * 60
126
+ mi = int(pehl)
127
+ sec = (pehl - mi) * 60
128
+ slive = int(sec)
129
+ y = int(s) + int(saal) + 1
130
+ m = int(r)
131
+ brth = dt(y, m, day)
132
+ cm = dt(abhi.year, brth.month, brth.day)
133
+ ish = (cm - abhi.today()).days + 1
134
+ dan = ish
135
+ if dan == 0:
136
+ hp = "`Happy BirthDay To U🎉🎊`"
137
+ elif dan < 0:
138
+ okk = 365 + ish
139
+ hp = f"{okk} Days Left 🥳"
140
+ elif dan > 0:
141
+ hp = f"{ish} Days Left 🥳"
142
+ if month == "12":
143
+ sign = "Sagittarius" if (day < 22) else "Capricorn"
144
+ elif month == "01":
145
+ sign = "Capricorn" if (day < 20) else "Aquarius"
146
+ elif month == "02":
147
+ sign = "Aquarius" if (day < 19) else "Pisces"
148
+ elif month == "03":
149
+ sign = "Pisces" if (day < 21) else "Aries"
150
+ elif month == "04":
151
+ sign = "Aries" if (day < 20) else "Taurus"
152
+ elif month == "05":
153
+ sign = "Taurus" if (day < 21) else "Gemini"
154
+ elif month == "06":
155
+ sign = "Gemini" if (day < 21) else "Cancer"
156
+ elif month == "07":
157
+ sign = "Cancer" if (day < 23) else "Leo"
158
+ elif month == "08":
159
+ sign = "Leo" if (day < 23) else "Virgo"
160
+ elif month == "09":
161
+ sign = "Virgo" if (day < 23) else "Libra"
162
+ elif month == "10":
163
+ sign = "Libra" if (day < 23) else "Scorpion"
164
+ elif month == "11":
165
+ sign = "Scorpio" if (day < 22) else "Sagittarius"
166
+ sign = f"{sign}"
167
+ params = (("sign", sign), ("today", day))
168
+ response = requests.post("https://aztro.sameerkumar.website/", params=params)
169
+ json = response.json()
170
+ dd = json.get("current_date")
171
+ ds = json.get("description")
172
+ lt = json.get("lucky_time")
173
+ md = json.get("mood")
174
+ cl = json.get("color")
175
+ ln = json.get("lucky_number")
176
+ await event.delete()
177
+ await event.client.send_message(
178
+ event.chat_id,
179
+ f"""
180
+ Name -: {name}
181
+
182
+ D.O.B -: {paida}
183
+
184
+ Lived -: {saal}yr, {mahina}m, {din}d, {ghanta}hr, {mi}min, {slive}sec
185
+
186
+ Birthday -: {hp}
187
+
188
+ Zodiac -: {sign}
189
+
190
+ **Horoscope On {dd} -**
191
+
192
+ `{ds}`
193
+
194
+ Lucky Time :- {lt}
195
+ Lucky Number :- {ln}
196
+ Lucky Color :- {cl}
197
+ Mood :- {md}
198
+ """,
199
+ reply_to=event.reply_to_msg_id,
200
+ )
201
+
202
+
203
+ @ultroid_cmd(pattern="sticker ?(.*)")
204
+ async def _(event):
205
+ x = event.pattern_match.group(1)
206
+ if not x:
207
+ return await eor(event, "`Give something to search`")
208
+ uu = await eor(event, "`Processing...`")
209
+ z = requests.get("https://combot.org/telegram/stickers?q=" + x).text
210
+ xx = b(z, "lxml")
211
+ title = xx.find_all("div", "sticker-pack__title")
212
+ link = xx.find_all("a", {"class": "sticker-pack__btn"})
213
+ if not link:
214
+ return await uu.edit("Found Nothing")
215
+ a = "SᴛɪᴄᴋEʀs Aᴡᴀɪʟᴀʙʟᴇ ~"
216
+ for xxx, yyy in zip(title, link):
217
+ v = xxx.get_text()
218
+ w = yyy["href"]
219
+ d = f"\n\n[{v}]({w})"
220
+ if d not in a:
221
+ a += d
222
+ await uu.edit(a)
223
+
224
+
225
+ @ultroid_cmd(pattern="wall ?(.*)")
226
+ async def wall(event):
227
+ inp = event.pattern_match.group(1)
228
+ if not inp:
229
+ return await eor(event, "`Give something to search")
230
+ nn = await eor(event, "`Processing Keep Patience...`")
231
+ query = f"hd {inp}"
232
+ gi = googleimagesdownload()
233
+ args = {
234
+ "keywords": query,
235
+ "limit": 10,
236
+ "format": "jpg",
237
+ "output_directory": "./resources/downloads/",
238
+ }
239
+ gi.download(args)
240
+ xx = choice(os.listdir(os.path.abspath(f"./resources/downloads/{query}/")))
241
+ await event.client.send_file(event.chat_id, f"./resources/downloads/{query}/{xx}")
242
+ rmtree(f"./resources/downloads/{query}/")
243
+ await nn.delete()
244
+
245
+
246
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/stickertools.py ADDED
@@ -0,0 +1,524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}destroy <reply to animated sticker>`
12
+ To destroy the sticker.
13
+
14
+ • `{i}tiny <reply to media>`
15
+ To create Tiny stickers.
16
+
17
+ • `{i}convert <gif/img/sticker>`
18
+ Reply to animated sticker.
19
+
20
+ • `{i}kang <reply to image/sticker>`
21
+ Kang the sticker (add to your pack).
22
+
23
+ • `{i}round <reply to any media>`
24
+ To extract round sticker.
25
+
26
+ • `{i}waifu <text>`
27
+ paste text on random stickers.
28
+
29
+ """
30
+
31
+ import asyncio
32
+ import io
33
+ import os
34
+ import random
35
+ import re
36
+ import urllib.request
37
+ from os import remove
38
+
39
+ import cv2
40
+ import numpy as np
41
+ from PIL import Image, ImageDraw
42
+ from telethon.errors import ChatSendInlineForbiddenError, ChatSendStickersForbiddenError
43
+ from telethon.tl.types import (
44
+ DocumentAttributeFilename,
45
+ DocumentAttributeSticker,
46
+ MessageMediaPhoto,
47
+ )
48
+
49
+ from . import *
50
+
51
+ EMOJI_PATTERN = re.compile(
52
+ "["
53
+ "\U0001F1E0-\U0001F1FF" # flags (iOS)
54
+ "\U0001F300-\U0001F5FF" # symbols & pictographs
55
+ "\U0001F600-\U0001F64F" # emoticons
56
+ "\U0001F680-\U0001F6FF" # transport & map symbols
57
+ "\U0001F700-\U0001F77F" # alchemical symbols
58
+ "\U0001F780-\U0001F7FF" # Geometric Shapes Extended
59
+ "\U0001F800-\U0001F8FF" # Supplemental Arrows-C
60
+ "\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
61
+ "\U0001FA00-\U0001FA6F" # Chess Symbols
62
+ "\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
63
+ "\U00002702-\U000027B0" # Dingbats
64
+ "]+"
65
+ )
66
+
67
+
68
+ def deEmojify(inputString: str) -> str:
69
+ """Remove emojis and other non-safe characters from string"""
70
+ return re.sub(EMOJI_PATTERN, "", inputString)
71
+
72
+
73
+ @ultroid_cmd(
74
+ pattern="waifu ?(.*)",
75
+ )
76
+ async def waifu(animu):
77
+ xx = await eor(animu, "`Processing...`")
78
+ # """Creates random anime sticker!"""
79
+ text = animu.pattern_match.group(1)
80
+ if not text:
81
+ if animu.is_reply:
82
+ text = (await animu.get_reply_message()).message
83
+ else:
84
+ await xx.edit("`You haven't written any article, Waifu is going away.`")
85
+ return
86
+ animus = [0, 1, 3, 7, 9, 13, 22, 34, 35, 36, 37, 43, 44, 45, 52, 53, 55]
87
+ t1 = "#" + (str(random.choice(animus)))
88
+ animus2 = [0, 11, 12, 19, 20, 21, 22, 23, 28, 32, 33]
89
+ t2 = "$" + (str(random.choice(animus2)))
90
+ animus3 = [10, 14, 19]
91
+ t3 = "&" + (str(random.choice(animus3)))
92
+ animus4 = [0, 3, 9, 15]
93
+ t4 = "%" + (str(random.choice(animus4)))
94
+ t5 = "*" + (str(random.choice(animus4)))
95
+ # to increase probability of getting sticker from special category
96
+ finalcall = random.choice([t1, t2, t3, t4, t5, t1])
97
+ try:
98
+ sticcers = await ultroid_bot.inline_query(
99
+ "stickerizerbot", f"{finalcall}{(deEmojify(text))}"
100
+ )
101
+ await sticcers[0].click(
102
+ animu.chat_id,
103
+ reply_to=animu.reply_to_msg_id,
104
+ silent=True if animu.is_reply else False,
105
+ hide_via=True,
106
+ )
107
+ await xx.delete()
108
+ except ChatSendInlineForbiddenError:
109
+ await xx.edit("`Boss ! I cant use inline things here...`")
110
+ except ChatSendStickersForbiddenError:
111
+ await xx.edit("Sorry boss, I can't send Sticker Here !!")
112
+
113
+
114
+ @ultroid_cmd(
115
+ pattern="convert ?(.*)",
116
+ )
117
+ async def uconverter(event):
118
+ xx = await eor(event, "`Processing...`")
119
+ a = await event.get_reply_message()
120
+ input = event.pattern_match.group(1)
121
+ b = await event.client.download_media(a, "resources/downloads/")
122
+ if "gif" in input:
123
+ cmd = ["lottie_convert.py", b, "something.gif"]
124
+ file = "something.gif"
125
+ elif "sticker" in input:
126
+ cmd = ["lottie_convert.py", b, "something.webp"]
127
+ file = "something.webp"
128
+ elif "img" in input:
129
+ cmd = ["lottie_convert.py", b, "something.png"]
130
+ file = "something.png"
131
+ else:
132
+ await xx.edit("**Please select from gif/sticker/img**")
133
+ process = await asyncio.create_subprocess_exec(
134
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
135
+ )
136
+ stdout, stderr = await process.communicate()
137
+ stderr.decode().strip()
138
+ stdout.decode().strip()
139
+ os.remove(b)
140
+ await event.client.send_file(event.chat_id, file, force_document=False)
141
+ os.remove(file)
142
+ await xx.delete()
143
+
144
+
145
+ @ultroid_cmd(
146
+ pattern="kang",
147
+ )
148
+ async def hehe(args):
149
+ xx = await eor(args, "`Processing...`")
150
+ user = await ultroid_bot.get_me()
151
+ if not user.username:
152
+ user.username = user.first_name
153
+ message = await args.get_reply_message()
154
+ photo = None
155
+ emojibypass = False
156
+ is_anim = False
157
+ emoji = None
158
+ if message and message.media:
159
+ if isinstance(message.media, MessageMediaPhoto):
160
+ await xx.edit(f"`{random.choice(KANGING_STR)}`")
161
+ photo = io.BytesIO()
162
+ photo = await ultroid_bot.download_media(message.photo, photo)
163
+ elif "image" in message.media.document.mime_type.split("/"):
164
+ await xx.edit(f"`{random.choice(KANGING_STR)}`")
165
+ photo = io.BytesIO()
166
+ await ultroid_bot.download_file(message.media.document, photo)
167
+ if (
168
+ DocumentAttributeFilename(file_name="sticker.webp")
169
+ in message.media.document.attributes
170
+ ):
171
+ emoji = message.media.document.attributes[1].alt
172
+ emojibypass = True
173
+ elif "video" in message.media.document.mime_type.split("/"):
174
+ await xx.edit(f"`{random.choice(KANGING_STR)}`")
175
+ xy = await message.download_media()
176
+ y = cv2.VideoCapture(xy)
177
+ heh, lol = y.read()
178
+ cv2.imwrite("ult.webp", lol)
179
+ photo = "ult.webp"
180
+ elif "tgsticker" in message.media.document.mime_type:
181
+ await xx.edit(f"`{random.choice(KANGING_STR)}`")
182
+ await ultroid_bot.download_file(
183
+ message.media.document, "AnimatedSticker.tgs"
184
+ )
185
+
186
+ attributes = message.media.document.attributes
187
+ for attribute in attributes:
188
+ if isinstance(attribute, DocumentAttributeSticker):
189
+ emoji = attribute.alt
190
+
191
+ emojibypass = True
192
+ is_anim = True
193
+ photo = 1
194
+ else:
195
+ await xx.edit("`Unsupported File!`")
196
+ return
197
+ else:
198
+ await xx.edit("`I can't kang that...`")
199
+ return
200
+
201
+ if photo:
202
+ splat = args.text.split()
203
+ if not emojibypass:
204
+ emoji = "🔰"
205
+ pack = 1
206
+ if len(splat) == 3:
207
+ pack = splat[2] # User sent ultroid_both
208
+ emoji = splat[1]
209
+ elif len(splat) == 2:
210
+ if splat[1].isnumeric():
211
+ pack = int(splat[1])
212
+ else:
213
+ emoji = splat[1]
214
+
215
+ packname = f"ult_{user.id}_{pack}"
216
+ packnick = f"@{user.username}'s Pack {pack}"
217
+ cmd = "/newpack"
218
+ file = io.BytesIO()
219
+
220
+ if not is_anim:
221
+ image = await resize_photo(photo)
222
+ file.name = "sticker.png"
223
+ image.save(file, "PNG")
224
+ else:
225
+ packname += "_anim"
226
+ packnick += " (Animated)"
227
+ cmd = "/newanimated"
228
+
229
+ response = urllib.request.urlopen(
230
+ urllib.request.Request(f"http://t.me/addstickers/{packname}")
231
+ )
232
+ htmlstr = response.read().decode("utf8").split("\n")
233
+
234
+ if (
235
+ " A <strong>Telegram</strong> user has created the <strong>Sticker&nbsp;Set</strong>."
236
+ not in htmlstr
237
+ ):
238
+ async with ultroid_bot.conversation("Stickers") as conv:
239
+ await conv.send_message("/addsticker")
240
+ await conv.get_response()
241
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
242
+ await conv.send_message(packname)
243
+ x = await conv.get_response()
244
+ while "120" in x.text:
245
+ pack += 1
246
+ packname = f"ult_{user.id}_{pack}"
247
+ packnick = f"@{user.username}'s Pack {pack}"
248
+ await xx.edit(
249
+ "`Switching to Pack "
250
+ + str(pack)
251
+ + " due to insufficient space`"
252
+ )
253
+ await conv.send_message(packname)
254
+ x = await conv.get_response()
255
+ if x.text == "Invalid pack selected.":
256
+ await conv.send_message(cmd)
257
+ await conv.get_response()
258
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
259
+ await conv.send_message(packnick)
260
+ await conv.get_response()
261
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
262
+ if is_anim:
263
+ await conv.send_file("AnimatedSticker.tgs")
264
+ remove("AnimatedSticker.tgs")
265
+ else:
266
+ file.seek(0)
267
+ await conv.send_file(file, force_document=True)
268
+ await conv.get_response()
269
+ await conv.send_message(emoji)
270
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
271
+ await conv.get_response()
272
+ await conv.send_message("/publish")
273
+ if is_anim:
274
+ await conv.get_response()
275
+ await conv.send_message(f"<{packnick}>")
276
+ await conv.get_response()
277
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
278
+ await conv.send_message("/skip")
279
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
280
+ await conv.get_response()
281
+ await conv.send_message(packname)
282
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
283
+ await conv.get_response()
284
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
285
+ await xx.edit(
286
+ f"`Sticker added in a Different Pack !\
287
+ \nThis Pack is Newly created!\
288
+ \nYour pack can be found [here](t.me/addstickers/{packname})",
289
+ parse_mode="md",
290
+ )
291
+ return
292
+ if is_anim:
293
+ await conv.send_file("AnimatedSticker.tgs")
294
+ remove("AnimatedSticker.tgs")
295
+ else:
296
+ file.seek(0)
297
+ await conv.send_file(file, force_document=True)
298
+ rsp = await conv.get_response()
299
+ if "Sorry, the file type is invalid." in rsp.text:
300
+ await xx.edit(
301
+ "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`"
302
+ )
303
+ return
304
+ await conv.send_message(emoji)
305
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
306
+ await conv.get_response()
307
+ await conv.send_message("/done")
308
+ await conv.get_response()
309
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
310
+ else:
311
+ await xx.edit("`Brewing a new Pack...`")
312
+ async with ultroid_bot.conversation("Stickers") as conv:
313
+ await conv.send_message(cmd)
314
+ await conv.get_response()
315
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
316
+ await conv.send_message(packnick)
317
+ await conv.get_response()
318
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
319
+ if is_anim:
320
+ await conv.send_file("AnimatedSticker.tgs")
321
+ remove("AnimatedSticker.tgs")
322
+ else:
323
+ file.seek(0)
324
+ await conv.send_file(file, force_document=True)
325
+ rsp = await conv.get_response()
326
+ if "Sorry, the file type is invalid." in rsp.text:
327
+ await xx.edit(
328
+ "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`"
329
+ )
330
+ return
331
+ await conv.send_message(emoji)
332
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
333
+ await conv.get_response()
334
+ await conv.send_message("/publish")
335
+ if is_anim:
336
+ await conv.get_response()
337
+ await conv.send_message(f"<{packnick}>")
338
+
339
+ await conv.get_response()
340
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
341
+ await conv.send_message("/skip")
342
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
343
+ await conv.get_response()
344
+ await conv.send_message(packname)
345
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
346
+ await conv.get_response()
347
+ await ultroid_bot.send_read_acknowledge(conv.chat_id)
348
+ await xx.edit(
349
+ f"`Kanged!`\
350
+ \n`Emoji` - {emoji}\
351
+ \n`Sticker Pack` [here](t.me/addstickers/{packname})",
352
+ parse_mode="md",
353
+ )
354
+ try:
355
+ os.remove(photo)
356
+ except BaseException:
357
+ pass
358
+
359
+
360
+ @ultroid_cmd(
361
+ pattern="round$",
362
+ )
363
+ async def ultdround(event):
364
+ ureply = await event.get_reply_message()
365
+ xx = await eor(event, "`Processing...`")
366
+ if not (ureply and (ureply.media)):
367
+ await xx.edit("`Reply to any media`")
368
+ return
369
+ ultt = await ureply.download_media()
370
+ if ultt.endswith(".tgs"):
371
+ await xx.edit("`Ooo Animated Sticker 👀...`")
372
+ cmd = ["lottie_convert.py", ultt, "ult.png"]
373
+ file = "ult.png"
374
+ process = await asyncio.create_subprocess_exec(
375
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
376
+ )
377
+ stdout, stderr = await process.communicate()
378
+ stderr.decode().strip()
379
+ stdout.decode().strip()
380
+ elif ultt.endswith((".gif", ".mp4", ".mkv")):
381
+ await xx.edit("`Processing...`")
382
+ img = cv2.VideoCapture(ultt)
383
+ heh, lol = img.read()
384
+ cv2.imwrite("ult.png", lol)
385
+ file = "ult.png"
386
+ else:
387
+ file = ultt
388
+ img = Image.open(file).convert("RGB")
389
+ npImage = np.array(img)
390
+ h, w = img.size
391
+ alpha = Image.new("L", img.size, 0)
392
+ draw = ImageDraw.Draw(alpha)
393
+ draw.pieslice([0, 0, h, w], 0, 360, fill=255)
394
+ npAlpha = np.array(alpha)
395
+ npImage = np.dstack((npImage, npAlpha))
396
+ Image.fromarray(npImage).save("ult.webp")
397
+ await event.client.send_file(
398
+ event.chat_id, "ult.webp", force_document=False, reply_to=event.reply_to_msg_id
399
+ )
400
+ await xx.delete()
401
+ os.remove(file)
402
+ os.remove("ult.webp")
403
+ os.remove(ultt)
404
+
405
+
406
+ @ultroid_cmd(
407
+ pattern="destroy$",
408
+ )
409
+ async def ultdestroy(event):
410
+ ult = await event.get_reply_message()
411
+ if not (ult and ("tgsticker" in ult.media.document.mime_type)):
412
+ await eor(event, "`Reply to Animated Sticker Only...`")
413
+ return
414
+ roid = await event.client.download_media(ult, "ultroid.tgs")
415
+ xx = await eor(event, "`Processing...`")
416
+ os.system("lottie_convert.py ultroid.tgs json.json")
417
+ json = open("json.json", "r")
418
+ jsn = json.read()
419
+ json.close()
420
+ jsn = (
421
+ jsn.replace("[100]", "[200]")
422
+ .replace("[10]", "[40]")
423
+ .replace("[-1]", "[-10]")
424
+ .replace("[0]", "[15]")
425
+ .replace("[1]", "[20]")
426
+ .replace("[2]", "[17]")
427
+ .replace("[3]", "[40]")
428
+ .replace("[4]", "[37]")
429
+ .replace("[5]", "[60]")
430
+ .replace("[6]", "[70]")
431
+ .replace("[7]", "[40]")
432
+ .replace("[8]", "[37]")
433
+ .replace("[9]", "[110]")
434
+ )
435
+ open("json.json", "w").write(jsn)
436
+ os.system("lottie_convert.py json.json ultroid.tgs")
437
+ await event.client.send_file(
438
+ event.chat_id,
439
+ file="ultroid.tgs",
440
+ force_document=False,
441
+ reply_to=event.reply_to_msg_id,
442
+ )
443
+ await xx.delete()
444
+ os.remove("ultroid.tgs")
445
+ os.remove("json.json")
446
+ os.remove(roid)
447
+
448
+
449
+ @ultroid_cmd(
450
+ pattern="tiny$",
451
+ )
452
+ async def ultiny(event):
453
+ reply = await event.get_reply_message()
454
+ if not (reply and (reply.media)):
455
+ await eor(event, "`Reply To Media`")
456
+ return
457
+ xx = await eor(event, "`processing...`")
458
+ ik = await ultroid_bot.download_media(reply)
459
+ im1 = Image.open("resources/extras/ultroid_blank.png")
460
+ if ik.endswith(".tgs"):
461
+ await event.client.download_media(reply, "ult.tgs")
462
+ os.system("lottie_convert.py ult.tgs json.json")
463
+ json = open("json.json", "r")
464
+ jsn = json.read()
465
+ json.close()
466
+ jsn = jsn.replace("512", "2000")
467
+ open("json.json", "w").write(jsn)
468
+ os.system("lottie_convert.py json.json ult.tgs")
469
+ file = "ult.tgs"
470
+ os.remove("json.json")
471
+ elif ik.endswith((".gif", ".mp4")):
472
+ iik = cv2.VideoCapture(ik)
473
+ dani, busy = iik.read()
474
+ cv2.imwrite("i.png", busy)
475
+ fil = "i.png"
476
+ im = Image.open(fil)
477
+ z, d = im.size
478
+ if z == d:
479
+ xxx, yyy = 200, 200
480
+ else:
481
+ t = z + d
482
+ a = z / t
483
+ b = d / t
484
+ aa = (a * 100) - 50
485
+ bb = (b * 100) - 50
486
+ xxx = 200 + 5 * aa
487
+ yyy = 200 + 5 * bb
488
+ k = im.resize((int(xxx), int(yyy)))
489
+ k.save("k.png", format="PNG", optimize=True)
490
+ im2 = Image.open("k.png")
491
+ back_im = im1.copy()
492
+ back_im.paste(im2, (150, 0))
493
+ back_im.save("o.webp", "WEBP", quality=95)
494
+ file = "o.webp"
495
+ os.remove(fil)
496
+ os.remove("k.png")
497
+ else:
498
+ im = Image.open(ik)
499
+ z, d = im.size
500
+ if z == d:
501
+ xxx, yyy = 200, 200
502
+ else:
503
+ t = z + d
504
+ a = z / t
505
+ b = d / t
506
+ aa = (a * 100) - 50
507
+ bb = (b * 100) - 50
508
+ xxx = 200 + 5 * aa
509
+ yyy = 200 + 5 * bb
510
+ k = im.resize((int(xxx), int(yyy)))
511
+ k.save("k.png", format="PNG", optimize=True)
512
+ im2 = Image.open("k.png")
513
+ back_im = im1.copy()
514
+ back_im.paste(im2, (150, 0))
515
+ back_im.save("o.webp", "WEBP", quality=95)
516
+ file = "o.webp"
517
+ os.remove("k.png")
518
+ await event.client.send_file(event.chat_id, file, reply_to=event.reply_to_msg_id)
519
+ await xx.delete()
520
+ os.remove(file)
521
+ os.remove(ik)
522
+
523
+
524
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/sudo.py ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}addsudo`
12
+ Add Sudo Users by replying to user or using <space> separated userid(s)
13
+
14
+ • `{i}delsudo`
15
+ Remove Sudo Users by replying to user or using <space> separated userid(s)
16
+
17
+ • `{i}listsudo`
18
+ List all sudo users.
19
+ """
20
+
21
+ import re
22
+
23
+ from telethon.tl.functions.users import GetFullUserRequest
24
+
25
+ from . import *
26
+
27
+
28
+ @ultroid_cmd(
29
+ pattern="addsudo ?(.*)",
30
+ )
31
+ async def _(ult):
32
+ ok = await eor(ult, "`Updating SUDO Users List ...`")
33
+
34
+ if ult.reply_to_msg_id:
35
+ replied_to = await ult.get_reply_message()
36
+ id = replied_to.sender.id
37
+ user = await ult.client(GetFullUserRequest(int(id)))
38
+ sed.append(id)
39
+ if id == ultroid_bot.me.id:
40
+ return await ok.edit("You cant add yourself as Sudo User...")
41
+ elif is_sudo(id):
42
+ return await ok.edit(
43
+ f"[{user.user.first_name}](tg://user?id={id}) `is already a SUDO User ...`"
44
+ )
45
+ elif add_sudo(id):
46
+ return await ok.edit(
47
+ f"**Added [{user.user.first_name}](tg://user?id={id}) as SUDO User**"
48
+ )
49
+ else:
50
+ return await ok.edit("`SEEMS LIKE THIS FUNCTION CHOOSE TO BROKE ITSELF`")
51
+
52
+ args = ult.pattern_match.group(1).strip()
53
+
54
+ if re.search(r"[\s]", args) is not None:
55
+ args = args.split(" ")
56
+ msg = ""
57
+ sudos = get_sudos()
58
+ for item in args:
59
+ user = ""
60
+ try:
61
+ user = await ult.client(GetFullUserRequest(int(item)))
62
+ except BaseException:
63
+ pass
64
+ if not hasattr(user, "user"):
65
+ msg += f"• `{item}` __Invalid UserID__\n"
66
+ elif item in sudos:
67
+ msg += f"• [{user.user.first_name}](tg://user?id={item}) __Already a SUDO__\n"
68
+ elif add_sudo(item.strip()):
69
+ msg += (
70
+ f"• [{user.user.first_name}](tg://user?id={item}) __Added SUDO__\n"
71
+ )
72
+ else:
73
+ msg += f"• `{item}` __Failed to Add SUDO__\n"
74
+ return await ok.edit(f"**Adding Sudo Users :**\n{msg}")
75
+
76
+ id = args.strip()
77
+ user = ""
78
+
79
+ try:
80
+ user = await ult.client(GetFullUserRequest(int(i)))
81
+ except BaseException:
82
+ pass
83
+
84
+ if not id.isdigit():
85
+ return await ok.edit("`Integer(s) Expected`")
86
+ elif not hasattr(user, "user"):
87
+ return await ok.edit("`Invalid UserID`")
88
+ elif is_sudo(id):
89
+ return await ok.edit(
90
+ f"[{user.user.first_name}](tg://user?id={id}) `is already a SUDO User ...`"
91
+ )
92
+ elif add_sudo(id):
93
+ return await ok.edit(
94
+ f"**Added [{user.user.first_name}](tg://user?id={id}) as SUDO User**"
95
+ )
96
+ else:
97
+ return await ok.edit(f"**Failed to add `{id}` as SUDO User ... **")
98
+
99
+
100
+ @ultroid_cmd(
101
+ pattern="delsudo ?(.*)",
102
+ )
103
+ async def _(ult):
104
+ ok = await eor(ult, "`Updating SUDO Users List ...`")
105
+
106
+ if ult.reply_to_msg_id:
107
+ replied_to = await ult.get_reply_message()
108
+ id = replied_to.sender.id
109
+ user = await ult.client(GetFullUserRequest(int(id)))
110
+ sed.remove(id)
111
+ if not is_sudo(id):
112
+ return await ok.edit(
113
+ f"[{user.user.first_name}](tg://user?id={id}) `wasn't a SUDO User ...`"
114
+ )
115
+ elif del_sudo(id):
116
+ return await ok.edit(
117
+ f"**Removed [{user.user.first_name}](tg://user?id={id}) from SUDO User(s)**"
118
+ )
119
+ else:
120
+ return await ok.edit("`SEEMS LIKE THIS FUNCTION CHOOSE TO BROKE ITSELF`")
121
+
122
+ args = ult.pattern_match.group(1)
123
+
124
+ if re.search(r"[\s]", args) is not None:
125
+ args = args.split(" ")
126
+ msg = ""
127
+ sudos = get_sudos()
128
+ for item in args:
129
+ user = ""
130
+ try:
131
+ user = await ult.client(GetFullUserRequest(int(item)))
132
+ except BaseException:
133
+ pass
134
+ if not hasattr(user, "user"):
135
+ msg += f"• `{item}` __Invalid UserID__\n"
136
+ elif item in sudos and del_sudo(item):
137
+ msg += (
138
+ f"• [{user.user.first_name}](tg://user?id={id}) __Removed SUDO__\n"
139
+ )
140
+ elif item not in sudos:
141
+ msg += (
142
+ f"• [{user.user.first_name}](tg://user?id={id}) __Wasn't a SUDO__\n"
143
+ )
144
+ else:
145
+ msg += f"• `{item}` __Failed to Remove SUDO__\n"
146
+ return await ok.edit(msg)
147
+
148
+ id = args.strip()
149
+ user = ""
150
+
151
+ try:
152
+ user = await ult.client(GetFullUserRequest(int(i)))
153
+ except BaseException:
154
+ pass
155
+
156
+ if not id.isdigit():
157
+ return await ok.edit("`Integer(s) Expected`")
158
+ elif not hasattr(user, "user"):
159
+ return await ok.edit("`Invalid UserID`")
160
+ elif not is_sudo(id):
161
+ return await ok.edit(
162
+ f"[{user.user.first_name}](tg://user?id={id}) wasn't a SUDO user ..."
163
+ )
164
+ elif del_sudo(id):
165
+ return await ok.edit(
166
+ f"**Removed [{user.user.first_name}](tg://user?id={id}) from SUDO User**"
167
+ )
168
+ else:
169
+ return await ok.edit(f"**Failed to Remove `{id}` as SUDO User ... **")
170
+
171
+
172
+ @ultroid_cmd(
173
+ pattern="listsudo$",
174
+ )
175
+ async def _(ult):
176
+ ok = await eor(ult, "`...")
177
+ sudos = get_sudos()
178
+ if "" in sudos:
179
+ return await ok.edit("`No SUDO User was assigned ...`")
180
+ msg = ""
181
+ for i in sudos:
182
+ user = ""
183
+ try:
184
+ user = await ok.client(GetFullUserRequest(int(i.strip())))
185
+ except BaseException:
186
+ pass
187
+ if hasattr(user, "user"):
188
+ msg += f"• [{user.user.first_name}](tg://user?id={i}) ( `{i}` )\n"
189
+ else:
190
+ msg += f"• `{i}` -> Invalid User\n"
191
+ return await ok.edit(f"**List of SUDO Users :**\n{msg}")
192
+
193
+
194
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/superfban.py ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}superfban <reply to user/userid/username>`
12
+ FBan the person across all feds in which you are admin.
13
+
14
+ • `{i}superunfban <reply to user/userid/username>`
15
+ Un-FBan the person across all feds in which you are admin.
16
+
17
+ Specify FBan Group and Feds to exclude in the assistant.
18
+ """
19
+
20
+ import asyncio
21
+ import os
22
+
23
+ from . import *
24
+
25
+
26
+ @ultroid_cmd(pattern="superfban ?(.*)")
27
+ async def _(event):
28
+ msg = await eor(event, "Starting a Mass-FedBan...")
29
+ fedList = []
30
+ if event.reply_to_msg_id:
31
+ previous_message = await event.get_reply_message()
32
+ if previous_message.media:
33
+ downloaded_file_name = await ultroid_bot.download_media(
34
+ previous_message, "fedlist"
35
+ )
36
+ file = open(downloaded_file_name, encoding="utf8")
37
+ lines = file.readlines()
38
+ for line in lines:
39
+ try:
40
+ fedList.append(line[:36])
41
+ except BaseException:
42
+ pass
43
+ arg = event.text.split(" ", maxsplit=2)
44
+ if len(arg) > 2:
45
+ FBAN = arg[1]
46
+ REASON = arg[2]
47
+ else:
48
+ FBAN = arg[1]
49
+ REASON = " #TBMassBanned "
50
+ else:
51
+ FBAN = previous_message.sender_id
52
+ try:
53
+ REASON = event.text.split(" ", maxsplit=1)[1]
54
+ except BaseException:
55
+ REASON = ""
56
+ if REASON.strip() == "":
57
+ REASON = " #TBMassBanned "
58
+ else:
59
+ arg = event.text.split(" ", maxsplit=2)
60
+ if len(arg) > 2:
61
+ try:
62
+ FBAN = arg[1]
63
+ REASON = arg[2]
64
+ except BaseException:
65
+ return await msg.edit("`No user designated!`")
66
+ else:
67
+ try:
68
+ FBAN = arg[1]
69
+ REASON = " #TBMassBanned "
70
+ except BaseException:
71
+ return await msg.edit("`No user designated!`")
72
+ try:
73
+ if str(FBAN) in DEVLIST:
74
+ await msg.edit("You can't ban my dev you noob!!")
75
+ return
76
+ elif FBAN.startswith("@"):
77
+ try:
78
+ x = await ultroid_bot(GetFullUserRequest(FBAN))
79
+ uid = x.user.id
80
+ if str(uid) in DEVLIST:
81
+ await msg.edit("You can't ban my dev you noob!!")
82
+ return
83
+ except Exception as e:
84
+ print(str(e))
85
+ return await msg.edit(str(e))
86
+ except Exception as e:
87
+ print(str(e))
88
+ return await msg.edit(str(e))
89
+ if udB.get("FBAN_GROUP_ID"):
90
+ chat = int(udB.get("FBAN_GROUP_ID"))
91
+ else:
92
+ chat = await event.get_chat()
93
+ if not len(fedList):
94
+ for a in range(3):
95
+ async with ultroid_bot.conversation("@MissRose_bot") as bot_conv:
96
+ await bot_conv.send_message("/start")
97
+ await asyncio.sleep(3)
98
+ await bot_conv.send_message("/myfeds")
99
+ await asyncio.sleep(3)
100
+ try:
101
+ response = await bot_conv.get_response()
102
+ except asyncio.exceptions.TimeoutError:
103
+ return await msg.edit(
104
+ "`Seems like rose isn't responding, or, the plugin is misbehaving`"
105
+ )
106
+ await asyncio.sleep(3)
107
+ if "make a file" in response.text or "Looks like" in response.text:
108
+ await response.click(0)
109
+ await asyncio.sleep(3)
110
+ fedfile = await bot_conv.get_response()
111
+ await asyncio.sleep(3)
112
+ if fedfile.media:
113
+ downloaded_file_name = await ultroid_bot.download_media(
114
+ fedfile, "fedlist"
115
+ )
116
+ await asyncio.sleep(6)
117
+ file = open(downloaded_file_name, "r", errors="ignore")
118
+ lines = file.readlines()
119
+ for line in lines:
120
+ try:
121
+ fedList.append(line[:36])
122
+ except BaseException:
123
+ pass
124
+ elif "You can only use fed commands once every 5 minutes" in (
125
+ await bot_conv.get_edit
126
+ ):
127
+ await msg.edit("Try again after 5 mins.")
128
+ return
129
+ if len(fedList) == 0:
130
+ await msg.edit(
131
+ f"Unable to collect FedAdminList. Retrying ({a+1}/3)..."
132
+ )
133
+ else:
134
+ break
135
+ else:
136
+ await msg.edit("Error")
137
+ In = False
138
+ tempFedId = ""
139
+ for x in response.text:
140
+ if x == "`":
141
+ if In:
142
+ In = False
143
+ fedList.append(tempFedId)
144
+ tempFedId = ""
145
+ else:
146
+ In = True
147
+ elif In:
148
+ tempFedId += x
149
+ if len(fedList) == 0:
150
+ await msg.edit("Unable to collect FedAdminList.")
151
+ return
152
+ await msg.edit(f"FBaning in {len(fedList)} feds.")
153
+ try:
154
+ await ultroid_bot.send_message(chat, f"/start")
155
+ except BaseException:
156
+ await msg.edit("Specified FBan Group ID is incorrect.")
157
+ return
158
+ await asyncio.sleep(3)
159
+ if udB.get("EXCLUDE_FED"):
160
+ excludeFed = udB.get("EXCLUDE_FED").split(" ")
161
+ for n in range(len(excludeFed)):
162
+ excludeFed[n] = excludeFed[n].strip()
163
+ exCount = 0
164
+ for fed in fedList:
165
+ if udB.get("EXCLUDE_FED") and fed in excludeFed:
166
+ await ultroid_bot.send_message(chat, f"{fed} Excluded.")
167
+ exCount += 1
168
+ continue
169
+ await ultroid_bot.send_message(chat, f"/joinfed {fed}")
170
+ await asyncio.sleep(3)
171
+ await ultroid_bot.send_message(chat, f"/fban {FBAN} {REASON}")
172
+ await asyncio.sleep(3)
173
+ try:
174
+ os.remove("fedlist")
175
+ except Exception as e:
176
+ print(f"Error in removing FedAdmin file.\n{str(e)}")
177
+ await msg.edit(
178
+ f"SuperFBan Completed.\nTotal Feds - {len(fedlist)}.\nExcluded - {exCount}.\n Affected {len(fedList) - exCount} feds.\n#TB"
179
+ )
180
+
181
+
182
+ @ultroid_cmd(pattern="superunfban ?(.*)")
183
+ async def _(event):
184
+ msg = await eor(event, "Starting a Mass-UnFedBan...")
185
+ fedList = []
186
+ if event.reply_to_msg_id:
187
+ previous_message = await event.get_reply_message()
188
+ if previous_message.media:
189
+ downloaded_file_name = await ultroid_bot.download_media(
190
+ previous_message, "fedlist"
191
+ )
192
+ file = open(downloaded_file_name, encoding="utf8")
193
+ lines = file.readlines()
194
+ for line in lines:
195
+ try:
196
+ fedList.append(line[:36])
197
+ except BaseException:
198
+ pass
199
+ arg = event.text.split(" ", maxsplit=2)
200
+ if len(arg) > 2:
201
+ FBAN = arg[1]
202
+ REASON = arg[2] # rose unbans now can have reasons
203
+ else:
204
+ FBAN = arg[1]
205
+ REASON = ""
206
+ else:
207
+ FBAN = previous_message.sender_id
208
+ try:
209
+ REASON = event.text.split(" ", maxsplit=1)[1]
210
+ except BaseException:
211
+ REASON = ""
212
+ if REASON.strip() == "":
213
+ REASON = ""
214
+ else:
215
+ arg = event.text.split(" ", maxsplit=2)
216
+ if len(arg) > 2:
217
+ try:
218
+ FBAN = arg[1]
219
+ REASON = arg[2]
220
+ except BaseException:
221
+ return await msg.edit("`No user designated!`")
222
+ else:
223
+ try:
224
+ FBAN = arg[1]
225
+ REASON = " #TBMassUnBanned "
226
+ except BaseException:
227
+ return await msg.edit("`No user designated!`")
228
+ try:
229
+ if str(FBAN) in DEVLIST:
230
+ await msg.edit("You can't ban my dev you noob!!")
231
+ return
232
+ except Exception as e:
233
+ print(str(e))
234
+ return await msg.edit(str(e))
235
+ if udB.get("FBAN_GROUP_ID"):
236
+ chat = int(udB.get("FBAN_GROUP_ID"))
237
+ else:
238
+ chat = await event.get_chat()
239
+ if not len(fedList):
240
+ for a in range(3):
241
+ async with ultroid_bot.conversation("@MissRose_bot") as bot_conv:
242
+ await bot_conv.send_message("/start")
243
+ await asyncio.sleep(3)
244
+ await bot_conv.send_message("/myfeds")
245
+ await asyncio.sleep(3)
246
+ try:
247
+ response = await bot_conv.get_response()
248
+ except asyncio.exceptions.TimeoutError:
249
+ return await msg.edit(
250
+ "`Seems like rose isn't responding, or, the plugin is misbehaving`"
251
+ )
252
+ await asyncio.sleep(3)
253
+ if "make a file" in response.text or "Looks like" in response.text:
254
+ await response.click(0)
255
+ await asyncio.sleep(3)
256
+ fedfile = await bot_conv.get_response()
257
+ await asyncio.sleep(3)
258
+ if fedfile.media:
259
+ downloaded_file_name = await ultroid_bot.download_media(
260
+ fedfile, "fedlist"
261
+ )
262
+ await asyncio.sleep(6)
263
+ file = open(downloaded_file_name, "r", errors="ignore")
264
+ lines = file.readlines()
265
+ for line in lines:
266
+ try:
267
+ fedList.append(line[:36])
268
+ except BaseException:
269
+ pass
270
+ elif "You can only use fed commands once every 5 minutes" in (
271
+ await bot_conv.get_edit
272
+ ):
273
+ await msg.edit("Try again after 5 mins.")
274
+ return
275
+ if len(fedList) == 0:
276
+ await msg.edit(
277
+ f"Unable to collect FedAdminList. Retrying ({a+1}/3)..."
278
+ )
279
+ else:
280
+ break
281
+ else:
282
+ await msg.edit("Error")
283
+ In = False
284
+ tempFedId = ""
285
+ for x in response.text:
286
+ if x == "`":
287
+ if In:
288
+ In = False
289
+ fedList.append(tempFedId)
290
+ tempFedId = ""
291
+ else:
292
+ In = True
293
+ elif In:
294
+ tempFedId += x
295
+ if len(fedList) == 0:
296
+ await msg.edit("Unable to collect FedAdminList.")
297
+ return
298
+ await msg.edit(f"UnFBaning in {len(fedList)} feds.")
299
+ try:
300
+ await ultroid_bot.send_message(chat, f"/start")
301
+ except BaseException:
302
+ await msg.edit("Specified FBan Group ID is incorrect.")
303
+ return
304
+ await asyncio.sleep(3)
305
+ if udB.get("EXCLUDE_FED"):
306
+ excludeFed = udB.get("EXCLUDE_FED").split(" ")
307
+ for n in range(len(excludeFed)):
308
+ excludeFed[n] = excludeFed[n].strip()
309
+ exCount = 0
310
+ for fed in fedList:
311
+ if udB.get("EXCLUDE_FED") and fed in excludeFed:
312
+ await ultroid_bot.send_message(chat, f"{fed} Excluded.")
313
+ exCount += 1
314
+ continue
315
+ await ultroid_bot.send_message(chat, f"/joinfed {fed}")
316
+ await asyncio.sleep(3)
317
+ await ultroid_bot.send_message(chat, f"/unfban {FBAN} {REASON}")
318
+ await asyncio.sleep(3)
319
+ try:
320
+ os.remove("fedlist")
321
+ except Exception as e:
322
+ print(f"Error in removing FedAdmin file.\n{str(e)}")
323
+ await msg.edit(
324
+ f"SuperUnFBan Completed.\nTotal Feds - {len(fedlist)}.\nExcluded - {exCount}.\n Affected {len(fedList) - exCount} feds.\n#TB"
325
+ )
326
+
327
+
328
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/tools.py ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}bash <cmds>`
12
+ Run linux commands on telegram.
13
+
14
+ • `{i}eval <cmds>`
15
+ Evaluate python commands on telegram.
16
+
17
+ • `{i}circle`
18
+ Reply to a audio song or gif to get video note.
19
+
20
+ • `{i}bots`
21
+ Shows the number of bots in the current chat with their perma-link.
22
+
23
+ • `{i}hl`
24
+ {i}hl <link> hyperlinks the message by editing the message with a blank text.
25
+
26
+ • `{i}id`
27
+ Reply a Sticker to Get Its Id
28
+ Reply a User to Get His Id
29
+ Without Replying You Will Get the Chat's Id
30
+
31
+ • `{i}sg`
32
+ Reply The User to Get His Name History
33
+
34
+ • `{i}tr <dest lang code> <input>`
35
+ Reply to a message with `{i}tr <lang code>`
36
+ Use `{i}tr <dest lang code> <input>`
37
+ To get translated message.
38
+ """
39
+
40
+ import asyncio
41
+ import io
42
+ import sys
43
+ import time
44
+ import traceback
45
+ from asyncio.exceptions import TimeoutError
46
+
47
+ import cv2
48
+ import emoji
49
+ from googletrans import Translator
50
+ from telethon.errors.rpcerrorlist import YouBlockedUserError
51
+ from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantsBots
52
+ from telethon.utils import pack_bot_file_id
53
+
54
+ from . import *
55
+
56
+
57
+ @ultroid_cmd(
58
+ pattern="tr",
59
+ )
60
+ async def _(event):
61
+ input = event.text[4:6]
62
+ txt = event.text[7:]
63
+ xx = await eor(event, "`Translating...`")
64
+ if event.reply_to_msg_id:
65
+ previous_message = await event.get_reply_message()
66
+ text = previous_message.message
67
+ lan = input or "en"
68
+ elif input:
69
+ text = txt
70
+ lan = input or "en"
71
+ else:
72
+ return await eod(xx, f"`{hndlr}tr LanguageCode` as reply to a message", time=5)
73
+ text = emoji.demojize(text.strip())
74
+ lan = lan.strip()
75
+ translator = Translator()
76
+ try:
77
+ tt = translator.translate(text, dest=lan)
78
+ output_str = f"**TRANSLATED** from {tt.src} to {lan}\n{tt.text}"
79
+ await eod(xx, output_str)
80
+ except Exception as exc:
81
+ await eod(xx, str(exc), time=10)
82
+
83
+
84
+ @ultroid_cmd(
85
+ pattern="id$",
86
+ )
87
+ async def _(event):
88
+ if event.reply_to_msg_id:
89
+ await event.get_input_chat()
90
+ r_msg = await event.get_reply_message()
91
+ if r_msg.media:
92
+ bot_api_file_id = pack_bot_file_id(r_msg.media)
93
+ await eor(
94
+ event,
95
+ "**Current Chat ID:** `{}`\n**From User ID:** `{}`\n**Bot API File ID:** `{}`".format(
96
+ str(event.chat_id), str(r_msg.sender.id), bot_api_file_id
97
+ ),
98
+ )
99
+ else:
100
+ await eor(
101
+ event,
102
+ "**Chat ID:** `{}`\n**User ID:** `{}`".format(
103
+ str(event.chat_id), str(r_msg.sender.id)
104
+ ),
105
+ )
106
+ else:
107
+ await eor(event, "**Current Chat ID:** `{}`".format(str(event.chat_id)))
108
+
109
+
110
+ @ultroid_cmd(pattern="bots ?(.*)")
111
+ async def _(ult):
112
+ mentions = "**Bots in this Chat**: \n"
113
+ input_str = ult.pattern_match.group(1)
114
+ to_write_chat = await ult.get_input_chat()
115
+ chat = None
116
+ if not input_str:
117
+ chat = to_write_chat
118
+ else:
119
+ mentions = "**Bots in **{}: \n".format(input_str)
120
+ try:
121
+ chat = await ultroid_bot.get_entity(input_str)
122
+ except Exception as e:
123
+ await eor(ult, str(e))
124
+ return None
125
+ try:
126
+ async for x in ultroid_bot.iter_participants(
127
+ chat, filter=ChannelParticipantsBots
128
+ ):
129
+ if isinstance(x.participant, ChannelParticipantAdmin):
130
+ mentions += "\n ⚜️ [{}](tg://user?id={}) `{}`".format(
131
+ x.first_name, x.id, x.id
132
+ )
133
+ else:
134
+ mentions += "\n [{}](tg://user?id={}) `{}`".format(
135
+ x.first_name, x.id, x.id
136
+ )
137
+ except Exception as e:
138
+ mentions += " " + str(e) + "\n"
139
+ await eod(ult, mentions)
140
+
141
+
142
+ @ultroid_cmd(pattern="hl")
143
+ async def _(ult):
144
+ try:
145
+ input = ult.text.split(" ", maxsplit=1)[1]
146
+ except IndexError:
147
+ return await eod(ult, "`Input some link`", time=5)
148
+ await eod(ult, "[ㅤㅤㅤㅤㅤㅤㅤ](" + input + ")", link_preview=False)
149
+
150
+
151
+ @ultroid_cmd(
152
+ pattern="circle$",
153
+ )
154
+ async def _(e):
155
+ a = await e.get_reply_message()
156
+ if a is None:
157
+ return await eor(e, "Reply to a gif or audio")
158
+ if a.document and a.document.mime_type == "audio/mpeg":
159
+ z = await eor(e, "**Cʀᴇᴀᴛɪɴɢ Vɪᴅᴇᴏ Nᴏᴛᴇ**")
160
+ toime = time.time()
161
+ try:
162
+ bbbb = await a.download_media(thumb=-1)
163
+ im = cv2.imread(bbbb)
164
+ dsize = (320, 320)
165
+ output = cv2.resize(im, dsize, interpolation=cv2.INTER_AREA)
166
+ cv2.imwrite("img.png", output)
167
+ thumb = "img.png"
168
+ except TypeError:
169
+ thumb = "./resources/extras/thumb.jpg"
170
+ c = await a.download_media(
171
+ "resources/downloads/",
172
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
173
+ progress(d, t, z, toime, "**Dᴏᴡɴʟᴏᴀᴅɪɴɢ...**")
174
+ ),
175
+ )
176
+ await z.edit("**Dᴏᴡɴʟᴏᴀᴅᴇᴅ...\nNᴏᴡ Cᴏɴᴠᴇʀᴛɪɴɢ...**")
177
+ cmd = [
178
+ "ffmpeg",
179
+ "-i",
180
+ c,
181
+ "-acodec",
182
+ "libmp3lame",
183
+ "-ac",
184
+ "2",
185
+ "-ab",
186
+ "144k",
187
+ "-ar",
188
+ "44100",
189
+ "comp.mp3",
190
+ ]
191
+ proess = await asyncio.create_subprocess_exec(
192
+ *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
193
+ )
194
+ stdout, stderr = await proess.communicate()
195
+ stderr.decode().strip()
196
+ stdout.decode().strip()
197
+ mcd = [
198
+ "ffmpeg",
199
+ "-y",
200
+ "-i",
201
+ thumb,
202
+ "-i",
203
+ "comp.mp3",
204
+ "-c:a",
205
+ "copy",
206
+ "circle.mp4",
207
+ ]
208
+ process = await asyncio.create_subprocess_exec(
209
+ *mcd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
210
+ )
211
+ stdout, stderr = await process.communicate()
212
+ stderr.decode().strip()
213
+ stdout.decode().strip()
214
+ taime = time.time()
215
+ await e.client.send_file(
216
+ e.chat_id,
217
+ "circle.mp4",
218
+ thumb=thumb,
219
+ video_note=True,
220
+ reply_to=a,
221
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
222
+ progress(d, t, z, taime, "**Uᴘʟᴏᴀᴅɪɴɢ...**")
223
+ ),
224
+ )
225
+ await z.delete()
226
+ os.system("rm resources/downloads/*")
227
+ os.system("rm circle.mp4 comp.mp3 img.png")
228
+ os.remove(bbbb)
229
+ elif a.document and a.document.mime_type == "video/mp4":
230
+ z = await eor(e, "**Cʀᴇᴀᴛɪɴɢ Vɪᴅᴇᴏ Nᴏᴛᴇ**")
231
+ c = await a.download_media("resources/downloads/")
232
+ await e.client.send_file(e.chat_id, c, video_note=True, reply_to=a)
233
+ await z.delete()
234
+ os.remove(c)
235
+ else:
236
+ return await eor(e, "**Reply to a gif or audio file only**")
237
+
238
+
239
+ @ultroid_cmd(
240
+ pattern="bash",
241
+ )
242
+ async def _(event):
243
+ if (Var.I_DEV if Var.I_DEV else Redis("I_DEV")) != "True":
244
+ await eor(
245
+ event,
246
+ "Developer Restricted!\nIf you know what this does, and want to proceed\n\n set var `I_DEV` as `True`\n\nThis Might Be Dangerous.",
247
+ )
248
+ return
249
+ xx = await eor(event, "`Processing...`")
250
+ try:
251
+ cmd = event.text.split(" ", maxsplit=1)[1]
252
+ except IndexError:
253
+ return await eod(xx, "`No cmd given`", time=10)
254
+ reply_to_id = event.message.id
255
+ if event.reply_to_msg_id:
256
+ reply_to_id = event.reply_to_msg_id
257
+ time.time() + 100
258
+ process = await asyncio.create_subprocess_shell(
259
+ cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
260
+ )
261
+ stdout, stderr = await process.communicate()
262
+ OUT = f"**☞ BASH\n\n• COMMAND:**\n`{cmd}` \n\n"
263
+ e = stderr.decode()
264
+ if e:
265
+ OUT += f"**• ERROR:** \n`{e}`\n"
266
+ o = stdout.decode()
267
+ if not o and not e:
268
+ o = "Success"
269
+ OUT += f"**• OUTPUT:**\n`{o}`"
270
+ else:
271
+ _o = o.split("\n")
272
+ o = "`\n".join(_o)
273
+ OUT += f"**• OUTPUT:**\n{o}"
274
+ if len(OUT) > 4096:
275
+ with io.BytesIO(str.encode(OUT)) as out_file:
276
+ out_file.name = "bash.txt"
277
+ await event.client.send_file(
278
+ event.chat_id,
279
+ out_file,
280
+ force_document=True,
281
+ allow_cache=False,
282
+ caption=f"`{cmd}`",
283
+ reply_to=reply_to_id,
284
+ )
285
+ await xx.delete()
286
+ else:
287
+ await eod(xx, OUT)
288
+
289
+
290
+ @ultroid_cmd(
291
+ pattern="eval",
292
+ )
293
+ async def _(event):
294
+ if (Var.I_DEV if Var.I_DEV else Redis("I_DEV")) != "True":
295
+ await eor(
296
+ event,
297
+ "Developer Restricted!\nIf you know what this does, and want to proceed\n\n set var `I_DEV` as `True`\n\nThis Might Be Dangerous.",
298
+ )
299
+ return
300
+ xx = await eor(event, "`Processing ...`")
301
+ try:
302
+ cmd = event.text.split(" ", maxsplit=1)[1]
303
+ except IndexError:
304
+ return await eod(xx, "`Give some python cmd`", time=5)
305
+ if event.reply_to_msg_id:
306
+ reply_to_id = event.reply_to_msg_id
307
+ old_stderr = sys.stderr
308
+ old_stdout = sys.stdout
309
+ redirected_output = sys.stdout = io.StringIO()
310
+ redirected_error = sys.stderr = io.StringIO()
311
+ stdout, stderr, exc = None, None, None
312
+ reply_to_id = event.message.id
313
+ try:
314
+ await aexec(cmd, event)
315
+ except Exception:
316
+ exc = traceback.format_exc()
317
+ stdout = redirected_output.getvalue()
318
+ stderr = redirected_error.getvalue()
319
+ sys.stdout = old_stdout
320
+ sys.stderr = old_stderr
321
+ evaluation = ""
322
+ if exc:
323
+ evaluation = exc
324
+ elif stderr:
325
+ evaluation = stderr
326
+ elif stdout:
327
+ evaluation = stdout
328
+ else:
329
+ evaluation = "Success"
330
+ final_output = (
331
+ "__►__ **EVAL**\n```{}``` \n\n __►__ **OUTPUT**: \n```{}``` \n".format(
332
+ cmd, evaluation
333
+ )
334
+ )
335
+ if len(final_output) > 4096:
336
+ with io.BytesIO(str.encode(final_output)) as out_file:
337
+ out_file.name = "eval.txt"
338
+ await ultroid_bot.send_file(
339
+ event.chat_id,
340
+ out_file,
341
+ force_document=True,
342
+ allow_cache=False,
343
+ caption=f"```{cmd}```",
344
+ reply_to=reply_to_id,
345
+ )
346
+ await xx.delete()
347
+ else:
348
+ await eod(xx, final_output)
349
+
350
+
351
+ async def aexec(code, event):
352
+ e = message = event
353
+ client = event.client
354
+ exec(
355
+ f"async def __aexec(e, client): "
356
+ + "\n message = event = e"
357
+ + "".join(f"\n {l}" for l in code.split("\n"))
358
+ )
359
+
360
+ return await locals()["__aexec"](e, e.client)
361
+
362
+
363
+ @ultroid_cmd(
364
+ pattern="sg(?: |$)(.*)",
365
+ )
366
+ async def lastname(steal):
367
+ if steal.fwd_from:
368
+ return
369
+ if not steal.reply_to_msg_id:
370
+ await steal.edit("Reply to any user message.")
371
+ return
372
+ message = await steal.get_reply_message()
373
+ chat = "@SangMataInfo_bot"
374
+ user_id = message.sender.id
375
+ id = f"/search_id {user_id}"
376
+ if message.sender.bot:
377
+ await steal.edit("Reply to actual users message.")
378
+ return
379
+ lol = await eor(steal, "Processingg !!!!!")
380
+ try:
381
+ async with ultroid_bot.conversation(chat) as conv:
382
+ try:
383
+ msg = await conv.send_message(id)
384
+ response = await conv.get_response()
385
+ respond = await conv.get_response()
386
+ responds = await conv.get_response()
387
+ except YouBlockedUserError:
388
+ await lol.edit("Please unblock @sangmatainfo_bot and try again")
389
+ return
390
+ if response.text.startswith("No records found"):
391
+ await lol.edit("No records found for this user")
392
+ await steal.client.delete_messages(conv.chat_id, [msg.id, response.id])
393
+ return
394
+ else:
395
+ if response.text.startswith("🔗"):
396
+ await lol.edit(respond.message)
397
+ await lol.reply(responds.message)
398
+ elif respond.text.startswith("🔗"):
399
+ await lol.edit(response.message)
400
+ await lol.reply(responds.message)
401
+ else:
402
+ await lol.edit(respond.message)
403
+ await lol.reply(response.message)
404
+ await steal.client.delete_messages(
405
+ conv.chat_id, [msg.id, responds.id, respond.id, response.id]
406
+ )
407
+ except TimeoutError:
408
+ return await lol.edit("Error: @SangMataInfo_bot is not responding!.")
409
+
410
+
411
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/updater.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ import asyncio
9
+ import sys
10
+ from os import environ, execle, path, remove
11
+
12
+ from git import Repo
13
+ from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError
14
+
15
+ UPSTREAM_REPO_URL = "https://github.com/TeamUltroid/Ultroid"
16
+ requirements_path = path.join(
17
+ path.dirname(path.dirname(path.dirname(__file__))), "requirements.txt"
18
+ )
19
+
20
+
21
+ async def gen_chlog(repo, diff):
22
+ ch_log = ""
23
+ d_form = "On %d/%m/%y at %H:%M:%S"
24
+ for c in repo.iter_commits(diff):
25
+ ch_log += f"**#{c.count()}** : {c.committed_datetime.strftime(d_form)} : [{c.summary}]({UPSTREAM_REPO_URL.rstrip('/')}/commit/{c}) by `{c.author}`\n"
26
+ return ch_log
27
+
28
+
29
+ async def updateme_requirements():
30
+ reqs = str(requirements_path)
31
+ try:
32
+ process = await asyncio.create_subprocess_shell(
33
+ " ".join([sys.executable, "-m", "pip", "install", "-r", reqs]),
34
+ stdout=asyncio.subprocess.PIPE,
35
+ stderr=asyncio.subprocess.PIPE,
36
+ )
37
+ await process.communicate()
38
+ return process.returncode
39
+ except Exception as e:
40
+ return repr(e)
41
+
42
+
43
+ @ultroid_cmd(
44
+ pattern="update ?(.*)",
45
+ )
46
+ async def upstream(ups):
47
+ pagal = await eor(ups, "`Checking for updates, please wait....`")
48
+ conf = ups.pattern_match.group(1)
49
+ off_repo = UPSTREAM_REPO_URL
50
+ try:
51
+ txt = "`Oops.. Updater cannot continue due to "
52
+ txt += "some problems occured`\n\n**LOGTRACE:**\n"
53
+ repo = Repo()
54
+ except NoSuchPathError as error:
55
+ await eod(pagal, f"{txt}\n`directory {error} is not found`", time=10)
56
+ repo.__del__()
57
+ return
58
+ except GitCommandError as error:
59
+ await eod(pagal, f"{txt}\n`Early failure! {error}`", time=10)
60
+ repo.__del__()
61
+ return
62
+ except InvalidGitRepositoryError as error:
63
+ if conf != "now":
64
+ await eod(
65
+ pagal,
66
+ f"**Unfortunately, the directory {error} does not seem to be a git repository.Or Maybe it just needs a sync verification with {GIT_REPO_NAME} But we can fix that by force updating the userbot using** `.update now.`",
67
+ time=30,
68
+ )
69
+ return
70
+ repo = Repo.init()
71
+ origin = repo.create_remote("upstream", off_repo)
72
+ origin.fetch()
73
+ repo.create_head("main", origin.refs.main)
74
+ repo.heads.main.set_tracking_branch(origin.refs.main)
75
+ repo.heads.main.checkout(True)
76
+ ac_br = repo.active_branch.name
77
+ if ac_br != "main":
78
+ await eod(
79
+ pagal,
80
+ f"**[UPDATER]:**` You are on ({ac_br})\n Please change to main branch.`",
81
+ )
82
+ repo.__del__()
83
+ return
84
+ try:
85
+ repo.create_remote("upstream", off_repo)
86
+ except BaseException:
87
+ pass
88
+ ups_rem = repo.remote("upstream")
89
+ ups_rem.fetch(ac_br)
90
+ changelog = await gen_chlog(repo, f"HEAD..upstream/{ac_br}")
91
+ if "now" not in conf:
92
+ if changelog:
93
+ changelog_str = f"**New UPDATE available for [[{ac_br}]]({UPSTREAM_REPO_URL}/tree/{ac_br}):\n\nCHANGELOG**\n\n{changelog}"
94
+ if len(changelog_str) > 4096:
95
+ await eor(pagal, "`Changelog is too big, view the file to see it.`")
96
+ file = open("output.txt", "w+")
97
+ file.write(changelog_str)
98
+ file.close()
99
+ await ups.client.send_file(
100
+ ups.chat_id,
101
+ "output.txt",
102
+ caption=f"Do `{hndlr}update now` to update.",
103
+ reply_to=ups.id,
104
+ )
105
+ remove("output.txt")
106
+ else:
107
+ return await eod(
108
+ pagal, f"{changelog_str}\n\nDo `{hndlr}update now` to update."
109
+ )
110
+ else:
111
+ await eod(
112
+ pagal,
113
+ f"\n`Your BOT is` **up-to-date** `with` **[[{ac_br}]]({UPSTREAM_REPO_URL}/tree/{ac_br})**\n",
114
+ time=10,
115
+ )
116
+ repo.__del__()
117
+ return
118
+ if Var.HEROKU_API is not None:
119
+ import heroku3
120
+
121
+ heroku = heroku3.from_key(Var.HEROKU_API)
122
+ heroku_app = None
123
+ heroku_applications = heroku.apps()
124
+ if not Var.HEROKU_APP_NAME:
125
+ await eod(
126
+ pagal,
127
+ "`Please set up the HEROKU_APP_NAME variable to be able to update userbot.`",
128
+ time=10,
129
+ )
130
+ repo.__del__()
131
+ return
132
+ for app in heroku_applications:
133
+ if app.name == Var.HEROKU_APP_NAME:
134
+ heroku_app = app
135
+ break
136
+ if heroku_app is None:
137
+ await eod(
138
+ pagal,
139
+ f"{txt}\n`Invalid Heroku credentials for updating userbot dyno.`",
140
+ time=10,
141
+ )
142
+ repo.__del__()
143
+ return
144
+ await eor(
145
+ pagal, "`Userbot dyno build in progress, please wait for it to complete.`"
146
+ )
147
+ ups_rem.fetch(ac_br)
148
+ repo.git.reset("--hard", "FETCH_HEAD")
149
+ heroku_git_url = heroku_app.git_url.replace(
150
+ "https://", "https://api:" + Var.HEROKU_API + "@"
151
+ )
152
+ if "heroku" in repo.remotes:
153
+ remote = repo.remote("heroku")
154
+ remote.set_url(heroku_git_url)
155
+ else:
156
+ remote = repo.create_remote("heroku", heroku_git_url)
157
+ try:
158
+ remote.push(refspec=f"HEAD:refs/heads/{ac_br}", force=True)
159
+ except GitCommandError as error:
160
+ await eod(pagal, f"{txt}\n`Here is the error log:\n{error}`", time=10)
161
+ repo.__del__()
162
+ return
163
+ await eod(pagal, "`Successfully Updated!\nRestarting, please wait...`", time=60)
164
+ else:
165
+ # Classic Updater, pretty straightforward.
166
+ try:
167
+ ups_rem.pull(ac_br)
168
+ except GitCommandError:
169
+ repo.git.reset("--hard", "FETCH_HEAD")
170
+ await updateme_requirements()
171
+ await eod(
172
+ pagal,
173
+ "`Successfully Updated!\nBot is restarting... Wait for a second!`",
174
+ )
175
+ # Spin a new instance of bot
176
+ args = [sys.executable, "./resources/startup/deploy.sh"]
177
+ execle(sys.executable, *args, environ)
178
+ return
plugins/uploads_files.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}ul <path/to/file>`
12
+ Upload file to telegram chat.
13
+
14
+ • `{i}dl <filename(optional)>`
15
+ Reply to file to download.
16
+
17
+ • `{i}save <filename.ext>`
18
+ Reply to a text msg to save it in a file.
19
+
20
+ • `{i}open`
21
+ Reply to a file to reveal it's text.
22
+ """
23
+
24
+ import asyncio
25
+ import os
26
+ import time
27
+ from datetime import datetime as dt
28
+
29
+ from . import *
30
+
31
+ opn = []
32
+
33
+
34
+ @ultroid_cmd(
35
+ pattern="dl ?(.*)",
36
+ )
37
+ async def download(event):
38
+ xx = await eor(event, "`Processing...`")
39
+ kk = event.pattern_match.group(1)
40
+ s = dt.now()
41
+ k = time.time()
42
+ if event.reply_to_msg_id:
43
+ ok = await event.get_reply_message()
44
+ if not ok.media:
45
+ return await eod(xx, "`Reply The File/Media u Want to Download..`", time=5)
46
+ else:
47
+ if not kk:
48
+ d = "resources/downloads/"
49
+ o = await event.client.download_media(
50
+ ok,
51
+ d,
52
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
53
+ progress(
54
+ d,
55
+ t,
56
+ xx,
57
+ k,
58
+ "Downloading...",
59
+ )
60
+ ),
61
+ )
62
+ else:
63
+ d = f"resources/downloads/{kk}"
64
+ o = await event.client.download_media(
65
+ ok,
66
+ d,
67
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
68
+ progress(
69
+ d,
70
+ t,
71
+ xx,
72
+ k,
73
+ "Downloading...",
74
+ file_name=d,
75
+ )
76
+ ),
77
+ )
78
+ e = datetime.now()
79
+ t = convert((e - s).seconds)
80
+ await eod(xx, f"Download Successful..\nTo\n`{o}`\nin `{t}`")
81
+
82
+
83
+ @ultroid_cmd(
84
+ pattern="ul ?(.*)",
85
+ )
86
+ async def download(event):
87
+ xx = await eor(event, "`Processing...`")
88
+ kk = event.pattern_match.group(1)
89
+ s = dt.now()
90
+ tt = time.time()
91
+ if not kk:
92
+ return await eod(xx, "`Give a specific path to file`")
93
+ else:
94
+ try:
95
+ x = await event.client.send_file(
96
+ event.chat_id,
97
+ kk,
98
+ caption=kk,
99
+ progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
100
+ progress(
101
+ d,
102
+ t,
103
+ xx,
104
+ tt,
105
+ "Uploading...",
106
+ file_name=kk,
107
+ )
108
+ ),
109
+ )
110
+ except ValueError as ve:
111
+ return await eod(xx, str(ve))
112
+ e = datetime.now()
113
+ t = convert((e - s).seconds)
114
+ try:
115
+ await x.edit(f"`{kk}`\nTime Taken: `{t}`")
116
+ except BaseException:
117
+ pass
118
+ await eod(xx, f"Uploaded `{kk}` in `{t}`", time=5)
119
+
120
+
121
+ @ultroid_cmd(
122
+ pattern="save",
123
+ )
124
+ async def _(event):
125
+ input_str = event.text[6:]
126
+ xx = await eor(event, "`Processing...`")
127
+ if event.reply_to_msg_id:
128
+ a = await event.get_reply_message()
129
+ if not a.message:
130
+ return await xx.edit("`Reply to a message`")
131
+ else:
132
+ b = open(input_str, "w")
133
+ b.write(str(a.message))
134
+ b.close()
135
+ await xx.edit(f"**Packing into** `{input_str}`")
136
+ await asyncio.sleep(2)
137
+ await xx.edit(f"**Uploading** `{input_str}`")
138
+ await asyncio.sleep(2)
139
+ await event.client.send_file(event.chat_id, input_str)
140
+ await xx.delete()
141
+ os.remove(input_str)
142
+
143
+
144
+ @ultroid_cmd(
145
+ pattern="open$",
146
+ )
147
+ async def _(event):
148
+ xx = await eor(event, "`Processing...`")
149
+ if event.reply_to_msg_id:
150
+ a = await event.get_reply_message()
151
+ if a.media:
152
+ b = await a.download_media()
153
+ c = open(b, "r")
154
+ d = c.read()
155
+ c.close()
156
+ n = 4096
157
+ for bkl in range(0, len(d), n):
158
+ opn.append(d[bkl : bkl + n])
159
+ for bc in opn:
160
+ await event.client.send_message(
161
+ event.chat_id,
162
+ f"```{bc}```",
163
+ reply_to=event.reply_to_msg_id,
164
+ )
165
+ await event.delete()
166
+ opn.clear()
167
+ os.remove(b)
168
+ await xx.delete()
169
+ else:
170
+ return await eod(xx, "`Reply to a readable file`", time=10)
171
+ else:
172
+ return await eod(xx, "`Reply to a readable file`", time=10)
173
+
174
+
175
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/utilities.py ADDED
@@ -0,0 +1,583 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}kickme`
12
+ Leaves the group in which it is used.
13
+
14
+ • `{i}calc <equation>`
15
+ A simple calculator.
16
+
17
+ • `{i}date`
18
+ Show Calender.
19
+
20
+ • `{i}chatinfo`
21
+ Get full info about the group/chat.
22
+
23
+ • `{i}listreserved`
24
+ List all usernames (channels/groups) you own.
25
+
26
+ • `{i}stats`
27
+ See your profile stats.
28
+
29
+ • `{i}paste`
30
+ Include long text / Reply to text file.
31
+
32
+ • `{i}hastebin`
33
+ Include long text / Reply to text file.
34
+
35
+ • `{i}info <username/userid>`
36
+ Reply to someone's msg.
37
+
38
+ • `{i}invite <username/userid>`
39
+ Add user to the chat.
40
+
41
+ • `{i}rmbg <reply to pic>`
42
+ Remove background from that picture.
43
+
44
+ • `{i}telegraph <reply to media/text>`
45
+ Upload media/text to telegraph.
46
+
47
+ • `{i}json <reply to msg>`
48
+ Get the json encoding of the message.
49
+ """
50
+ import asyncio
51
+ import calendar
52
+ import html
53
+ import io
54
+ import os
55
+ import sys
56
+ import time
57
+ import traceback
58
+ from datetime import datetime as dt
59
+
60
+ import pytz
61
+ import requests
62
+ from telegraph import Telegraph
63
+ from telegraph import upload_file as uf
64
+ from telethon import functions
65
+ from telethon.errors.rpcerrorlist import BotInlineDisabledError, BotResponseTimeoutError
66
+ from telethon.events import NewMessage
67
+ from telethon.tl.custom import Dialog
68
+ from telethon.tl.functions.channels import LeaveChannelRequest
69
+ from telethon.tl.functions.photos import GetUserPhotosRequest
70
+ from telethon.tl.types import Channel, Chat, User
71
+ from telethon.utils import get_input_location
72
+
73
+ # =================================================================#
74
+ from . import *
75
+
76
+ TMP_DOWNLOAD_DIRECTORY = "resources/downloads/"
77
+
78
+ # Telegraph Things
79
+ telegraph = Telegraph()
80
+ telegraph.create_account(short_name="Ultroid")
81
+ # ================================================================#
82
+
83
+
84
+ @ultroid_cmd(
85
+ pattern="kickme$",
86
+ groups_only=True,
87
+ )
88
+ async def leave(ult):
89
+ x = ultroid_bot.me
90
+ name = x.first_name
91
+ await eor(ult, f"`{name} has left this group, bye!!.`")
92
+ await ultroid_bot(LeaveChannelRequest(ult.chat_id))
93
+
94
+
95
+ @ultroid_cmd(
96
+ pattern="date$",
97
+ )
98
+ async def date(event):
99
+ k = pytz.timezone("Asia/Kolkata")
100
+ m = dt.now(k).month
101
+ y = dt.now(k).year
102
+ d = dt.now(k).strftime("Date - %B %d, %Y\nTime- %H:%M:%S")
103
+ k = calendar.month(y, m)
104
+ ultroid = await eor(event, f"`{k}\n\n{d}`")
105
+
106
+
107
+ @ultroid_cmd(
108
+ pattern="calc",
109
+ )
110
+ async def _(event):
111
+ x = await eor(event, "...")
112
+ cmd = event.text.split(" ", maxsplit=1)[1]
113
+ event.message.id
114
+ if event.reply_to_msg_id:
115
+ event.reply_to_msg_id
116
+ wtf = f"print({cmd})"
117
+ old_stderr = sys.stderr
118
+ old_stdout = sys.stdout
119
+ redirected_output = sys.stdout = io.StringIO()
120
+ redirected_error = sys.stderr = io.StringIO()
121
+ stdout, stderr, exc = None, None, None
122
+ try:
123
+ await aexec(wtf, event)
124
+ except Exception:
125
+ exc = traceback.format_exc()
126
+ stdout = redirected_output.getvalue()
127
+ stderr = redirected_error.getvalue()
128
+ sys.stdout = old_stdout
129
+ sys.stderr = old_stderr
130
+ evaluation = ""
131
+ if exc:
132
+ evaluation = exc
133
+ elif stderr:
134
+ evaluation = stderr
135
+ elif stdout:
136
+ evaluation = stdout
137
+ else:
138
+ evaluation = "`Something went wrong`"
139
+
140
+ final_output = """
141
+ **EQUATION**:
142
+ `{}`
143
+ **SOLUTION**:
144
+ `{}`
145
+ """.format(
146
+ cmd, evaluation
147
+ )
148
+ await x.edit(final_output)
149
+
150
+
151
+ async def aexec(code, event):
152
+ exec(f"async def __aexec(event): " + "".join(f"\n {l}" for l in code.split("\n")))
153
+ return await locals()["__aexec"](event)
154
+
155
+
156
+ @ultroid_cmd(
157
+ pattern="chatinfo(?: |$)(.*)",
158
+ )
159
+ async def info(event):
160
+ ok = await eor(event, "`...`")
161
+ chat = await get_chatinfo(event)
162
+ caption = await fetch_info(chat, event)
163
+ try:
164
+ await ok.edit(caption, parse_mode="html")
165
+ except Exception as e:
166
+ print("Exception:", e)
167
+ await ok.edit(f"`An unexpected error has occurred. {e}`")
168
+ await asyncio.sleep(5)
169
+ await ok.delete()
170
+ return
171
+
172
+
173
+ @ultroid_cmd(
174
+ pattern="listreserved$",
175
+ )
176
+ async def _(event):
177
+ result = await ultroid_bot(functions.channels.GetAdminedPublicChannelsRequest())
178
+ output_str = ""
179
+ r = result.chats
180
+ for channel_obj in r:
181
+ output_str += f"- {channel_obj.title} @{channel_obj.username} \n"
182
+ if not r:
183
+ await eor(event, "`Not username Reserved`")
184
+ else:
185
+ await eor(event, output_str)
186
+
187
+
188
+ @ultroid_cmd(
189
+ pattern="stats$",
190
+ )
191
+ async def stats(
192
+ event: NewMessage.Event,
193
+ ) -> None:
194
+ ok = await eor(event, "`Collecting stats...`")
195
+ start_time = time.time()
196
+ private_chats = 0
197
+ bots = 0
198
+ groups = 0
199
+ broadcast_channels = 0
200
+ admin_in_groups = 0
201
+ creator_in_groups = 0
202
+ admin_in_broadcast_channels = 0
203
+ creator_in_channels = 0
204
+ unread_mentions = 0
205
+ unread = 0
206
+ dialog: Dialog
207
+ async for dialog in ultroid_bot.iter_dialogs():
208
+ entity = dialog.entity
209
+ if isinstance(entity, Channel):
210
+ if entity.broadcast:
211
+ broadcast_channels += 1
212
+ if entity.creator or entity.admin_rights:
213
+ admin_in_broadcast_channels += 1
214
+ if entity.creator:
215
+ creator_in_channels += 1
216
+
217
+ elif entity.megagroup:
218
+ groups += 1
219
+ if entity.creator or entity.admin_rights:
220
+ admin_in_groups += 1
221
+ if entity.creator:
222
+ creator_in_groups += 1
223
+
224
+ elif isinstance(entity, User):
225
+ private_chats += 1
226
+ if entity.bot:
227
+ bots += 1
228
+
229
+ elif isinstance(entity, Chat):
230
+ groups += 1
231
+ if entity.creator or entity.admin_rights:
232
+ admin_in_groups += 1
233
+ if entity.creator:
234
+ creator_in_groups += 1
235
+
236
+ unread_mentions += dialog.unread_mentions_count
237
+ unread += dialog.unread_count
238
+ stop_time = time.time() - start_time
239
+
240
+ full_name = inline_mention(await ultroid_bot.get_me())
241
+ response = f"🔸 **Stats for {full_name}** \n\n"
242
+ response += f"**Private Chats:** {private_chats} \n"
243
+ response += f"** •• **`Users: {private_chats - bots}` \n"
244
+ response += f"** •• **`Bots: {bots}` \n"
245
+ response += f"**Groups:** {groups} \n"
246
+ response += f"**Channels:** {broadcast_channels} \n"
247
+ response += f"**Admin in Groups:** {admin_in_groups} \n"
248
+ response += f"** •• **`Creator: {creator_in_groups}` \n"
249
+ response += f"** •• **`Admin Rights: {admin_in_groups - creator_in_groups}` \n"
250
+ response += f"**Admin in Channels:** {admin_in_broadcast_channels} \n"
251
+ response += f"** •• **`Creator: {creator_in_channels}` \n"
252
+ response += f"** •• **`Admin Rights: {admin_in_broadcast_channels - creator_in_channels}` \n"
253
+ response += f"**Unread:** {unread} \n"
254
+ response += f"**Unread Mentions:** {unread_mentions} \n\n"
255
+ response += f"**__It Took:__** {stop_time:.02f}s \n"
256
+ await ok.edit(response)
257
+
258
+
259
+ @ultroid_cmd(
260
+ pattern="paste( (.*)|$)",
261
+ )
262
+ async def _(event):
263
+ xx = await eor(event, "`...`")
264
+ input_str = "".join(event.text.split(maxsplit=1)[1:])
265
+ if input_str:
266
+ message = input_str
267
+ downloaded_file_name = None
268
+ elif event.reply_to_msg_id:
269
+ previous_message = await event.get_reply_message()
270
+ if previous_message.media:
271
+ downloaded_file_name = await event.client.download_media(
272
+ previous_message,
273
+ "./resources/downloads",
274
+ )
275
+ m_list = None
276
+ with open(downloaded_file_name, "rb") as fd:
277
+ m_list = fd.readlines()
278
+ message = ""
279
+ try:
280
+ for m in m_list:
281
+ message += m.decode("UTF-8")
282
+ except BaseException:
283
+ message = "`Include long text / Reply to text file`"
284
+ os.remove(downloaded_file_name)
285
+ else:
286
+ downloaded_file_name = None
287
+ message = previous_message.message
288
+ else:
289
+ downloaded_file_name = None
290
+ message = "`Include long text / Reply to text file`"
291
+ if downloaded_file_name and downloaded_file_name.endswith(".py"):
292
+ data = message
293
+ key = (
294
+ requests.post("https://nekobin.com/api/documents", json={"content": data})
295
+ .json()
296
+ .get("result")
297
+ .get("key")
298
+ )
299
+ else:
300
+ data = message
301
+ key = (
302
+ requests.post("https://nekobin.com/api/documents", json={"content": data})
303
+ .json()
304
+ .get("result")
305
+ .get("key")
306
+ )
307
+ q = f"paste-{key}"
308
+ try:
309
+ ok = await ultroid_bot.inline_query(Var.BOT_USERNAME, q)
310
+ await ok[0].click(event.chat_id, reply_to=event.reply_to_msg_id, hide_via=True)
311
+ await xx.delete()
312
+ except BotInlineDisabledError or BotResponseTimeoutError: # incase the bot doesnt respond
313
+ await xx.edit(reply_text)
314
+
315
+
316
+ @ultroid_cmd(
317
+ pattern="hastebin ?(.*)",
318
+ )
319
+ async def _(event):
320
+ input_str = event.pattern_match.group(1)
321
+ xx = await eor(event, "`Pasting...`")
322
+ message = "SYNTAX: `.paste <long text to include>`"
323
+ if input_str:
324
+ message = input_str
325
+ elif event.reply_to_msg_id:
326
+ previous_message = await event.get_reply_message()
327
+ if previous_message.media:
328
+ downloaded_file_name = await event.client.download_media(
329
+ previous_message,
330
+ "./resources/downloads",
331
+ )
332
+ m_list = None
333
+ with open(downloaded_file_name, "rb") as fd:
334
+ m_list = fd.readlines()
335
+ message = ""
336
+ for m in m_list:
337
+ message += m.decode("UTF-8") + "\r\n"
338
+ os.remove(downloaded_file_name)
339
+ else:
340
+ message = previous_message.message
341
+ else:
342
+ message = "SYNTAX: `.hastebin <long text to include>`"
343
+ url = "https://hastebin.com/documents"
344
+ r = requests.post(url, data=message).json()
345
+ url = f"https://hastebin.com/{r['key']}"
346
+ await xx.edit("**Pasted to Hastebin** : [Link]({})".format(url))
347
+
348
+
349
+ @ultroid_cmd(
350
+ pattern="info ?(.*)",
351
+ )
352
+ async def _(event):
353
+ xx = await eor(event, "`Processing...`")
354
+ replied_user, error_i_a = await get_full_user(event)
355
+ if replied_user is None:
356
+ await xx.edit("Please repl to a user.\nError - " + str(error_i_a))
357
+ return False
358
+ replied_user_profile_photos = await event.client(
359
+ GetUserPhotosRequest(
360
+ user_id=replied_user.user.id, offset=42, max_id=0, limit=80
361
+ )
362
+ )
363
+ replied_user_profile_photos_count = "NaN"
364
+ try:
365
+ replied_user_profile_photos_count = replied_user_profile_photos.count
366
+ except AttributeError:
367
+ pass
368
+ user_id = replied_user.user.id
369
+ first_name = html.escape(replied_user.user.first_name)
370
+ if first_name is not None:
371
+ first_name = first_name.replace("\u2060", "")
372
+ last_name = replied_user.user.last_name
373
+ last_name = (
374
+ last_name.replace("\u2060", "") if last_name else ("Last Name not found")
375
+ )
376
+ user_bio = replied_user.about
377
+ if user_bio is not None:
378
+ user_bio = html.escape(replied_user.about)
379
+ common_chats = replied_user.common_chats_count
380
+ try:
381
+ dc_id, location = get_input_location(replied_user.profile_photo)
382
+ except Exception as e:
383
+ dc_id = "Need a Profile Picture to check this"
384
+ str(e)
385
+ caption = """<b>Exᴛʀᴀᴄᴛᴇᴅ Dᴀᴛᴀʙᴀsᴇ Fʀᴏᴍ Tᴇʟᴇɢʀᴀᴍ's Dᴀᴛᴀʙᴀsᴇ<b>
386
+ <b>••Tᴇʟᴇɢʀᴀᴍ ID</b>: <code>{}</code>
387
+ <b>••Pᴇʀᴍᴀɴᴇɴᴛ Lɪɴᴋ</b>: <a href='tg://user?id={}'>Click Here</a>
388
+ <b>••Fɪʀsᴛ Nᴀᴍᴇ</b>: <code>{}</code>
389
+ <b>••Sᴇᴄᴏɴᴅ Nᴀᴍᴇ</b>: <code>{}</code>
390
+ <b>••Bɪᴏ</b>: <code>{}</code>
391
+ <b>••Dᴄ ID</b>: <code>{}</code>
392
+ <b>••Nᴏ. Oғ PғPs</b> : <code>{}</code>
393
+ <b>••Is Rᴇsᴛʀɪᴄᴛᴇᴅ</b>: <code>{}</code>
394
+ <b>••Vᴇʀɪғɪᴇᴅ</b>: <code>{}</code>
395
+ <b>••Is A Bᴏᴛ</b>: <code>{}</code>
396
+ <b>••Gʀᴏᴜᴘs Iɴ Cᴏᴍᴍᴏɴ</b>: <code>{}</code>
397
+ """.format(
398
+ user_id,
399
+ user_id,
400
+ first_name,
401
+ last_name,
402
+ user_bio,
403
+ dc_id,
404
+ replied_user_profile_photos_count,
405
+ replied_user.user.restricted,
406
+ replied_user.user.verified,
407
+ replied_user.user.bot,
408
+ common_chats,
409
+ )
410
+ message_id_to_reply = event.message.reply_to_msg_id
411
+ if not message_id_to_reply:
412
+ message_id_to_reply = event.message.id
413
+ await event.client.send_message(
414
+ event.chat_id,
415
+ caption,
416
+ reply_to=message_id_to_reply,
417
+ parse_mode="HTML",
418
+ file=replied_user.profile_photo,
419
+ force_document=False,
420
+ silent=True,
421
+ )
422
+ await xx.delete()
423
+
424
+
425
+ @ultroid_cmd(
426
+ pattern="invite ?(.*)",
427
+ groups_only=True,
428
+ )
429
+ async def _(ult):
430
+ xx = await eor(ult, "`Processing...`")
431
+ to_add_users = ult.pattern_match.group(1)
432
+ if not ult.is_channel and ult.is_group:
433
+ for user_id in to_add_users.split(" "):
434
+ try:
435
+ await ultroid_bot(
436
+ functions.messages.AddChatUserRequest(
437
+ chat_id=ult.chat_id, user_id=user_id, fwd_limit=1000000
438
+ )
439
+ )
440
+ await xx.edit(f"Successfully invited `{user_id}` to `{ult.chat_id}`")
441
+ except Exception as e:
442
+ await xx.edit(str(e))
443
+ else:
444
+ for user_id in to_add_users.split(" "):
445
+ try:
446
+ await ultroid_bot(
447
+ functions.channels.InviteToChannelRequest(
448
+ channel=ult.chat_id, users=[user_id]
449
+ )
450
+ )
451
+ await xx.edit(f"Successfully invited `{user_id}` to `{ult.chat_id}`")
452
+ except Exception as e:
453
+ await xx.edit(str(e))
454
+
455
+
456
+ @ultroid_cmd(
457
+ pattern=r"rmbg ?(.*)",
458
+ )
459
+ async def rmbg(event):
460
+ RMBG_API = udB.get("RMBG_API")
461
+ xx = await eor(event, "`Processing...`")
462
+ if not RMBG_API:
463
+ return await xx.edit(
464
+ "Get your API key from [here](https://www.remove.bg/) for this plugin to work.",
465
+ )
466
+ input_str = event.pattern_match.group(1)
467
+ message_id = event.message.id
468
+ if event.reply_to_msg_id:
469
+ message_id = event.reply_to_msg_id
470
+ reply_message = await event.get_reply_message()
471
+ try:
472
+ dl_file = await ultroid_bot.download_media(
473
+ reply_message, TMP_DOWNLOAD_DIRECTORY
474
+ )
475
+ except Exception as e:
476
+ return await xx.edit("**ERROR:**\n`{}`".format(str(e)))
477
+ else:
478
+ await xx.edit("`Sending to remove.bg`")
479
+ output_file_name = ReTrieveFile(dl_file)
480
+ os.remove(dl_file)
481
+ elif input_str:
482
+ await xx.edit("`Sending to remove.bg`")
483
+ output_file_name = ReTrieveURL(input_str)
484
+ else:
485
+ await xx.edit(
486
+ f"Use `{Var.HNDLR}rmbg` as reply to a pic to remove its background."
487
+ )
488
+ await asyncio.sleep(5)
489
+ await xx.delete()
490
+ return
491
+ contentType = output_file_name.headers.get("content-type")
492
+ if "image" in contentType:
493
+ with io.BytesIO(output_file_name.content) as remove_bg_image:
494
+ remove_bg_image.name = "rmbg-ult.png"
495
+ await ultroid_bot.send_file(
496
+ event.chat_id,
497
+ remove_bg_image,
498
+ force_document=True,
499
+ supports_streaming=False,
500
+ allow_cache=False,
501
+ reply_to=message_id,
502
+ )
503
+ await xx.edit("`Done.`")
504
+ else:
505
+ await xx.edit(
506
+ "RemoveBG returned an error - \n`{}`".format(
507
+ output_file_name.content.decode("UTF-8")
508
+ ),
509
+ )
510
+
511
+
512
+ @ultroid_cmd(
513
+ pattern="telegraph ?(.*)",
514
+ )
515
+ async def telegraphcmd(event):
516
+ input_str = event.pattern_match.group(1)
517
+ xx = await eor(event, "`Processing...`")
518
+ if event.reply_to_msg_id:
519
+ getmsg = await event.get_reply_message()
520
+ if getmsg.photo or getmsg.video or getmsg.gif:
521
+ getit = await ultroid_bot.download_media(getmsg)
522
+ try:
523
+ variable = uf(getit)
524
+ os.remove(getit)
525
+ nn = "https://telegra.ph" + variable[0]
526
+ amsg = f"Uploaded to [Telegraph]({nn}) !"
527
+ except Exception as e:
528
+ amsg = f"Error - {e}"
529
+ await xx.edit(amsg)
530
+ elif getmsg.document:
531
+ getit = await ultroid_bot.download_media(getmsg)
532
+ ab = open(getit, "r")
533
+ cd = ab.read()
534
+ ab.close()
535
+ if input_str:
536
+ tcom = input_str
537
+ else:
538
+ tcom = "Ultroid"
539
+ makeit = telegraph.create_page(title=tcom, content=[f"{cd}"])
540
+ war = makeit["url"]
541
+ os.remove(getit)
542
+ await xx.edit(f"Pasted to Telegraph : [Telegraph]({war})")
543
+ elif getmsg.text:
544
+ if input_str:
545
+ tcom = input_str
546
+ else:
547
+ tcom = "Ultroid"
548
+ makeit = telegraph.create_page(title=tcom, content=[f"{getmsg.text}"])
549
+ war = makeit["url"]
550
+ await xx.edit(f"Pasted to Telegraph : [Telegraph]({war})")
551
+ else:
552
+ await xx.edit("Reply to a Media or Text !")
553
+ else:
554
+ await xx.edit("Reply to a Message !")
555
+
556
+
557
+ @ultroid_cmd(pattern="json")
558
+ async def _(event):
559
+ the_real_message = None
560
+ reply_to_id = None
561
+ if event.reply_to_msg_id:
562
+ previous_message = await event.get_reply_message()
563
+ the_real_message = previous_message.stringify()
564
+ reply_to_id = event.reply_to_msg_id
565
+ else:
566
+ the_real_message = event.stringify()
567
+ reply_to_id = event.message.id
568
+ if len(the_real_message) > 4096:
569
+ with io.BytesIO(str.encode(the_real_message)) as out_file:
570
+ out_file.name = "json-ult.txt"
571
+ await borg.send_file(
572
+ event.chat_id,
573
+ out_file,
574
+ force_document=True,
575
+ allow_cache=False,
576
+ reply_to=reply_to_id,
577
+ )
578
+ await event.delete()
579
+ else:
580
+ await eor(event, f"```{the_real_message}```")
581
+
582
+
583
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
plugins/words.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultroid - UserBot
2
+ # Copyright (C) 2020 TeamUltroid
3
+ #
4
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
+ # PLease read the GNU Affero General Public License in
6
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ """
9
+ ✘ Commands Available -
10
+
11
+ • `{i}meaning <word>`
12
+ Get the meaning of the word.
13
+
14
+ • `{i}synonym <word>`
15
+ Get all synonyms.
16
+
17
+ • `{i}antonym <word>`
18
+ Get all antonyms.
19
+
20
+ • `{i}ud <word>`
21
+ Fetch word defenition from urbandictionary.
22
+ """
23
+
24
+ import asyncurban
25
+ from PyDictionary import PyDictionary
26
+
27
+ from . import *
28
+
29
+ dictionary = PyDictionary()
30
+
31
+
32
+ @ultroid_cmd(
33
+ pattern="meaning",
34
+ )
35
+ async def mean(event):
36
+ evid = event.message.id
37
+ xx = await eor(event, "`Processing...`")
38
+ wrd = event.text.split(" ", maxsplit=1)[1]
39
+ ok = dictionary.meaning(wrd)
40
+ try:
41
+ p = ok["Noun"]
42
+ except BaseException:
43
+ return await xx.edit("Oops! No such word found!!")
44
+ x = f"**Word** - `{wrd}`\n\n**Meanings** - \n"
45
+ c = 1
46
+ for i in p:
47
+ x += f"**{c}.** `{i}`\n"
48
+ c += 1
49
+ if len(x) > 4096:
50
+ with io.BytesIO(str.encode(x)) as fle:
51
+ fle.name = f"{wrd}-meanings.txt"
52
+ await ultroid_bot.send_file(
53
+ event.chat_id,
54
+ out_file,
55
+ force_document=True,
56
+ allow_cache=False,
57
+ caption=f"Meanings of {wrd}",
58
+ reply_to=evid,
59
+ )
60
+ await xx.delete()
61
+ else:
62
+ await xx.edit(x)
63
+
64
+
65
+ @ultroid_cmd(
66
+ pattern="synonym",
67
+ )
68
+ async def mean(event):
69
+ evid = event.message.id
70
+ xx = await eor(event, "`Processing...`")
71
+ wrd = event.text.split(" ", maxsplit=1)[1]
72
+ ok = dictionary.synonym(wrd)
73
+ x = f"**Word** - `{wrd}`\n\n**Synonyms** - \n"
74
+ c = 1
75
+ try:
76
+ for i in ok:
77
+ x += f"**{c}.** `{i}`\n"
78
+ c += 1
79
+ if len(x) > 4096:
80
+ with io.BytesIO(str.encode(x)) as fle:
81
+ fle.name = f"{wrd}-synonyms.txt"
82
+ await ultroid_bot.send_file(
83
+ event.chat_id,
84
+ out_file,
85
+ force_document=True,
86
+ allow_cache=False,
87
+ caption=f"Synonyms of {wrd}",
88
+ reply_to=evid,
89
+ )
90
+ await xx.delete()
91
+ else:
92
+ await xx.edit(x)
93
+ except Exception as e:
94
+ await xx.edit(f"No synonym found!!\n{str(e)}")
95
+
96
+
97
+ @ultroid_cmd(
98
+ pattern="antonym",
99
+ )
100
+ async def mean(event):
101
+ evid = event.message.id
102
+ xx = await eor(event, "`Processing...`")
103
+ wrd = event.text.split(" ", maxsplit=1)[1]
104
+ ok = dictionary.antonym(wrd)
105
+ x = f"**Word** - `{wrd}`\n\n**Antonyms** - \n"
106
+ c = 1
107
+ try:
108
+ for i in ok:
109
+ x += f"**{c}.** `{i}`\n"
110
+ c += 1
111
+ if len(x) > 4096:
112
+ with io.BytesIO(str.encode(x)) as fle:
113
+ fle.name = f"{wrd}-antonyms.txt"
114
+ await ultroid_bot.send_file(
115
+ event.chat_id,
116
+ out_file,
117
+ force_document=True,
118
+ allow_cache=False,
119
+ caption=f"Antonyms of {wrd}",
120
+ reply_to=evid,
121
+ )
122
+ await xx.delete()
123
+ else:
124
+ await xx.edit(x)
125
+ except Exception as e:
126
+ await xx.edit(f"No antonym found!!\n{str(e)}")
127
+
128
+
129
+ @ultroid_cmd(pattern="ud (.*)")
130
+ async def _(event):
131
+ xx = await eor(event, "`Processing...`")
132
+ word = event.pattern_match.group(1)
133
+ if word is None:
134
+ return await xx.edit("`No word given!`")
135
+ urban = asyncurban.UrbanDictionary()
136
+ try:
137
+ mean = await urban.get_word(word)
138
+ await xx.edit(
139
+ f"**Text**: `{mean.word}`\n\n**Meaning**: `{mean.definition}`\n\n**Example**: __{mean.example}__"
140
+ )
141
+ except asyncurban.WordNotFoundError:
142
+ await xx.edit(f"**No result found for** `{word}`")
143
+
144
+
145
+ HELP.update({f"{__name__.split('.')[1]}": f"{__doc__.format(i=Var.HNDLR)}"})
requirements.txt ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ py-Ultroid==2021.2.21
2
+ asyncurban
3
+ carbonnow
4
+ cairosvg
5
+ emoji
6
+ GitPython
7
+ googletrans==3.1.0a0
8
+ heroku3
9
+ imutils
10
+ lottie
11
+ lxml
12
+ moviepy
13
+ numpy
14
+ opencv-python-headless
15
+ Pillow>=7.0.0
16
+ play-scraper
17
+ PyDictionary
18
+ PyPDF2
19
+ psutil
20
+ pytz
21
+ requests>=2.18.4
22
+ scikit-image
23
+ search-engine-parser
24
+ speedtest-cli==2.1.2
25
+ telegraph
26
+ validators
27
+ youtube_dl
28
+ youtube-search-python
29
+ google-api-python-client==1.7.11
30
+ oauth2client==4.1.3
31
+ httplib2==0.13.1
resources/downloads/.atoz ADDED
@@ -0,0 +1 @@
 
 
1
+ .
resources/session/session.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # !/bin/bash
2
+ # Ultroid - UserBot
3
+ # Copyright (C) 2020 TeamUltroid
4
+ #
5
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
6
+ # PLease read the GNU Affero General Public License in <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
+
8
+ clear
9
+ echo -e "\e[1m"
10
+ echo " _ _ _ _ _ _ "
11
+ echo " | | | | | | (_) | |"
12
+ echo " | | | | | |_ _ __ ___ _ __| |"
13
+ echo " | | | | | __| '__/ _ \| |/ _ |"
14
+ echo " | |__| | | |_| | | (_) | | (_| |"
15
+ echo " \____/|_|\__|_| \___/|_|\__,_|"
16
+ echo -e "\e[0m"
17
+ sec=5
18
+ spinner=(⣻ ⢿ ⡿ ⣟ ⣯ ⣷)
19
+ while [ $sec -gt 0 ]; do
20
+ echo -ne "\e[33m ${spinner[sec]} Starting dependency installation in $sec seconds...\r"
21
+ sleep 1
22
+ sec=$(($sec - 1))
23
+ done
24
+ echo -e "\e[1;32mInstalling Dependencies ---------------------------\e[0m\n" # Don't Remove Dashes / Fix it
25
+ apt-get update
26
+ apt-get upgrade -y
27
+ pkg upgrade -y
28
+ pkg install python wget -y
29
+ wget https://raw.githubusercontent.com/TeamUltroid/ultroid/main/resources/session/ssgen.py
30
+ pip install telethon
31
+ clear
32
+ python3 ssgen.py
resources/session/ssgen.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Ultroid - UserBot
3
+ # Copyright (C) 2020 TeamUltroid
4
+ #
5
+ # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
6
+ # PLease read the GNU Affero General Public License in
7
+ # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
8
+
9
+ from telethon.sessions import StringSession
10
+ from telethon.sync import TelegramClient
11
+
12
+ print("Please ensure that you have your API ID and API HASH.")
13
+ print("")
14
+
15
+ API_ID = int(input("Enter API ID: "))
16
+ API_HASH = input("Enter API HASH: ")
17
+
18
+ with TelegramClient(StringSession(), API_ID, API_HASH) as client:
19
+ ult = client.send_message("me", client.session.save())
20
+ ult.reply(
21
+ "The above is the `SESSION` for your current session.\nVisit @TheUltroid")
22
+ print("")
23
+ print("String Session for the current login has been generated.")
24
+ print("Check your Telegram Saved messages for your SESSION.")