├── .dockerignore
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── app.json
├── cache
├── __init__.py
└── admins.py
├── callsmusic
├── __init__.py
├── callsmusic.py
└── queues
│ ├── __init__.py
│ └── queues.py
├── config.py
├── converter
├── __init__.py
└── converter.py
├── downloaders
├── __init__.py
└── youtube.py
├── etc
├── font.otf
├── foreground.png
├── foreground_square.png
├── tg_vc_bot.png
└── thumb.jpg
├── example.env
├── handlers
├── __init__.py
├── admins.py
├── chat_member_updated.py
├── play.py
├── private.py
├── songs.py
└── ytsearch.py
├── helpers
├── __init__.py
├── admins.py
├── decorators.py
├── errors.py
├── filters.py
└── gets.py
├── heroku.yml
├── main.py
├── requirements.txt
└── str.py
/.dockerignore:
--------------------------------------------------------------------------------
1 | LICENSE
2 | README.md
3 |
4 | .env
5 | .gitignore
6 |
7 | .git/
8 | __pycache__/
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.session
2 | *.session-journal
3 | .env
4 | __pycache__
5 | .idea
6 | .vscode
7 | raw_files
8 | downloads
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:latest
2 |
3 | RUN apt update && apt upgrade -y
4 | RUN apt install git curl python3-pip ffmpeg -y
5 | RUN pip3 install -U pip
6 | RUN curl -sL https://deb.nodesource.com/setup_15.x | bash -
7 | RUN apt-get install -y nodejs
8 | RUN npm i -g npm
9 | RUN mkdir /app/
10 | WORKDIR /app/
11 | COPY . /app/
12 | RUN pip3 install -U -r requirements.txt
13 | CMD python3 main.py
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
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 General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Telegram Group Music Player Bot 🎵
2 |
3 | ### A bot that can play music on telegram group's voice call
4 |
5 |
6 |
7 |
8 |
9 | Requirements 📝
10 |
11 | - FFmpeg
12 | - NodeJS [nodesource.com](https://nodesource.com/)
13 | - Python 3.7+
14 | - [PyTgCalls](https://github.com/pytgcalls/pytgcalls)
15 |
16 | ### Commands 🛠
17 | #### For all in group
18 | - `/play` - reply to youtube url or song file to play song
19 | - `/play ` - play song you requested
20 | - `/song ` - download songs you want quickly
21 | - `/search ` - search videos on youtube with details
22 |
23 | #### Admins only
24 | - `/pause` - pause song play
25 | - `/resume` - resume song play
26 | - `/skip` - play next song
27 | - `/end` - stop music play
28 |
29 | ### Deploy To Heroku
30 |
31 | [](https://heroku.com/deploy?template=https://github.com/Infinity-Bots/GroupMusicPlayerBot)
32 |
33 | Use [Repl Link](https://replit.com/@SpEcHiDe/GenerateStringSession) to get pyrogram string session
34 |
35 | ### Credits
36 | - [ImJanindu](https://github.com/ImJanindu): Dev
37 | - [InukaASiTH](https://github.com/InukaAsith): Dev
38 | - [Laky](https://github.com/Laky-64) & [Andrew](https://github.com/AndrewLaneX): PyTgCalls
39 | - [Original Repo](https://github.com/suprojects/CallsMusic)
40 | - [Infinity BOTs](https://t.me/Infinity_BOTs)
41 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Music Bot",
3 | "description": "Open-Source bot to play songs in your Telegram's Group Voice Chat. Powered by PyTgCalls.",
4 | "keywords": ["music", "voicechat", "telegram"],
5 | "repository": "https://github.com/ImJanindu/GroupMusicBot",
6 | "stack": "container",
7 | "env": {
8 | "SESSION_NAME": {
9 | "description": "Pyrogram session string",
10 | "required": true
11 | },
12 | "BOT_TOKEN": {
13 | "description": "A bot token from @BotFather",
14 | "required": true
15 | },
16 | "BOT_NAME": {
17 | "description": "Your MusicPlayer Bot Name.",
18 | "required": false,
19 | "value": ""
20 | },
21 | "API_ID": {
22 | "description": "App ID from my.telegram.org/apps",
23 | "required": true
24 | },
25 | "API_HASH": {
26 | "description": "App hash from my.telegram.org/apps",
27 | "required": true
28 | },
29 | "SUDO_USERS": {
30 | "description": "List of user IDs counted as admin everywhere (separated by space).",
31 | "required": true
32 | },
33 | "DURATION_LIMIT": {
34 | "description": "Max audio duration limit for downloads (minutes).",
35 | "required": true,
36 | "value": "10"
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/cache/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/cache/admins.py:
--------------------------------------------------------------------------------
1 | from typing import List, Dict, Union
2 |
3 |
4 | admins: Dict[int, List[int]] = {}
5 |
6 |
7 | def set(chat_id: int, admins_: List[int]):
8 | admins[chat_id] = admins_
9 |
10 |
11 | def get(chat_id: int) -> Union[List[int], bool]:
12 | if chat_id in admins:
13 | return admins[chat_id]
14 |
15 | return False
16 |
--------------------------------------------------------------------------------
/callsmusic/__init__.py:
--------------------------------------------------------------------------------
1 | from .callsmusic import pytgcalls, run
2 | from . import queues
3 |
--------------------------------------------------------------------------------
/callsmusic/callsmusic.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client
2 | from pytgcalls import PyTgCalls
3 |
4 | import config
5 | from . import queues
6 |
7 | client = Client(config.SESSION_NAME, config.API_ID, config.API_HASH)
8 | pytgcalls = PyTgCalls(client)
9 |
10 |
11 | @pytgcalls.on_stream_end()
12 | def on_stream_end(chat_id: int) -> None:
13 | queues.task_done(chat_id)
14 |
15 | if queues.is_empty(chat_id):
16 | pytgcalls.leave_group_call(chat_id)
17 | else:
18 | pytgcalls.change_stream(
19 | chat_id, queues.get(chat_id)["file"]
20 | )
21 |
22 |
23 | run = pytgcalls.run
24 |
--------------------------------------------------------------------------------
/callsmusic/queues/__init__.py:
--------------------------------------------------------------------------------
1 | from .queues import put, get, is_empty, task_done, clear
2 |
--------------------------------------------------------------------------------
/callsmusic/queues/queues.py:
--------------------------------------------------------------------------------
1 | from asyncio import Queue, QueueEmpty as Empty
2 | from typing import Dict, Union
3 |
4 | queues: Dict[int, Queue] = {}
5 |
6 |
7 | async def put(chat_id: int, **kwargs) -> int:
8 | if chat_id not in queues:
9 | queues[chat_id] = Queue()
10 | await queues[chat_id].put({**kwargs})
11 | return queues[chat_id].qsize()
12 |
13 |
14 | def get(chat_id: int) -> Union[Dict[str, str], None]:
15 | if chat_id in queues:
16 | try:
17 | return queues[chat_id].get_nowait()
18 | except Empty:
19 | return None
20 |
21 |
22 | def is_empty(chat_id: int) -> bool:
23 | if chat_id in queues:
24 | return queues[chat_id].empty()
25 | return True
26 |
27 |
28 | def task_done(chat_id: int):
29 | if chat_id in queues:
30 | try:
31 | queues[chat_id].task_done()
32 | except ValueError:
33 | pass
34 |
35 |
36 | def clear(chat_id: int):
37 | if chat_id in queues:
38 | if queues[chat_id].empty():
39 | raise Empty
40 | else:
41 | queues[chat_id].queue = []
42 | raise Empty
43 |
--------------------------------------------------------------------------------
/config.py:
--------------------------------------------------------------------------------
1 | from os import getenv
2 |
3 | from dotenv import load_dotenv
4 |
5 | load_dotenv()
6 |
7 | SESSION_NAME = getenv("SESSION_NAME", "session")
8 | BOT_TOKEN = getenv("BOT_TOKEN")
9 | BOT_NAME = getenv("BOT_NAME")
10 |
11 | API_ID = int(getenv("API_ID"))
12 | API_HASH = getenv("API_HASH")
13 |
14 | DURATION_LIMIT = int(getenv("DURATION_LIMIT", "7"))
15 |
16 | COMMAND_PREFIXES = list(getenv("COMMAND_PREFIXES", "/ !").split())
17 |
18 | SUDO_USERS = list(map(int, getenv("SUDO_USERS").split()))
19 |
--------------------------------------------------------------------------------
/converter/__init__.py:
--------------------------------------------------------------------------------
1 | from os import listdir, mkdir
2 |
3 | if "raw_files" not in listdir(): mkdir("raw_files")
4 |
5 | from .converter import convert
6 |
--------------------------------------------------------------------------------
/converter/converter.py:
--------------------------------------------------------------------------------
1 | from os import path
2 | import asyncio
3 |
4 | from helpers.errors import FFmpegReturnCodeError
5 |
6 |
7 | async def convert(file_path: str) -> str:
8 | out = path.basename(file_path)
9 | out = out.split(".")
10 | out[-1] = "raw"
11 | out = ".".join(out)
12 | out = path.basename(out)
13 | out = path.join("raw_files", out)
14 |
15 | if path.isfile(out):
16 | return out
17 |
18 | proc = await asyncio.create_subprocess_shell(
19 | f"ffmpeg -y -i {file_path} -f s16le -ac 1 -ar 48000 -acodec pcm_s16le {out}",
20 | asyncio.subprocess.PIPE,
21 | stderr=asyncio.subprocess.PIPE
22 | )
23 |
24 | await proc.communicate()
25 |
26 | if proc.returncode != 0:
27 | raise FFmpegReturnCodeError("FFmpeg did not return 0")
28 |
29 | return out
30 |
--------------------------------------------------------------------------------
/downloaders/__init__.py:
--------------------------------------------------------------------------------
1 | from .youtube import download
2 |
--------------------------------------------------------------------------------
/downloaders/youtube.py:
--------------------------------------------------------------------------------
1 | from os import path
2 |
3 | from youtube_dl import YoutubeDL
4 |
5 | from config import BOT_NAME as bn, DURATION_LIMIT
6 | from helpers.errors import DurationLimitError
7 |
8 | ydl_opts = {
9 | "format": "bestaudio/best",
10 | "geo-bypass": True,
11 | "nocheckcertificate": True,
12 | "outtmpl": "downloads/%(id)s.%(ext)s",
13 | }
14 | ydl = YoutubeDL(ydl_opts)
15 |
16 |
17 | def download(url: str) -> str:
18 | info = ydl.extract_info(url, False)
19 | duration = round(info["duration"] / 60)
20 |
21 | if duration > DURATION_LIMIT:
22 | raise DurationLimitError(
23 | f"❌ Videos longer than {DURATION_LIMIT} minute(s) aren't allowed, the provided video is {duration} minute(s)"
24 | )
25 |
26 | ydl.download([url])
27 | return path.join("downloads", f"{info['id']}.{info['ext']}")
28 |
--------------------------------------------------------------------------------
/etc/font.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Infinity-Bots/GroupMusicPlayerBot/7dd545714789e7e78004907351fab18a4b18c028/etc/font.otf
--------------------------------------------------------------------------------
/etc/foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Infinity-Bots/GroupMusicPlayerBot/7dd545714789e7e78004907351fab18a4b18c028/etc/foreground.png
--------------------------------------------------------------------------------
/etc/foreground_square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Infinity-Bots/GroupMusicPlayerBot/7dd545714789e7e78004907351fab18a4b18c028/etc/foreground_square.png
--------------------------------------------------------------------------------
/etc/tg_vc_bot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Infinity-Bots/GroupMusicPlayerBot/7dd545714789e7e78004907351fab18a4b18c028/etc/tg_vc_bot.png
--------------------------------------------------------------------------------
/etc/thumb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Infinity-Bots/GroupMusicPlayerBot/7dd545714789e7e78004907351fab18a4b18c028/etc/thumb.jpg
--------------------------------------------------------------------------------
/example.env:
--------------------------------------------------------------------------------
1 | SESSION_NAME=session # If you don't deploy with docker, keep it as is and if you do so it should be a session string generated by "python str.py"
2 | BOT_TOKEN=123456:abcdefghijklmnopqrstuv
3 | BOT_NAME=HELLBOT
4 | API_ID=123456
5 | API_HASH=abcdefghijklmnopqrstuv
6 | SUDO_USERS=1111 2222 # List of user IDs separated by space
7 | DURATION_LIMIT=10 # in minutes (default: 7)
8 |
--------------------------------------------------------------------------------
/handlers/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/handlers/admins.py:
--------------------------------------------------------------------------------
1 | from asyncio.queues import QueueEmpty
2 |
3 | from pyrogram import Client
4 | from pyrogram.types import Message
5 | from callsmusic import callsmusic
6 |
7 | from config import BOT_NAME as BN
8 | from helpers.filters import command, other_filters
9 | from helpers.decorators import errors, authorized_users_only
10 |
11 |
12 | @Client.on_message(command("pause") & other_filters)
13 | @errors
14 | @authorized_users_only
15 | async def pause(_, message: Message):
16 | if (
17 | message.chat.id not in callsmusic.pytgcalls.active_calls
18 | ) or (
19 | callsmusic.pytgcalls.active_calls[message.chat.id] == 'paused'
20 | ):
21 | await message.reply_text("❗ Nothing is playing!")
22 | else:
23 | callsmusic.pytgcalls.pause_stream(message.chat.id)
24 | await message.reply_text("▶️ Paused!")
25 |
26 |
27 | @Client.on_message(command("resume") & other_filters)
28 | @errors
29 | @authorized_users_only
30 | async def resume(_, message: Message):
31 | if (
32 | message.chat.id not in callsmusic.pytgcalls.active_calls
33 | ) or (
34 | callsmusic.pytgcalls.active_calls[message.chat.id] == 'playing'
35 | ):
36 | await message.reply_text("❗ Nothing is paused!")
37 | else:
38 | callsmusic.pytgcalls.resume_stream(message.chat.id)
39 | await message.reply_text("⏸ Resumed!")
40 |
41 |
42 | @Client.on_message(command("end") & other_filters)
43 | @errors
44 | @authorized_users_only
45 | async def stop(_, message: Message):
46 | if message.chat.id not in callsmusic.pytgcalls.active_calls:
47 | await message.reply_text("❗ Nothing is streaming!")
48 | else:
49 | try:
50 | callsmusic.queues.clear(message.chat.id)
51 | except QueueEmpty:
52 | pass
53 |
54 | callsmusic.pytgcalls.leave_group_call(message.chat.id)
55 | await message.reply_text("❌ Stopped streaming!")
56 |
57 |
58 | @Client.on_message(command("skip") & other_filters)
59 | @errors
60 | @authorized_users_only
61 | async def skip(_, message: Message):
62 | if message.chat.id not in callsmusic.pytgcalls.active_calls:
63 | await message.reply_text("❗ Nothing is playing to skip!")
64 | else:
65 | callsmusic.queues.task_done(message.chat.id)
66 |
67 | if callsmusic.queues.is_empty(message.chat.id):
68 | callsmusic.pytgcalls.leave_group_call(message.chat.id)
69 | else:
70 | callsmusic.pytgcalls.change_stream(
71 | message.chat.id,
72 | callsmusic.queues.get(message.chat.id)["file"]
73 | )
74 |
75 | await message.reply_text("➡️ Skipped the current song!")
76 |
--------------------------------------------------------------------------------
/handlers/chat_member_updated.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client
2 | from pyrogram.types import ChatMemberUpdated
3 |
4 | from cache import admins as cache
5 |
6 |
7 | @Client.on_chat_member_updated()
8 | async def chat_member_updated(_, chat_member_updated: ChatMemberUpdated):
9 | chat = chat_member_updated.chat.id
10 | new = chat_member_updated.new_chat_member
11 |
12 | if new.can_manage_voice_chats:
13 | if new.user.id not in cache.admins[chat]:
14 | cache.admins[chat].append(new.user.id)
15 | else:
16 | if new.user.id in cache.admins[chat]:
17 | cache.admins[chat].remove(new.user.id)
18 |
--------------------------------------------------------------------------------
/handlers/play.py:
--------------------------------------------------------------------------------
1 | import os
2 | from os import path
3 | from pyrogram import Client, filters
4 | from pyrogram.types import Message, Voice, InlineKeyboardButton, InlineKeyboardMarkup
5 | from pyrogram.errors import UserAlreadyParticipant
6 | from callsmusic import callsmusic, queues
7 | from callsmusic.callsmusic import client as USER
8 | from helpers.admins import get_administrators
9 | import requests
10 | import aiohttp
11 | import youtube_dl
12 | from youtube_search import YoutubeSearch
13 | import converter
14 | from downloaders import youtube
15 | from config import DURATION_LIMIT
16 | from helpers.filters import command
17 | from helpers.decorators import errors
18 | from helpers.errors import DurationLimitError
19 | from helpers.gets import get_url, get_file_name
20 | import aiofiles
21 | import ffmpeg
22 | from PIL import Image, ImageFont, ImageDraw
23 |
24 |
25 | def transcode(filename):
26 | ffmpeg.input(filename).output("input.raw", format='s16le', acodec='pcm_s16le', ac=2, ar='48k').overwrite_output().run()
27 | os.remove(filename)
28 |
29 | # Convert seconds to mm:ss
30 | def convert_seconds(seconds):
31 | seconds = seconds % (24 * 3600)
32 | seconds %= 3600
33 | minutes = seconds // 60
34 | seconds %= 60
35 | return "%02d:%02d" % (minutes, seconds)
36 |
37 |
38 | # Convert hh:mm:ss to seconds
39 | def time_to_seconds(time):
40 | stringt = str(time)
41 | return sum(int(x) * 60 ** i for i, x in enumerate(reversed(stringt.split(':'))))
42 |
43 |
44 | # Change image size
45 | def changeImageSize(maxWidth, maxHeight, image):
46 | widthRatio = maxWidth / image.size[0]
47 | heightRatio = maxHeight / image.size[1]
48 | newWidth = int(widthRatio * image.size[0])
49 | newHeight = int(heightRatio * image.size[1])
50 | newImage = image.resize((newWidth, newHeight))
51 | return newImage
52 |
53 | async def generate_cover(requested_by, title, views, duration, thumbnail):
54 | async with aiohttp.ClientSession() as session:
55 | async with session.get(thumbnail) as resp:
56 | if resp.status == 200:
57 | f = await aiofiles.open("background.png", mode="wb")
58 | await f.write(await resp.read())
59 | await f.close()
60 |
61 | image1 = Image.open("./background.png")
62 | image2 = Image.open("etc/foreground.png")
63 | image3 = changeImageSize(1280, 720, image1)
64 | image4 = changeImageSize(1280, 720, image2)
65 | image5 = image3.convert("RGBA")
66 | image6 = image4.convert("RGBA")
67 | Image.alpha_composite(image5, image6).save("temp.png")
68 | img = Image.open("temp.png")
69 | draw = ImageDraw.Draw(img)
70 | font = ImageFont.truetype("etc/font.otf", 32)
71 | draw.text((190, 550), f"Title: {title}", (255, 255, 255), font=font)
72 | draw.text(
73 | (190, 590), f"Duration: {duration}", (255, 255, 255), font=font
74 | )
75 | draw.text((190, 630), f"Views: {views}", (255, 255, 255), font=font)
76 | draw.text((190, 670),
77 | f"Added By: {requested_by}",
78 | (255, 255, 255),
79 | font=font,
80 | )
81 | img.save("final.png")
82 | os.remove("temp.png")
83 | os.remove("background.png")
84 |
85 |
86 |
87 |
88 | @Client.on_message(command("play")
89 | & filters.group
90 | & ~filters.edited
91 | & ~filters.forwarded
92 | & ~filters.via_bot)
93 | async def play(_, message: Message):
94 |
95 | lel = await message.reply("🔄 **Processing...**")
96 |
97 | administrators = await get_administrators(message.chat)
98 | chid = message.chat.id
99 |
100 | try:
101 | user = await USER.get_me()
102 | except:
103 | user.first_name = "Mizuki"
104 | usar = user
105 | wew = usar.id
106 | try:
107 | await _.get_chat_member(chid, wew)
108 | except:
109 | for administrator in administrators:
110 | if administrator == message.from_user.id:
111 | try:
112 | invitelink = await _.export_chat_invite_link(chid)
113 | except:
114 | await lel.edit(
115 | "Add me as admin of yor group first!")
116 | return
117 |
118 | try:
119 | await USER.join_chat(invitelink)
120 | await USER.send_message(
121 | message.chat.id, "**Mizuki Music assistant joined this group for play music 🎵**")
122 |
123 | except UserAlreadyParticipant:
124 | pass
125 | except Exception:
126 | await lel.edit(
127 | f"🛑 Flood Wait Error 🛑 \n\Hey {user.first_name}, assistant userbot couldn't join your group due to heavy join requests. Make sure userbot is not banned in group and try again later!")
128 | try:
129 | await USER.get_chat(chid)
130 | except:
131 | await lel.edit(
132 | f"Hey {user.first_name}, assistant userbot is not in this chat, ask admin to send /play command for first time to add it.")
133 | return
134 |
135 | audio = (message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None
136 | url = get_url(message)
137 |
138 | if audio:
139 | if round(audio.duration / 60) > DURATION_LIMIT:
140 | raise DurationLimitError(
141 | f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!"
142 | )
143 |
144 | file_name = get_file_name(audio)
145 | title = file_name
146 | thumb_name = "https://telegra.ph/file/caeb50039026a746e7252.jpg"
147 | thumbnail = thumb_name
148 | duration = round(audio.duration / 60)
149 | views = "Locally added"
150 |
151 | keyboard = InlineKeyboardMarkup(
152 | [
153 | [
154 | InlineKeyboardButton(
155 | text="Channel 🔊",
156 | url="https://t.me/Infinity_BOTs")
157 |
158 | ]
159 | ]
160 | )
161 |
162 | requested_by = message.from_user.first_name
163 | await generate_cover(requested_by, title, views, duration, thumbnail)
164 | file_path = await converter.convert(
165 | (await message.reply_to_message.download(file_name))
166 | if not path.isfile(path.join("downloads", file_name)) else file_name
167 | )
168 |
169 | elif url:
170 | try:
171 | results = YoutubeSearch(url, max_results=1).to_dict()
172 | # print results
173 | title = results[0]["title"]
174 | thumbnail = results[0]["thumbnails"][0]
175 | thumb_name = f'thumb{title}.jpg'
176 | thumb = requests.get(thumbnail, allow_redirects=True)
177 | open(thumb_name, 'wb').write(thumb.content)
178 | duration = results[0]["duration"]
179 | url_suffix = results[0]["url_suffix"]
180 | views = results[0]["views"]
181 | durl = url
182 | durl = durl.replace("youtube", "youtubepp")
183 |
184 | secmul, dur, dur_arr = 1, 0, duration.split(':')
185 | for i in range(len(dur_arr)-1, -1, -1):
186 | dur += (int(dur_arr[i]) * secmul)
187 | secmul *= 60
188 |
189 | keyboard = InlineKeyboardMarkup(
190 | [
191 | [
192 | InlineKeyboardButton(
193 | text="YouTube 🎬",
194 | url=f"{url}"),
195 | InlineKeyboardButton(
196 | text="Download 📥",
197 | url=f"{durl}")
198 |
199 | ]
200 | ]
201 | )
202 | except Exception as e:
203 | title = "NaN"
204 | thumb_name = "https://telegra.ph/file/638c20c44ca418c8b2178.jpg"
205 | duration = "NaN"
206 | views = "NaN"
207 | keyboard = InlineKeyboardMarkup(
208 | [
209 | [
210 | InlineKeyboardButton(
211 | text="YouTube 🎬",
212 | url=f"https://youtube.com")
213 |
214 | ]
215 | ]
216 | )
217 | if (dur / 60) > DURATION_LIMIT:
218 | await lel.edit(f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!")
219 | return
220 | requested_by = message.from_user.first_name
221 | await generate_cover(requested_by, title, views, duration, thumbnail)
222 | file_path = await converter.convert(youtube.download(url))
223 | else:
224 | if len(message.command) < 2:
225 | return await lel.edit("🧐 **What's the song you want to play?**")
226 | await lel.edit("🔎 **Finding the song...**")
227 | query = message.text.split(None, 1)[1]
228 | # print(query)
229 | await lel.edit("🎵 **Processing sounds...**")
230 | try:
231 | results = YoutubeSearch(query, max_results=1).to_dict()
232 | url = f"https://youtube.com{results[0]['url_suffix']}"
233 | # print results
234 | title = results[0]["title"]
235 | thumbnail = results[0]["thumbnails"][0]
236 | thumb_name = f'thumb{title}.jpg'
237 | thumb = requests.get(thumbnail, allow_redirects=True)
238 | open(thumb_name, 'wb').write(thumb.content)
239 | duration = results[0]["duration"]
240 | url_suffix = results[0]["url_suffix"]
241 | views = results[0]["views"]
242 | durl = url
243 | durl = durl.replace("youtube", "youtubepp")
244 |
245 | secmul, dur, dur_arr = 1, 0, duration.split(':')
246 | for i in range(len(dur_arr)-1, -1, -1):
247 | dur += (int(dur_arr[i]) * secmul)
248 | secmul *= 60
249 |
250 | except Exception as e:
251 | await lel.edit(
252 | "❌ Song not found.\n\nTry another song or maybe spell it properly."
253 | )
254 | print(str(e))
255 | return
256 |
257 | keyboard = InlineKeyboardMarkup(
258 | [
259 | [
260 | InlineKeyboardButton(
261 | text="YouTube 🎬",
262 | url=f"{url}"),
263 | InlineKeyboardButton(
264 | text="Download 📥",
265 | url=f"{durl}")
266 |
267 | ]
268 | ]
269 | )
270 |
271 | if (dur / 60) > DURATION_LIMIT:
272 | await lel.edit(f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!")
273 | return
274 | requested_by = message.from_user.first_name
275 | await generate_cover(requested_by, title, views, duration, thumbnail)
276 | file_path = await converter.convert(youtube.download(url))
277 |
278 | if message.chat.id in callsmusic.pytgcalls.active_calls:
279 | position = await queues.put(message.chat.id, file=file_path)
280 | await message.reply_photo(
281 | photo="final.png",
282 | caption="**🎵 Song:** {}\n**🕒 Duration:** {} min\n**👤 Added By:** {}\n\n**#⃣ Queued Position:** {}".format(
283 | title, duration, message.from_user.mention(), position
284 | ),
285 | reply_markup=keyboard)
286 | os.remove("final.png")
287 | return await lel.delete()
288 | else:
289 | callsmusic.pytgcalls.join_group_call(message.chat.id, file_path)
290 | await message.reply_photo(
291 | photo="final.png",
292 | reply_markup=keyboard,
293 | caption="**🎵 Song:** {}\n**🕒 Duration:** {} min\n**👤 Added By:** {}\n\n**▶️ Now Playing at `{}`...**".format(
294 | title, duration, message.from_user.mention(), message.chat.title
295 | ), )
296 | os.remove("final.png")
297 | return await lel.delete()
298 |
--------------------------------------------------------------------------------
/handlers/private.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client, filters
2 | from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
3 |
4 | from config import BOT_NAME as bn
5 | from helpers.filters import other_filters2
6 |
7 |
8 | @Client.on_message(other_filters2)
9 | async def start(_, message: Message):
10 | await message.reply_sticker("CAACAgQAAx0CTv65QgABBfJlYF6VCrGMm6OJ23AxHmD6qUSWESsAAhoQAAKm8XEeD5nrjz5IJFYeBA")
11 | await message.reply_text(
12 | f"""**Hey, I'm {bn} 🎵
13 |
14 | I can play music in your group's voice call. Developed by [Jason](https://t.me/ImJanindu).
15 |
16 | Add me to your group and play music freely!**
17 | """,
18 | reply_markup=InlineKeyboardMarkup(
19 | [
20 | [
21 | InlineKeyboardButton(
22 | "🛠 Source Code 🛠", url="https://github.com/Infinity-Bots/GroupMusicPlayerBot")
23 | ],[
24 | InlineKeyboardButton(
25 | "💬 Group", url="https://t.me/InfinityBOTs_Support"
26 | ),
27 | InlineKeyboardButton(
28 | "🔊 Channel", url="https://t.me/Infinity_BOTs"
29 | )
30 | ],[
31 | InlineKeyboardButton(
32 | "➕ Add To Your Group ➕", url="https://t.me/JEGroupMusicPlayerBot?startgroup=true"
33 | )]
34 | ]
35 | ),
36 | disable_web_page_preview=True
37 | )
38 |
39 | @Client.on_message(filters.command("start") & ~filters.private & ~filters.channel)
40 | async def gstart(_, message: Message):
41 | await message.reply_text("""**Group Music Player Online ✅**""",
42 | reply_markup=InlineKeyboardMarkup(
43 | [
44 | [
45 | InlineKeyboardButton(
46 | "🔊 Channel", url="https://t.me/Infinity_BOTs")
47 | ]
48 | ]
49 | )
50 | )
51 |
52 |
53 |
--------------------------------------------------------------------------------
/handlers/songs.py:
--------------------------------------------------------------------------------
1 | # Infinity Bots (https://t.me/Infinity_Bots)
2 |
3 | import os
4 | import aiohttp
5 | import asyncio
6 | import json
7 | import sys
8 | import time
9 | from youtubesearchpython import SearchVideos
10 | from pyrogram import filters, Client
11 | from youtube_dl import YoutubeDL
12 | from youtube_dl.utils import (
13 | ContentTooShortError,
14 | DownloadError,
15 | ExtractorError,
16 | GeoRestrictedError,
17 | MaxDownloadsReached,
18 | PostProcessingError,
19 | UnavailableVideoError,
20 | XAttrMetadataError,
21 | )
22 |
23 | @Client.on_message(filters.command("song") & ~filters.edited)
24 | async def song(client, message):
25 | cap = "@JEBotZ"
26 | url = message.text.split(None, 1)[1]
27 | rkp = await message.reply("Processing...")
28 | if not url:
29 | await rkp.edit("**What's the song you want?**\nUsage`/song `")
30 | search = SearchVideos(url, offset=1, mode="json", max_results=1)
31 | test = search.result()
32 | p = json.loads(test)
33 | q = p.get("search_result")
34 | try:
35 | url = q[0]["link"]
36 | except BaseException:
37 | return await rkp.edit("Failed to find that song.")
38 | type = "audio"
39 | if type == "audio":
40 | opts = {
41 | "format": "bestaudio",
42 | "addmetadata": True,
43 | "key": "FFmpegMetadata",
44 | "writethumbnail": True,
45 | "prefer_ffmpeg": True,
46 | "geo_bypass": True,
47 | "nocheckcertificate": True,
48 | "postprocessors": [
49 | {
50 | "key": "FFmpegExtractAudio",
51 | "preferredcodec": "mp3",
52 | "preferredquality": "320",
53 | }
54 | ],
55 | "outtmpl": "%(id)s.mp3",
56 | "quiet": True,
57 | "logtostderr": False,
58 | }
59 | song = True
60 | try:
61 | await rkp.edit("Downloading...")
62 | with YoutubeDL(opts) as rip:
63 | rip_data = rip.extract_info(url)
64 | except DownloadError as DE:
65 | await rkp.edit(f"`{str(DE)}`")
66 | return
67 | except ContentTooShortError:
68 | await rkp.edit("`The download content was too short.`")
69 | return
70 | except GeoRestrictedError:
71 | await rkp.edit(
72 | "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`"
73 | )
74 | return
75 | except MaxDownloadsReached:
76 | await rkp.edit("`Max-downloads limit has been reached.`")
77 | return
78 | except PostProcessingError:
79 | await rkp.edit("`There was an error during post processing.`")
80 | return
81 | except UnavailableVideoError:
82 | await rkp.edit("`Media is not available in the requested format.`")
83 | return
84 | except XAttrMetadataError as XAME:
85 | await rkp.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`")
86 | return
87 | except ExtractorError:
88 | await rkp.edit("`There was an error during info extraction.`")
89 | return
90 | except Exception as e:
91 | await rkp.edit(f"{str(type(e)): {str(e)}}")
92 | return
93 | time.time()
94 | if song:
95 | await rkp.edit("Uploading...") #ImJanindu
96 | lol = "./etc/thumb.jpg"
97 | lel = await message.reply_audio(
98 | f"{rip_data['id']}.mp3",
99 | duration=int(rip_data["duration"]),
100 | title=str(rip_data["title"]),
101 | performer=str(rip_data["uploader"]),
102 | thumb=lol,
103 | caption=cap) #JEBotZ
104 | await rkp.delete()
105 |
--------------------------------------------------------------------------------
/handlers/ytsearch.py:
--------------------------------------------------------------------------------
1 | # the logging things
2 | import logging
3 |
4 | from pyrogram.types import Message
5 | from search_engine_parser import GoogleSearch
6 | from youtube_search import YoutubeSearch
7 |
8 | from pyrogram import Client as app, filters
9 |
10 | logging.basicConfig(
11 | level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
12 | )
13 | logger = logging.getLogger(__name__)
14 |
15 | import pyrogram
16 |
17 | logging.getLogger("pyrogram").setLevel(logging.WARNING)
18 |
19 | @app.on_message(pyrogram.filters.command(["search"]))
20 | async def ytsearch(_, message: Message):
21 | try:
22 | if len(message.command) < 2:
23 | await message.reply_text("/search needs an argument!")
24 | return
25 | query = message.text.split(None, 1)[1]
26 | m = await message.reply_text("Searching....")
27 | results = YoutubeSearch(query, max_results=4).to_dict()
28 | i = 0
29 | text = ""
30 | while i < 4:
31 | text += f"Title - {results[i]['title']}\n"
32 | text += f"Duration - {results[i]['duration']}\n"
33 | text += f"Views - {results[i]['views']}\n"
34 | text += f"Channel - {results[i]['channel']}\n"
35 | text += f"https://youtube.com{results[i]['url_suffix']}\n\n"
36 | i += 1
37 | await m.edit(text, disable_web_page_preview=True)
38 | except Exception as e:
39 | await message.reply_text(str(e))
40 |
--------------------------------------------------------------------------------
/helpers/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/helpers/admins.py:
--------------------------------------------------------------------------------
1 | from typing import List
2 |
3 | from pyrogram.types import Chat, User
4 |
5 | import cache.admins
6 |
7 |
8 | async def get_administrators(chat: Chat) -> List[User]:
9 | get = cache.admins.get(chat.id)
10 |
11 | if get:
12 | return get
13 | else:
14 | administrators = await chat.get_members(filter="administrators")
15 | to_set = []
16 |
17 | for administrator in administrators:
18 | if administrator.can_manage_voice_chats:
19 | to_set.append(administrator.user.id)
20 |
21 | cache.admins.set(chat.id, to_set)
22 | return await get_administrators(chat)
23 |
--------------------------------------------------------------------------------
/helpers/decorators.py:
--------------------------------------------------------------------------------
1 | from typing import Callable
2 |
3 | from pyrogram import Client
4 | from pyrogram.types import Message
5 |
6 | from helpers.admins import get_administrators
7 | from config import SUDO_USERS
8 |
9 |
10 | def errors(func: Callable) -> Callable:
11 | async def decorator(client: Client, message: Message):
12 | try:
13 | return await func(client, message)
14 | except Exception as e:
15 | await message.reply(f"{type(e).__name__}: {e}")
16 |
17 | return decorator
18 |
19 |
20 | def authorized_users_only(func: Callable) -> Callable:
21 | async def decorator(client: Client, message: Message):
22 | if message.from_user.id in SUDO_USERS:
23 | return await func(client, message)
24 |
25 | administrators = await get_administrators(message.chat)
26 |
27 | for administrator in administrators:
28 | if administrator == message.from_user.id:
29 | return await func(client, message)
30 |
31 | return decorator
32 |
--------------------------------------------------------------------------------
/helpers/errors.py:
--------------------------------------------------------------------------------
1 | class DurationLimitError(Exception):
2 | pass
3 |
4 |
5 | class FFmpegReturnCodeError(Exception):
6 | pass
7 |
--------------------------------------------------------------------------------
/helpers/filters.py:
--------------------------------------------------------------------------------
1 | from typing import Union, List
2 |
3 | from pyrogram import filters
4 |
5 | from config import COMMAND_PREFIXES
6 |
7 | other_filters = filters.group & ~ filters.edited & ~ filters.via_bot & ~ filters.forwarded
8 | other_filters2 = filters.private & ~ filters.edited & ~ filters.via_bot & ~ filters.forwarded
9 |
10 |
11 | def command(commands: Union[str, List[str]]):
12 | return filters.command(commands, COMMAND_PREFIXES)
13 |
14 |
--------------------------------------------------------------------------------
/helpers/gets.py:
--------------------------------------------------------------------------------
1 | from typing import Union
2 |
3 | from pyrogram.types import Message, Audio, Voice
4 |
5 |
6 | def get_url(message_1: Message) -> Union[str, None]:
7 | messages = [message_1]
8 |
9 | if message_1.reply_to_message:
10 | messages.append(message_1.reply_to_message)
11 |
12 | text = ""
13 | offset = None
14 | length = None
15 |
16 | for message in messages:
17 | if offset:
18 | break
19 |
20 | if message.entities:
21 | for entity in message.entities:
22 | if entity.type == "url":
23 | text = message.text or message.caption
24 | offset, length = entity.offset, entity.length
25 | break
26 |
27 | if offset in (None,):
28 | return None
29 |
30 | return text[offset:offset + length]
31 |
32 |
33 | def get_file_name(audio: Union[Audio, Voice]):
34 | return f'{audio.file_unique_id}.{audio.file_name.split(".")[-1] if not isinstance(audio, Voice) else "ogg"}'
35 |
--------------------------------------------------------------------------------
/heroku.yml:
--------------------------------------------------------------------------------
1 | build:
2 | docker:
3 | worker: Dockerfile
4 | run:
5 | worker: python3 main.py
6 |
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client as Bot
2 |
3 | from callsmusic import run
4 | from config import API_ID, API_HASH, BOT_TOKEN
5 |
6 |
7 | bot = Bot(
8 | ":memory:",
9 | API_ID,
10 | API_HASH,
11 | bot_token=BOT_TOKEN,
12 | plugins=dict(root="handlers")
13 | )
14 |
15 | bot.start()
16 | run()
17 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pyrogram
2 | TgCrypto
3 | py-tgcalls==0.5.2
4 | python-dotenv
5 | youtube_dl
6 | youtube_search_python
7 | requests
8 | aiohttp
9 | aiofiles
10 | asyncio
11 | youtube_search
12 | search_engine_parser
13 | ffmpeg
14 | Pillow
15 | ujson
16 |
--------------------------------------------------------------------------------
/str.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from pyrogram import Client
4 |
5 |
6 | print("Enter your app information from my.telegram.org/apps below.")
7 |
8 |
9 | async def main():
10 | async with Client(":memory:", api_id=int(input("API ID:")), api_hash=input("API HASH:")) as app:
11 | print(await app.export_session_string())
12 |
13 |
14 | if __name__ == "__main__":
15 | loop = asyncio.get_event_loop()
16 | loop.run_until_complete(main())
17 |
--------------------------------------------------------------------------------