├── LICENSE ├── Procfile ├── README.md ├── Script.py ├── TechVJ ├── __init__.py ├── bot │ ├── TechVJ │ ├── __init__.py │ └── clients.py ├── server │ ├── TechVJ │ ├── __init__.py │ ├── exceptions.py │ └── stream_routes.py ├── template │ ├── TechVJ │ ├── dl.html │ └── req.html └── utils │ ├── TechVJ │ ├── config_parser.py │ ├── custom_dl.py │ ├── file_properties.py │ ├── file_size.py │ ├── human_readable.py │ ├── keepalive.py │ ├── render_template.py │ └── time_format.py ├── app.py ├── bot.py ├── clone_plugins ├── TechVJ ├── broadcast.py ├── commands.py ├── dbusers.py ├── genlink.py └── users_api.py ├── config.py ├── logging.conf ├── plugins ├── TechVJ ├── broadcast.py ├── clone.py ├── commands.py ├── database.py ├── dbusers.py ├── genlink.py └── users_api.py ├── requirements.txt ├── run cmd.txt └── runtime.txt /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 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: python3 bot.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Tech HEro-FILE-STORE-BOT Logo 3 |

4 |

5 | Tech HEro FILE STORE BOT 6 |

7 | 8 | ![Typing SVG](https://readme-typing-svg.herokuapp.com/?lines=Welcome+To+HEro-FILE-STORE-BOT;A+Highly+Advance+File+Store+Bot;Made+By+Yt-@Hero_botss!;With+Clone+Feature+Stream/Download+Link;Custom+Url+Shortner+Auto+Delete+Feature;A+Bot+With+Fully+Advanced+Feature!;Must+Give+Credit+To+Tech+HEro;Because+He+Public+The+Paid+Repo;Thank+You!) 9 |

10 | 11 | ## Features 12 | 13 |
Tap On Me For Bot Features 14 | 15 | - [x] Stram Feature Added With Many Player Support 16 | - [x] Custom Url Shortner Support Any User Can Add His Own Shortner 17 | - [x] Batch Support Added, Any User Can Use Batch By Making Bot Admin In His File Store Channel 18 | - [x] Clone Feature Added [ Premium Feature] 19 | - [x] Auto Delete Feature Added 20 | - [x] Custom Start Message With Picture And Buttons 21 | 22 |
23 | 24 | ## Environment Variables 25 | 26 |
Tap On Me For Environment Variable 27 | 28 | - `API_ID` : Get From [my.telegram.org](https://my.telegram.org) 29 | - `API_HASH` : Get From [my.telegram.org](https://my.telegram.org) 30 | - `BOT_TOKEN` : Get From [BotFather](https://telegram.me/BotFather) 31 | - `BOT_USERNAME` : Your Bot Username Without @ 32 | - `DB_URI` : Mongodb Database Url For Main Bot [Tutorial Watch Here](https://youtu.be/I36_OTWvT2w) 33 | - `CDB_URI` : Mongodb Database Url For Clone Bot [Tutorial Watch Here](https://youtu.be/I36_OTWvT2w) 34 | - `ADMINS` : It mean Admin/Owner Id For Broadcasting Message. 35 | - `LOG_CHANNEL` : Log channel id start with -100xxxxxx 36 | - `BIN_CHANNEL` : Bin channel id start with -100xxxxxx 37 | - `FILE_STORE_CHANNEL` : File Store Channel id start with -100xxxxxx 38 | - `FQDN` : Your Server App Link Without https:// 39 | - `AUTO_DELETE` : Time In Minutes 40 | - `AUTO_DELETE_TIME` : Time In Seconds 41 | - `PYTHON_VERSION` : This Variable Is Only For Render, Value IS `3.10.8` 42 | - `PORT` : This Variable Is Only For Render, Value IS `8080` 43 | 44 |
45 | 46 | ## See How Bot Look Like 47 | 48 |
Tap On Me For Demo Bot 49 | 50 | Bot Demo 51 | Bot Demo 52 | Bot Demo 53 | Bot Demo 54 | Bot Demo 55 |
56 | 57 | ## Command To Use Bot 58 | 59 |
Tap On Me For Bot Commands 60 | 61 | 🖍️ Main Bot Commands :- 62 | 63 | - `/start` : By This Command You Can Check Bot Is Alive Or Not 64 | - `/link` : By This Command You Can Generate A Shareable Link Of File By Replying This Command To That File 65 | - `/batch` : By This Command You Can Generate Multiple File Shareable Link At A Time [Use Like This /batch (first post link) (last post link)] 66 | - `/base_site` : By This Command You Can Set Your Url Shortner Domain [Use Like This /base_site domain.com] 67 | - `/api` : By This Command You Can Set Your Url Shortner Api [Use Like This /api (your api key)] 68 | - `/deletecloned` : By This Command You Can Delete Your Cloned Bot [Use Like This /deletecloned (your bot token)] 69 | - `/broadcast` : By Using This Command You Can Broadcast A Message To Your Bot User, Reply This Command To Broadcast Message [Owner Only Command] 70 | 71 | 🖍️ Clone Bot Commands :- 72 | 73 | - `/start` : By This Command You Can Check Bot Is Alive Or Not 74 | - `/link` : By This Command You Can Generate A Shareable Link Of File By Replying This Command To That File 75 | - `/base_site` : By This Command You Can Set Your Url Shortner Domain [Use Like This /base_site domain.com] 76 | - `/api` : By This Command You Can Set Your Url Shortner Api [Use Like This /api (your api key)] 77 | - `/broadcast` : By Using This Command You Can Broadcast A Message To Your Bot User, Reply This Command To Broadcast Message [Clone Bot Owner Only Command] 78 | 79 | 80 |
81 | 82 | ## Credit 83 | 84 |
Tap On Me For See Credit 85 | 86 | 💝 Credit Goes To [Tech HEro](https://telegram.me/Hero_botss) 87 | 88 | 🖍️ This Code Is Fully Written Or Coded And Public By [Tech HEro](https://telegram.me/Hero_botss) So Don't Forgot To Give Credit 89 | 90 | 💖 And Thank You So Much To All Who Help In This Journey 💕 91 | 92 | Copyright ©️ [Tech HEro](https://telegram.me/Hero_botss) 93 | 94 | 95 |
96 | 97 | ## About Owner 98 | 99 |
Tap On Me For See Details Of Owner 100 | 101 | - YouTube Channel : [Sasta Marvel](https://youtube.com/@sastamarvel01?si=KiYYZ5mByFO-O_fl) 102 | - Telegram Channel : [Sasta Marvel](https://t.me/Avatar_last_airbender_3_hindi) 103 | - Contact Link : [King HEro](https://telegram.me/Hero_botss) 104 | - Instagram Id Link : [Tech hEro](https://insta) 105 | 106 | 107 |
108 | 109 | 110 | ### Copyright ©️ [Tech HEro](https://telegram.me/Hero_botss) 111 | 112 | Selling This Repo Or Code Of This Repo For Money Is Strictly Prohibited 🚫 113 | 114 | -------------------------------------------------------------------------------- /Script.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class script(object): 5 | START_TXT = """Hᴇʟʟᴏ {},ᴍʏ ɴᴀᴍᴇ {},【ɪ ᴀᴍ ʟᴀᴛᴇꜱᴛ ᴀᴅᴠᴀɴᴄᴇᴅ】ᴀɴᴅ ᴘᴏᴡᴇʀꜰᴜʟ ꜰɪʟᴇ ꜱᴛᴏʀᴇ ʙᴏᴛ +└ᴄʟᴏɴᴇ ғᴇᴀᴛᴜʀᴇ┘+└sᴛʀᴇᴀᴍ / ᴅᴏᴡɴʟᴏᴀᴅ ʟɪɴᴋ ғᴇᴀᴛᴜʀᴇ┘+├ᴄᴜꜱᴛᴏᴍ ᴜʀʟ ꜱʜᴏʀᴛɴᴇʀ ꜱᴜᴘᴘᴏʀᴛ┤+ ᢵᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ sᴜᴘᴘᴏʀᴛ ᢴ ᢾᴀɴᴅ ʙᴇꜱᴛ ᴜɪ ᴘᴇʀꜰᴏʀᴍᴀɴᴄᴇᢿ Jᴏɪɴ [ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ](https://t.me/what_if_season_2_hindi_dubb)""" 6 | 7 | 8 | 9 | CAPTION = """📂 ғɪʟᴇɴᴀᴍᴇ : {file_name} 10 | 11 | Qury: more movie,anime,web-serires in hindi [Get Here](https://t.me/group_discd) 12 | 13 | 14 | sɪᴢᴇ ⚙️: {file_size} """ 15 | 16 | 17 | 18 | SHORTENER_API_MESSAGE = """Tᴏ ᴀᴅᴅ ᴏʀ ᴜᴘᴅᴀᴛᴇ ʏᴏᴜʀ Sʜᴏʀᴛɴᴇʀ Wᴇʙsɪᴛᴇ API, /api (ᴀᴘɪ) 19 | 20 | Ex: /api 𝟼LZǫ𝟾𝟻𝟷sXᴏғғғPHᴜɢɪKQǫ 21 | 22 | Cᴜʀʀᴇɴᴛ Wᴇʙsɪᴛᴇ: {base_site} 23 | 24 | Cᴜʀʀᴇɴᴛ Sʜᴏʀᴛᴇɴᴇʀ API: `{shortener_api}`""" 25 | 26 | 27 | 28 | CLONE_START_TXT = """Hᴇʟʟᴏ {},ᴍʏ ɴᴀᴍᴇ {},【ɪ ᴀᴍ ʟᴀᴛᴇꜱᴛ ᴀᴅᴠᴀɴᴄᴇᴅ】ᴀɴᴅ ᴘᴏᴡᴇʀꜰᴜʟ ꜰɪʟᴇ ꜱᴛᴏʀᴇ ʙᴏᴛ +├ᴄᴜꜱᴛᴏᴍ ᴜʀʟ ꜱʜᴏʀᴛɴᴇʀ ꜱᴜᴘᴘᴏʀᴛ┤+ ᢵᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ sᴜᴘᴘᴏʀᴛ ᢴ ᢾᴀɴᴅ ʙᴇꜱᴛ ᴜɪ ᴘᴇʀꜰᴏʀᴍᴀɴᴄᴇᢿ Jᴏɪɴ [ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ](https://t.me/what_if_season_2_hindi_dubb) 29 | 30 | ɪғ ʏᴏᴜ ᴡᴀɴᴛ ᴛʜɪs ғᴇᴀᴛᴜʀᴇ ᴛʜᴇɴ ᴄʀᴇᴀᴛᴇ ʏᴏᴜʀ ᴏᴡɴ ᴄʟᴏɴᴇ ʙᴏᴛ ғʀᴏᴍ ᴍʏ ᴘᴀʀᴇɴᴛ""" 31 | 32 | 33 | 34 | ABOUT_TXT = """ʜɪ ɪ ᴀᴍ ᴘᴇʀᴍᴀɴᴇɴᴛ ғɪʟᴇ sᴛᴏʀᴇ ʙᴏᴛ ᴡɪᴛʜ ᴄʟᴏɴᴇ ғᴇᴀᴛᴜʀᴇ + ᴄᴜsᴛᴏᴍ ᴜʀʟ sʜᴏʀᴛɴᴇʀ ɪᴛ ᴍᴇᴀɴs ᴀɴʏ ᴜsᴇʀ ᴄᴀɴ sᴇᴛ ʜɪs ᴜʀʟ sʜᴏʀᴛɴᴇʀ ᴀɴᴅ + ᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ. 35 | 36 | 🤖 ᴍʏ ɴᴀᴍᴇ: {} 37 | 38 | 📝 ʟᴀɴɢᴜᴀɢᴇ: 𝐏𝐲𝐭𝐡𝐨𝐧𝟑 39 | 40 | 📚 ʟɪʙʀᴀʀʏ: 𝐏𝐲𝐫𝐨𝐠𝐫𝐚𝐦 41 | 42 | 🧑🏻‍💻 ᴅᴇᴠᴇʟᴏᴘᴇʀ: 𝐓𝐞𝐜𝐡 43 | 44 | 👥 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ: 𝐒𝐮𝐩𝐩𝐨𝐫𝐭 45 | 46 | 📢 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ: 𝐔𝐩𝐝𝐚𝐭𝐞 47 | """ 48 | 49 | CABOUT_TXT = """ʜɪ ɪ ᴀᴍ ᴘᴇʀᴍᴀɴᴇɴᴛ ғɪʟᴇ sᴛᴏʀᴇ ʙᴏᴛ ᴡɪᴛʜ ᴄʟᴏɴᴇ ғᴇᴀᴛᴜʀᴇ + ᴄᴜsᴛᴏᴍ ᴜʀʟ sʜᴏʀᴛɴᴇʀ ɪᴛ ᴍᴇᴀɴs ᴀɴʏ ᴜsᴇʀ ᴄᴀɴ sᴇᴛ ʜɪs ᴜʀʟ sʜᴏʀᴛɴᴇʀ ᴀɴᴅ + ᴀᴜᴛᴏ ᴅᴇʟᴇᴛᴇ. 50 | 51 | 🤖 ᴍʏ ɴᴀᴍᴇ: {} 52 | 53 | 📝 ʟᴀɴɢᴜᴀɢᴇ: 𝐏𝐲𝐭𝐡𝐨𝐧𝟑 54 | 55 | 📚 ʟɪʙʀᴀʀʏ: 𝐏𝐲𝐫𝐨𝐠𝐫𝐚𝐦 56 | 57 | 🧑🏻‍💻 ᴅᴇᴠᴇʟᴏᴘᴇʀ: ᴅᴇᴠᴇʟᴏᴘᴇʀ 58 | """ 59 | 60 | 61 | 62 | CLONE_TXT = """ʜᴇʟʟᴏ {} 👋 63 | 64 | 1) sᴇɴᴅ /newbot ᴛᴏ @BotFather 65 | 2) ɢɪᴠᴇ ᴀ ɴᴀᴍᴇ ꜰᴏʀ ʏᴏᴜʀ ʙᴏᴛ. 66 | 3) ɢɪᴠᴇ ᴀ ᴜɴɪǫᴜᴇ ᴜsᴇʀɴᴀᴍᴇ. 67 | 4) ᴛʜᴇɴ ʏᴏᴜ ᴡɪʟʟ ɢᴇᴛ ᴀ ᴍᴇssᴀɢᴇ ᴡɪᴛʜ ʏᴏᴜʀ ʙᴏᴛ ᴛᴏᴋᴇɴ. 68 | 5) ꜰᴏʀᴡᴀʀᴅ ᴛʜᴀᴛ ᴍᴇssᴀɢᴇ ᴛᴏ ᴍᴇ. 69 | 70 | ᴛʜᴇɴ ɪ ᴀᴍ ᴛʀʏ ᴛᴏ ᴄʀᴇᴀᴛᴇ ᴀ ᴄᴏᴘʏ ʙᴏᴛ ᴏғ ᴍᴇ ғᴏʀ ʏᴏᴜ ᴏɴʟʏ 😌""" 71 | 72 | 73 | 74 | HELP_TXT = """💢 Hᴏᴡ Tᴏ Usᴇ Tʜɪs Bᴏᴛ ☺️ 75 | 76 | 🔻 /link - ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴠɪᴅᴇᴏ ᴏʀ ғɪʟᴇ ᴛᴏ ɢᴇᴛ sʜᴀʀᴀʙʟᴇ ʟɪɴᴋ 77 | 78 | 🔻 /batch - sᴇɴᴅ ғɪʀsᴛ ʟɪɴᴋ ᴏғ ғɪʟᴇ sᴛᴏʀᴇ ᴄʜᴀɴɴᴇʟ ᴘᴏsᴛ ᴛʜᴇɴ ʟᴀsᴛ ᴘᴏsᴛ ʟɪɴᴋ ᴀɴᴅ ᴍᴀᴋᴇ sᴜʀᴇ ʙᴏᴛ ɪs ᴀᴅᴍɪɴ ɪɴ ʏᴏᴜʀ ғɪʟᴇ sᴛᴏʀᴇ ᴄʜᴀɴɴᴇʟ. 79 | ᴇx - /batch https://t.me/what_if_season_2_hindi_dubb/13 https://t.me/what_if_season_2_hindi_dubb/14 80 | 81 | 🔻 /base_site - ᴜsᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ sᴇᴛ ᴜʀʟ sʜᴏʀᴛɴᴇʀ ʟɪɴᴋ ᴅᴏᴍᴀɪɴ 82 | ᴇx - /base_site ʏᴏᴜʀᴅᴏᴍᴀɪɴ.ᴄᴏᴍ 83 | 84 | 🔻 /api - sᴇᴛ ʏᴏᴜʀ ᴜʀʟ sʜᴏʀᴛɴᴇʀ ᴀᴄᴄᴏᴜɴᴛ ᴀᴘɪ 85 | ᴇx - /api ʙᴀᴏᴡɢᴡᴋʟᴀᴀʙᴀᴋʟ 86 | 87 | 🔻 /deletecloned - ᴜsᴇ ᴛʜɪs ғᴏʀ ᴅᴇʟᴇᴛᴇ ʏᴏᴜʀ ᴄʟᴏɴᴇ ʙᴏᴛ 88 | ᴇx - /deletecloned ʏᴏᴜʀʙᴏᴛᴛᴏᴋᴇɴ 89 | 90 | 🔻 /broadcast - ʀᴇᴘʟʏ ᴛᴏ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ᴀ ᴍᴇssᴀɢᴇ ᴛᴏ ʙʀᴏᴀᴅᴄᴀsᴛ (ʙᴏᴛ ᴏᴡɴᴇʀ ᴏɴʟʏ)""" 91 | 92 | 93 | 94 | 95 | CHELP_TXT = """💢 Hᴏᴡ Tᴏ Usᴇ Tʜɪs Bᴏᴛ ☺️ 96 | 97 | 🔻 /link - ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴠɪᴅᴇᴏ ᴏʀ ғɪʟᴇ ᴛᴏ ɢᴇᴛ sʜᴀʀᴀʙʟᴇ ʟɪɴᴋ 98 | 99 | 🔻 /base_site - ᴜsᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ sᴇᴛ ᴜʀʟ sʜᴏʀᴛɴᴇʀ ʟɪɴᴋ ᴅᴏᴍᴀɪɴ 100 | ᴇx - /base_site ʏᴏᴜʀᴅᴏᴍᴀɪɴ.ᴄᴏᴍ 101 | 102 | 🔻 /api - sᴇᴛ ʏᴏᴜʀ ᴜʀʟ sʜᴏʀᴛɴᴇʀ ᴀᴄᴄᴏᴜɴᴛ ᴀᴘɪ 103 | ᴇx - /api ʙᴀᴏᴡɢᴡᴋʟᴀᴀʙᴀᴋʟ 104 | 105 | 🔻 /broadcast - ʀᴇᴘʟʏ ᴛᴏ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ᴀ ᴍᴇssᴀɢᴇ ᴛᴏ ʙʀᴏᴀᴅᴄᴀsᴛ [ʙᴏᴛ ᴏᴡɴᴇʀ ᴏɴʟʏ](https://t.me/aapna_Movies) """ 106 | 107 | 108 | 109 | LOG_TEXT = """#NewUser 110 | 111 | ID - {} 112 | 113 | Nᴀᴍᴇ - {} 114 | """ 115 | RESTART_TXT = """ 116 | Bᴏᴛ Rᴇsᴛᴀʀᴛᴇᴅ ! 117 | 118 | 📅 Dᴀᴛᴇ : {} 119 | ⏰ Tɪᴍᴇ : {} 120 | 🌐 Tɪᴍᴇᴢᴏɴᴇ : Asia/Kolkata 121 | 🛠️ Bᴜɪʟᴅ Sᴛᴀᴛᴜs: v2.7.1 [ Sᴛᴀʙʟᴇ ]""" 122 | 123 | -------------------------------------------------------------------------------- /TechVJ/__init__.py: -------------------------------------------------------------------------------- 1 | import time 2 | StartTime = time.time() 3 | __version__ = 1.1 4 | -------------------------------------------------------------------------------- /TechVJ/bot/TechVJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TechVJ/bot/__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import logging.config 3 | logging.config.fileConfig('logging.conf') 4 | logging.getLogger().setLevel(logging.INFO) 5 | logging.getLogger("pyrogram").setLevel(logging.ERROR) 6 | logging.getLogger("imdbpy").setLevel(logging.ERROR) 7 | logging.basicConfig( 8 | level=logging.INFO, 9 | format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" 10 | ) 11 | logging.getLogger("aiohttp").setLevel(logging.ERROR) 12 | logging.getLogger("aiohttp.web").setLevel(logging.ERROR) 13 | 14 | from pyrogram import Client 15 | from config import * 16 | from typing import Union, Optional, AsyncGenerator 17 | from pyrogram import types 18 | from aiohttp import web 19 | 20 | from pyrogram import Client 21 | 22 | class StreamXBot(Client): 23 | 24 | def __init__(self): 25 | super().__init__( 26 | name="vjfiletolink", 27 | api_id=API_ID, 28 | api_hash=API_HASH, 29 | bot_token=BOT_TOKEN, 30 | workers=50, 31 | plugins={"root": "plugins"}, 32 | sleep_threshold=5, 33 | ) 34 | async def iter_messages( 35 | self, 36 | chat_id: Union[int, str], 37 | limit: int, 38 | offset: int = 0, 39 | ) -> Optional[AsyncGenerator["types.Message", None]]: 40 | """Iterate through a chat sequentially. 41 | This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving 42 | you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a 43 | single call. 44 | Parameters: 45 | chat_id (``int`` | ``str``): 46 | Unique identifier (int) or username (str) of the target chat. 47 | For your personal cloud (Saved Messages) you can simply use "me" or "self". 48 | For a contact that exists in your Telegram address book you can use his phone number (str). 49 | 50 | limit (``int``): 51 | Identifier of the last message to be returned. 52 | 53 | offset (``int``, *optional*): 54 | Identifier of the first message to be returned. 55 | Defaults to 0. 56 | Returns: 57 | ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects. 58 | Example: 59 | .. code-block:: python 60 | for message in app.iter_messages("pyrogram", 1, 15000): 61 | print(message.text) 62 | """ 63 | current = offset 64 | while True: 65 | new_diff = min(200, limit - current) 66 | if new_diff <= 0: 67 | return 68 | messages = await self.get_messages(chat_id, list(range(current, current+new_diff+1))) 69 | for message in messages: 70 | yield message 71 | current += 1 72 | 73 | StreamBot = StreamXBot() 74 | 75 | multi_clients = {} 76 | work_loads = {} 77 | -------------------------------------------------------------------------------- /TechVJ/bot/clients.py: -------------------------------------------------------------------------------- 1 | # (c) adarsh-goel 2 | 3 | import asyncio 4 | import logging 5 | from config import API_HASH, API_ID, Var 6 | from pyrogram import Client 7 | from TechVJ.utils.config_parser import TokenParser 8 | from . import multi_clients, work_loads, StreamBot 9 | 10 | 11 | async def initialize_clients(): 12 | multi_clients[0] = StreamBot 13 | work_loads[0] = 0 14 | all_tokens = TokenParser().parse_from_env() 15 | if not all_tokens: 16 | print("No additional clients found, using default client") 17 | return 18 | 19 | async def start_client(client_id, token): 20 | try: 21 | print(f"Starting - Client {client_id}") 22 | if client_id == len(all_tokens): 23 | await asyncio.sleep(2) 24 | print("This will take some time, please wait...") 25 | client = await Client( 26 | name=str(client_id), 27 | api_id=API_ID, 28 | api_hash=API_HASH, 29 | bot_token=token, 30 | sleep_threshold=Var.SLEEP_THRESHOLD, 31 | no_updates=True, 32 | in_memory=True 33 | ).start() 34 | work_loads[client_id] = 0 35 | return client_id, client 36 | except Exception: 37 | logging.error(f"Failed starting Client - {client_id} Error:", exc_info=True) 38 | 39 | clients = await asyncio.gather(*[start_client(i, token) for i, token in all_tokens.items()]) 40 | multi_clients.update(dict(clients)) 41 | if len(multi_clients) != 1: 42 | Var.MULTI_CLIENT = True 43 | print("Multi-Client Mode Enabled") 44 | else: 45 | print("No additional clients were initialized, using default client") 46 | -------------------------------------------------------------------------------- /TechVJ/server/TechVJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TechVJ/server/__init__.py: -------------------------------------------------------------------------------- 1 | from aiohttp import web 2 | from .stream_routes import routes 3 | 4 | 5 | async def web_server(): 6 | web_app = web.Application(client_max_size=30000000) 7 | web_app.add_routes(routes) 8 | return web_app 9 | -------------------------------------------------------------------------------- /TechVJ/server/exceptions.py: -------------------------------------------------------------------------------- 1 | 2 | class InvalidHash(Exception): 3 | message = "Invalid hash" 4 | 5 | class FIleNotFound(Exception): 6 | message = "File not found" -------------------------------------------------------------------------------- /TechVJ/server/stream_routes.py: -------------------------------------------------------------------------------- 1 | import re 2 | import time 3 | import math 4 | import logging 5 | import secrets 6 | import mimetypes 7 | from aiohttp import web 8 | from aiohttp.http_exceptions import BadStatusLine 9 | from TechVJ.bot import multi_clients, work_loads, StreamBot 10 | from TechVJ.server.exceptions import FIleNotFound, InvalidHash 11 | from TechVJ import StartTime, __version__ 12 | from ..utils.time_format import get_readable_time 13 | from ..utils.custom_dl import ByteStreamer 14 | from TechVJ.utils.render_template import render_page 15 | from config import Var 16 | 17 | 18 | routes = web.RouteTableDef() 19 | 20 | @routes.get("/", allow_head=True) 21 | async def root_route_handler(_): 22 | return web.json_response( 23 | { 24 | "server_status": "running", 25 | "uptime": get_readable_time(time.time() - StartTime), 26 | "telegram_bot": "@" + StreamBot.username, 27 | "connected_bots": len(multi_clients), 28 | "loads": dict( 29 | ("bot" + str(c + 1), l) 30 | for c, (_, l) in enumerate( 31 | sorted(work_loads.items(), key=lambda x: x[1], reverse=True) 32 | ) 33 | ), 34 | "version": __version__, 35 | } 36 | ) 37 | 38 | 39 | @routes.get(r"/watch/{path:\S+}", allow_head=True) 40 | async def stream_handler(request: web.Request): 41 | try: 42 | path = request.match_info["path"] 43 | match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path) 44 | if match: 45 | secure_hash = match.group(1) 46 | id = int(match.group(2)) 47 | else: 48 | id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1)) 49 | secure_hash = request.rel_url.query.get("hash") 50 | return web.Response(text=await render_page(id, secure_hash), content_type='text/html') 51 | except InvalidHash as e: 52 | raise web.HTTPForbidden(text=e.message) 53 | except FIleNotFound as e: 54 | raise web.HTTPNotFound(text=e.message) 55 | except (AttributeError, BadStatusLine, ConnectionResetError): 56 | pass 57 | except Exception as e: 58 | logging.critical(e.with_traceback(None)) 59 | raise web.HTTPInternalServerError(text=str(e)) 60 | 61 | @routes.get(r"/{path:\S+}", allow_head=True) 62 | async def stream_handler(request: web.Request): 63 | try: 64 | path = request.match_info["path"] 65 | match = re.search(r"^([a-zA-Z0-9_-]{6})(\d+)$", path) 66 | if match: 67 | secure_hash = match.group(1) 68 | id = int(match.group(2)) 69 | else: 70 | id = int(re.search(r"(\d+)(?:\/\S+)?", path).group(1)) 71 | secure_hash = request.rel_url.query.get("hash") 72 | return await media_streamer(request, id, secure_hash) 73 | except InvalidHash as e: 74 | raise web.HTTPForbidden(text=e.message) 75 | except FIleNotFound as e: 76 | raise web.HTTPNotFound(text=e.message) 77 | except (AttributeError, BadStatusLine, ConnectionResetError): 78 | pass 79 | except Exception as e: 80 | logging.critical(e.with_traceback(None)) 81 | raise web.HTTPInternalServerError(text=str(e)) 82 | 83 | class_cache = {} 84 | 85 | async def media_streamer(request: web.Request, id: int, secure_hash: str): 86 | range_header = request.headers.get("Range", 0) 87 | 88 | index = min(work_loads, key=work_loads.get) 89 | faster_client = multi_clients[index] 90 | 91 | if Var.MULTI_CLIENT: 92 | logging.info(f"Client {index} is now serving {request.remote}") 93 | 94 | if faster_client in class_cache: 95 | tg_connect = class_cache[faster_client] 96 | logging.debug(f"Using cached ByteStreamer object for client {index}") 97 | else: 98 | logging.debug(f"Creating new ByteStreamer object for client {index}") 99 | tg_connect = ByteStreamer(faster_client) 100 | class_cache[faster_client] = tg_connect 101 | logging.debug("before calling get_file_properties") 102 | file_id = await tg_connect.get_file_properties(id) 103 | logging.debug("after calling get_file_properties") 104 | 105 | if file_id.unique_id[:6] != secure_hash: 106 | logging.debug(f"Invalid hash for message with ID {id}") 107 | raise InvalidHash 108 | 109 | file_size = file_id.file_size 110 | 111 | if range_header: 112 | from_bytes, until_bytes = range_header.replace("bytes=", "").split("-") 113 | from_bytes = int(from_bytes) 114 | until_bytes = int(until_bytes) if until_bytes else file_size - 1 115 | else: 116 | from_bytes = request.http_range.start or 0 117 | until_bytes = (request.http_range.stop or file_size) - 1 118 | 119 | if (until_bytes > file_size) or (from_bytes < 0) or (until_bytes < from_bytes): 120 | return web.Response( 121 | status=416, 122 | body="416: Range not satisfiable", 123 | headers={"Content-Range": f"bytes */{file_size}"}, 124 | ) 125 | 126 | chunk_size = 1024 * 1024 127 | until_bytes = min(until_bytes, file_size - 1) 128 | 129 | offset = from_bytes - (from_bytes % chunk_size) 130 | first_part_cut = from_bytes - offset 131 | last_part_cut = until_bytes % chunk_size + 1 132 | 133 | req_length = until_bytes - from_bytes + 1 134 | part_count = math.ceil(until_bytes / chunk_size) - math.floor(offset / chunk_size) 135 | body = tg_connect.yield_file( 136 | file_id, index, offset, first_part_cut, last_part_cut, part_count, chunk_size 137 | ) 138 | 139 | mime_type = file_id.mime_type 140 | file_name = file_id.file_name 141 | disposition = "attachment" 142 | 143 | if mime_type: 144 | if not file_name: 145 | try: 146 | file_name = f"{secrets.token_hex(2)}.{mime_type.split('/')[1]}" 147 | except (IndexError, AttributeError): 148 | file_name = f"{secrets.token_hex(2)}.unknown" 149 | else: 150 | if file_name: 151 | mime_type = mimetypes.guess_type(file_id.file_name) 152 | else: 153 | mime_type = "application/octet-stream" 154 | file_name = f"{secrets.token_hex(2)}.unknown" 155 | 156 | return web.Response( 157 | status=206 if range_header else 200, 158 | body=body, 159 | headers={ 160 | "Content-Type": f"{mime_type}", 161 | "Content-Range": f"bytes {from_bytes}-{until_bytes}/{file_size}", 162 | "Content-Length": str(req_length), 163 | "Content-Disposition": f'{disposition}; filename="{file_name}"', 164 | "Accept-Ranges": "bytes", 165 | }, 166 | ) 167 | -------------------------------------------------------------------------------- /TechVJ/template/TechVJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TechVJ/template/dl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | %s | Tech VJ 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 135 | 136 |
137 |
138 | 139 |
140 |
141 |

142 | 143 | %s 144 | 145 |

146 |
147 |
148 |
149 | 150 | 160 | 161 |
162 |
163 | 164 |
165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 |
200 | 201 | 202 |
203 |
204 | 207 |
208 |
209 | 212 |
213 |
214 | 222 |
223 | 224 | 225 |
226 |
227 |
228 |
229 | 230 |
231 |
232 |
233 |
234 |
235 |
236 | 237 | © Copyright : 241 | Tech VJ 242 | 243 | All right reserved 244 |
245 |
246 | 247 | 248 | 272 | 273 | 276 | 285 | 286 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /TechVJ/template/req.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{file_name}} | Tech VJ 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 134 | 135 |
136 | 137 | 138 |
139 | 140 |
141 |
142 |

143 | 144 | {{file_name}} 145 | 146 |

147 |
148 |
149 | 150 |
151 |
152 | 155 |
156 |
157 | 158 | 159 |
160 |
161 | 162 |
163 |

Play with...

164 |
165 |
166 |
167 | 168 | VLC Player 169 |
170 |
171 | 172 | Mx Player 173 |
174 |
175 | 176 | Play-it 177 |
178 |
179 | 180 | km Player 181 |
182 |
183 | 184 | 185 | 186 | S Player 187 |
188 | 189 |
190 | 191 | 192 | 193 | 194 | HD Player(4K) 195 |
196 |
197 | Download Now 198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 | Video not playing ? possibly because your browser or the player doesn't support codec please download and watch. 206 |
207 |
208 |
209 |
210 |
211 |
212 | If you find any broken links then please contact Tech VJ 213 |
214 |
215 |
216 | 217 |
218 | 219 |
220 |
221 | 222 |
223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 |
258 | 259 | 260 |
261 |
262 | 265 |
266 |
267 | 270 |
271 |
272 | 280 |
281 | 282 | 283 |
284 |
285 |
286 |
287 | 288 |
289 |
290 |
291 |
292 |
293 |
294 | 295 | © Copyright : 299 | Tech VJ 300 | 301 | All right reserved 302 |
303 |
304 | 305 | 306 | 307 | 310 | 319 | 320 | 321 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 366 | 367 | 368 | 369 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | -------------------------------------------------------------------------------- /TechVJ/utils/TechVJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TechVJ/utils/config_parser.py: -------------------------------------------------------------------------------- 1 | from os import environ 2 | from typing import Dict, Optional 3 | 4 | 5 | class TokenParser: 6 | def __init__(self, config_file: Optional[str] = None): 7 | self.tokens = {} 8 | self.config_file = config_file 9 | 10 | def parse_from_env(self) -> Dict[int, str]: 11 | self.tokens = dict( 12 | (c + 1, t) 13 | for c, (_, t) in enumerate( 14 | filter( 15 | lambda n: n[0].startswith("MULTI_TOKEN"), sorted(environ.items()) 16 | ) 17 | ) 18 | ) 19 | return self.tokens 20 | -------------------------------------------------------------------------------- /TechVJ/utils/custom_dl.py: -------------------------------------------------------------------------------- 1 | import math 2 | import asyncio 3 | import logging 4 | from config import Var 5 | from typing import Dict, Union 6 | from TechVJ.bot import work_loads 7 | from pyrogram import Client, utils, raw 8 | from .file_properties import get_file_ids 9 | from pyrogram.session import Session, Auth 10 | from pyrogram.errors import AuthBytesInvalid 11 | from TechVJ.server.exceptions import FIleNotFound 12 | from pyrogram.file_id import FileId, FileType, ThumbnailSource 13 | 14 | 15 | class ByteStreamer: 16 | def __init__(self, client: Client): 17 | """A custom class that holds the cache of a specific client and class functions. 18 | attributes: 19 | client: the client that the cache is for. 20 | cached_file_ids: a dict of cached file IDs. 21 | cached_file_properties: a dict of cached file properties. 22 | 23 | functions: 24 | generate_file_properties: returns the properties for a media of a specific message contained in Tuple. 25 | generate_media_session: returns the media session for the DC that contains the media file. 26 | yield_file: yield a file from telegram servers for streaming. 27 | 28 | This is a modified version of the 29 | Thanks to Eyaadh 30 | """ 31 | self.clean_timer = 30 * 60 32 | self.client: Client = client 33 | self.cached_file_ids: Dict[int, FileId] = {} 34 | asyncio.create_task(self.clean_cache()) 35 | 36 | async def get_file_properties(self, id: int) -> FileId: 37 | """ 38 | Returns the properties of a media of a specific message in a FIleId class. 39 | if the properties are cached, then it'll return the cached results. 40 | or it'll generate the properties from the Message ID and cache them. 41 | """ 42 | if id not in self.cached_file_ids: 43 | await self.generate_file_properties(id) 44 | logging.debug(f"Cached file properties for message with ID {id}") 45 | return self.cached_file_ids[id] 46 | 47 | async def generate_file_properties(self, id: int) -> FileId: 48 | """ 49 | Generates the properties of a media file on a specific message. 50 | returns ths properties in a FIleId class. 51 | """ 52 | file_id = await get_file_ids(self.client, Var.BIN_CHANNEL, id) 53 | logging.debug(f"Generated file ID and Unique ID for message with ID {id}") 54 | if not file_id: 55 | logging.debug(f"Message with ID {id} not found") 56 | raise FIleNotFound 57 | self.cached_file_ids[id] = file_id 58 | logging.debug(f"Cached media message with ID {id}") 59 | return self.cached_file_ids[id] 60 | 61 | async def generate_media_session(self, client: Client, file_id: FileId) -> Session: 62 | """ 63 | Generates the media session for the DC that contains the media file. 64 | This is required for getting the bytes from Telegram servers. 65 | """ 66 | 67 | media_session = client.media_sessions.get(file_id.dc_id, None) 68 | 69 | if media_session is None: 70 | if file_id.dc_id != await client.storage.dc_id(): 71 | media_session = Session( 72 | client, 73 | file_id.dc_id, 74 | await Auth( 75 | client, file_id.dc_id, await client.storage.test_mode() 76 | ).create(), 77 | await client.storage.test_mode(), 78 | is_media=True, 79 | ) 80 | await media_session.start() 81 | 82 | for _ in range(6): 83 | exported_auth = await client.invoke( 84 | raw.functions.auth.ExportAuthorization(dc_id=file_id.dc_id) 85 | ) 86 | 87 | try: 88 | await media_session.send( 89 | raw.functions.auth.ImportAuthorization( 90 | id=exported_auth.id, bytes=exported_auth.bytes 91 | ) 92 | ) 93 | break 94 | except AuthBytesInvalid: 95 | logging.debug( 96 | f"Invalid authorization bytes for DC {file_id.dc_id}" 97 | ) 98 | continue 99 | else: 100 | await media_session.stop() 101 | raise AuthBytesInvalid 102 | else: 103 | media_session = Session( 104 | client, 105 | file_id.dc_id, 106 | await client.storage.auth_key(), 107 | await client.storage.test_mode(), 108 | is_media=True, 109 | ) 110 | await media_session.start() 111 | logging.debug(f"Created media session for DC {file_id.dc_id}") 112 | client.media_sessions[file_id.dc_id] = media_session 113 | else: 114 | logging.debug(f"Using cached media session for DC {file_id.dc_id}") 115 | return media_session 116 | 117 | 118 | @staticmethod 119 | async def get_location(file_id: FileId) -> Union[raw.types.InputPhotoFileLocation, 120 | raw.types.InputDocumentFileLocation, 121 | raw.types.InputPeerPhotoFileLocation,]: 122 | """ 123 | Returns the file location for the media file. 124 | """ 125 | file_type = file_id.file_type 126 | 127 | if file_type == FileType.CHAT_PHOTO: 128 | if file_id.chat_id > 0: 129 | peer = raw.types.InputPeerUser( 130 | user_id=file_id.chat_id, access_hash=file_id.chat_access_hash 131 | ) 132 | else: 133 | if file_id.chat_access_hash == 0: 134 | peer = raw.types.InputPeerChat(chat_id=-file_id.chat_id) 135 | else: 136 | peer = raw.types.InputPeerChannel( 137 | channel_id=utils.get_channel_id(file_id.chat_id), 138 | access_hash=file_id.chat_access_hash, 139 | ) 140 | 141 | location = raw.types.InputPeerPhotoFileLocation( 142 | peer=peer, 143 | volume_id=file_id.volume_id, 144 | local_id=file_id.local_id, 145 | big=file_id.thumbnail_source == ThumbnailSource.CHAT_PHOTO_BIG, 146 | ) 147 | elif file_type == FileType.PHOTO: 148 | location = raw.types.InputPhotoFileLocation( 149 | id=file_id.media_id, 150 | access_hash=file_id.access_hash, 151 | file_reference=file_id.file_reference, 152 | thumb_size=file_id.thumbnail_size, 153 | ) 154 | else: 155 | location = raw.types.InputDocumentFileLocation( 156 | id=file_id.media_id, 157 | access_hash=file_id.access_hash, 158 | file_reference=file_id.file_reference, 159 | thumb_size=file_id.thumbnail_size, 160 | ) 161 | return location 162 | 163 | async def yield_file( 164 | self, 165 | file_id: FileId, 166 | index: int, 167 | offset: int, 168 | first_part_cut: int, 169 | last_part_cut: int, 170 | part_count: int, 171 | chunk_size: int, 172 | ) -> Union[str, None]: 173 | """ 174 | Custom generator that yields the bytes of the media file. 175 | Modded from 176 | Thanks to Eyaadh 177 | """ 178 | client = self.client 179 | work_loads[index] += 1 180 | logging.debug(f"Starting to yielding file with client {index}.") 181 | media_session = await self.generate_media_session(client, file_id) 182 | 183 | current_part = 1 184 | location = await self.get_location(file_id) 185 | 186 | try: 187 | r = await media_session.send( 188 | raw.functions.upload.GetFile( 189 | location=location, offset=offset, limit=chunk_size 190 | ), 191 | ) 192 | if isinstance(r, raw.types.upload.File): 193 | while True: 194 | chunk = r.bytes 195 | if not chunk: 196 | break 197 | elif part_count == 1: 198 | yield chunk[first_part_cut:last_part_cut] 199 | elif current_part == 1: 200 | yield chunk[first_part_cut:] 201 | elif current_part == part_count: 202 | yield chunk[:last_part_cut] 203 | else: 204 | yield chunk 205 | 206 | current_part += 1 207 | offset += chunk_size 208 | 209 | if current_part > part_count: 210 | break 211 | 212 | r = await media_session.send( 213 | raw.functions.upload.GetFile( 214 | location=location, offset=offset, limit=chunk_size 215 | ), 216 | ) 217 | except (TimeoutError, AttributeError): 218 | pass 219 | finally: 220 | logging.debug("Finished yielding file with {current_part} parts.") 221 | work_loads[index] -= 1 222 | 223 | 224 | async def clean_cache(self) -> None: 225 | """ 226 | function to clean the cache to reduce memory usage 227 | """ 228 | while True: 229 | await asyncio.sleep(self.clean_timer) 230 | self.cached_file_ids.clear() 231 | logging.debug("Cleaned the cache") 232 | -------------------------------------------------------------------------------- /TechVJ/utils/file_properties.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client 2 | from typing import Any, Optional 3 | from pyrogram.types import Message 4 | from pyrogram.file_id import FileId 5 | from pyrogram.raw.types.messages import Messages 6 | from TechVJ.server.exceptions import FIleNotFound 7 | 8 | 9 | async def parse_file_id(message: "Message") -> Optional[FileId]: 10 | media = get_media_from_message(message) 11 | if media: 12 | return FileId.decode(media.file_id) 13 | 14 | async def parse_file_unique_id(message: "Messages") -> Optional[str]: 15 | media = get_media_from_message(message) 16 | if media: 17 | return media.file_unique_id 18 | 19 | async def get_file_ids(client: Client, chat_id: int, id: int) -> Optional[FileId]: 20 | message = await client.get_messages(chat_id, id) 21 | if message.empty: 22 | raise FIleNotFound 23 | media = get_media_from_message(message) 24 | file_unique_id = await parse_file_unique_id(message) 25 | file_id = await parse_file_id(message) 26 | setattr(file_id, "file_size", getattr(media, "file_size", 0)) 27 | setattr(file_id, "mime_type", getattr(media, "mime_type", "")) 28 | setattr(file_id, "file_name", getattr(media, "file_name", "")) 29 | setattr(file_id, "unique_id", file_unique_id) 30 | return file_id 31 | 32 | def get_media_from_message(message: "Message") -> Any: 33 | media_types = ( 34 | "audio", 35 | "document", 36 | "photo", 37 | "sticker", 38 | "animation", 39 | "video", 40 | "voice", 41 | "video_note", 42 | ) 43 | for attr in media_types: 44 | media = getattr(message, attr, None) 45 | if media: 46 | return media 47 | 48 | 49 | def get_hash(media_msg: Message) -> str: 50 | media = get_media_from_message(media_msg) 51 | return getattr(media, "file_unique_id", "")[:6] 52 | 53 | def get_name(media_msg: Message) -> str: 54 | media = get_media_from_message(media_msg) 55 | return getattr(media, 'file_name', "") 56 | 57 | def get_media_file_size(m): 58 | media = get_media_from_message(m) 59 | return getattr(media, "file_size", 0) 60 | -------------------------------------------------------------------------------- /TechVJ/utils/file_size.py: -------------------------------------------------------------------------------- 1 | def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']): 2 | """ Returns a human readable string representation of bytes """ 3 | return str(bytes) + units[0] if int(bytes) < 1024 else human_size(int(bytes)>>10, units[1:]) 4 | -------------------------------------------------------------------------------- /TechVJ/utils/human_readable.py: -------------------------------------------------------------------------------- 1 | def humanbytes(size): 2 | # https://stackoverflow.com/a/49361727/4723940 3 | # 2**10 = 1024 4 | if not size: 5 | return "" 6 | power = 2**10 7 | n = 0 8 | Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'} 9 | while size > power: 10 | size /= power 11 | n += 1 12 | return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' 13 | -------------------------------------------------------------------------------- /TechVJ/utils/keepalive.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import logging 3 | import aiohttp 4 | import traceback 5 | from config import Var 6 | 7 | 8 | async def ping_server(): 9 | sleep_time = Var.PING_INTERVAL 10 | while True: 11 | await asyncio.sleep(sleep_time) 12 | try: 13 | async with aiohttp.ClientSession( 14 | timeout=aiohttp.ClientTimeout(total=10) 15 | ) as session: 16 | async with session.get(Var.URL) as resp: 17 | logging.info("Pinged server with response: {}".format(resp.status)) 18 | except TimeoutError: 19 | logging.warning("Couldn't connect to the site URL..!") 20 | except Exception: 21 | traceback.print_exc() 22 | -------------------------------------------------------------------------------- /TechVJ/utils/render_template.py: -------------------------------------------------------------------------------- 1 | import jinja2 2 | from config import Var 3 | from TechVJ.bot import StreamBot 4 | from TechVJ.utils.human_readable import humanbytes 5 | from TechVJ.utils.file_properties import get_file_ids 6 | from TechVJ.server.exceptions import InvalidHash 7 | import urllib.parse 8 | import logging 9 | import aiohttp 10 | 11 | 12 | async def render_page(id, secure_hash, src=None): 13 | file = await StreamBot.get_messages(int(Var.BIN_CHANNEL), int(id)) 14 | file_data = await get_file_ids(StreamBot, int(Var.BIN_CHANNEL), int(id)) 15 | if file_data.unique_id[:6] != secure_hash: 16 | logging.debug(f"link hash: {secure_hash} - {file_data.unique_id[:6]}") 17 | logging.debug(f"Invalid hash for message with - ID {id}") 18 | raise InvalidHash 19 | 20 | src = urllib.parse.urljoin( 21 | Var.URL, 22 | f"{id}/{urllib.parse.quote_plus(file_data.file_name)}?hash={secure_hash}", 23 | ) 24 | 25 | tag = file_data.mime_type.split("/")[0].strip() 26 | file_size = humanbytes(file_data.file_size) 27 | if tag in ["video", "audio"]: 28 | template_file = "TechVJ/template/req.html" 29 | else: 30 | template_file = "TechVJ/template/dl.html" 31 | async with aiohttp.ClientSession() as s: 32 | async with s.get(src) as u: 33 | file_size = humanbytes(int(u.headers.get("Content-Length"))) 34 | 35 | with open(template_file) as f: 36 | template = jinja2.Template(f.read()) 37 | 38 | file_name = file_data.file_name.replace("_", " ") 39 | 40 | return template.render( 41 | file_name=file_name, 42 | file_url=src, 43 | file_size=file_size, 44 | file_unique_id=file_data.unique_id, 45 | ) 46 | return html 47 | -------------------------------------------------------------------------------- /TechVJ/utils/time_format.py: -------------------------------------------------------------------------------- 1 | def get_readable_time(seconds: int) -> str: 2 | count = 0 3 | readable_time = "" 4 | time_list = [] 5 | time_suffix_list = ["s", "m", "h", " days"] 6 | while count < 4: 7 | count += 1 8 | if count < 3: 9 | remainder, result = divmod(seconds, 60) 10 | else: 11 | remainder, result = divmod(seconds, 24) 12 | if seconds == 0 and remainder == 0: 13 | break 14 | time_list.append(int(result)) 15 | seconds = int(remainder) 16 | for x in range(len(time_list)): 17 | time_list[x] = str(time_list[x]) + time_suffix_list[x] 18 | if len(time_list) == 4: 19 | readable_time += time_list.pop() + ", " 20 | time_list.reverse() 21 | readable_time += ": ".join(time_list) 22 | return readable_time 23 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | app = Flask(__name__) 3 | 4 | @app.route('/') 5 | def hello_world(): 6 | return 'TechVJ' 7 | 8 | 9 | if __name__ == "__main__": 10 | app.run() 11 | 12 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import sys 4 | import glob 5 | import importlib 6 | from pathlib import Path 7 | from pyrogram import idle 8 | import logging 9 | import logging.config 10 | 11 | 12 | 13 | # Get logging configurations 14 | logging.config.fileConfig('logging.conf') 15 | logging.getLogger().setLevel(logging.INFO) 16 | logging.getLogger("pyrogram").setLevel(logging.ERROR) 17 | logging.getLogger("imdbpy").setLevel(logging.ERROR) 18 | logging.basicConfig( 19 | level=logging.INFO, 20 | format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" 21 | ) 22 | logging.getLogger("aiohttp").setLevel(logging.ERROR) 23 | logging.getLogger("aiohttp.web").setLevel(logging.ERROR) 24 | 25 | 26 | 27 | 28 | from pyrogram import Client, __version__ 29 | from pyrogram.raw.all import layer 30 | from config import Var, LOG_CHANNEL 31 | from typing import Union, Optional, AsyncGenerator 32 | from pyrogram import types 33 | from Script import script 34 | from datetime import date, datetime 35 | import pytz 36 | from aiohttp import web 37 | from TechVJ.server import web_server 38 | 39 | 40 | 41 | import asyncio 42 | from pyrogram import idle 43 | from plugins.clone import restart_bots 44 | from TechVJ.bot import StreamBot 45 | from TechVJ.utils.keepalive import ping_server 46 | from TechVJ.bot.clients import initialize_clients 47 | 48 | 49 | 50 | 51 | ppath = "plugins/*.py" 52 | files = glob.glob(ppath) 53 | StreamBot.start() 54 | loop = asyncio.get_event_loop() 55 | 56 | 57 | 58 | async def start(): 59 | print('\n') 60 | print('Initalizing Tech HEro Bot') 61 | bot_info = await StreamBot.get_me() 62 | StreamBot.username = bot_info.username 63 | await initialize_clients() 64 | for name in files: 65 | with open(name) as a: 66 | patt = Path(a.name) 67 | plugin_name = patt.stem.replace(".py", "") 68 | plugins_dir = Path(f"plugins/{plugin_name}.py") 69 | import_path = "plugins.{}".format(plugin_name) 70 | spec = importlib.util.spec_from_file_location(import_path, plugins_dir) 71 | load = importlib.util.module_from_spec(spec) 72 | spec.loader.exec_module(load) 73 | sys.modules["plugins." + plugin_name] = load 74 | print("Tech HEro Imported => " + plugin_name) 75 | if Var.ON_HEROKU: 76 | asyncio.create_task(ping_server()) 77 | me = await StreamBot.get_me() 78 | tz = pytz.timezone('Asia/Kolkata') 79 | today = date.today() 80 | now = datetime.now(tz) 81 | time = now.strftime("%H:%M:%S %p") 82 | app = web.AppRunner(await web_server()) 83 | await StreamBot.send_message(chat_id=LOG_CHANNEL, text=script.RESTART_TXT.format(today, time)) 84 | await app.setup() 85 | bind_address = "0.0.0.0" 86 | await web.TCPSite(app, bind_address, Var.PORT).start() 87 | await restart_bots() 88 | print("Bot Started Powered By @VJ_Botz") 89 | await idle() 90 | 91 | 92 | 93 | if __name__ == '__main__': 94 | try: 95 | loop.run_until_complete(start()) 96 | except KeyboardInterrupt: 97 | logging.info('Service Stopped Bye 👋') 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /clone_plugins/TechVJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /clone_plugins/broadcast.py: -------------------------------------------------------------------------------- 1 | from pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid 2 | from clone_plugins.dbusers import db 3 | from pyrogram import Client, filters 4 | from config import ADMINS 5 | import asyncio 6 | import datetime 7 | import time 8 | import logging 9 | from config import DB_URI as MONGO_URL 10 | from pymongo import MongoClient 11 | 12 | mongo_client = MongoClient(MONGO_URL) 13 | mongo_db = mongo_client["cloned_vjbotz"] 14 | 15 | logger = logging.getLogger(__name__) 16 | logger.setLevel(logging.INFO) 17 | 18 | async def broadcast_messages(user_id, message): 19 | try: 20 | await message.copy(chat_id=user_id) 21 | return True, "Success" 22 | except FloodWait as e: 23 | await asyncio.sleep(e.x) 24 | return await broadcast_messages(user_id, message) 25 | except InputUserDeactivated: 26 | await db.delete_user(int(user_id)) 27 | logging.info(f"{user_id}-Removed from Database, since deleted account.") 28 | return False, "Deleted" 29 | except UserIsBlocked: 30 | logging.info(f"{user_id} -Blocked the bot.") 31 | return False, "Blocked" 32 | except PeerIdInvalid: 33 | await db.delete_user(int(user_id)) 34 | logging.info(f"{user_id} - PeerIdInvalid") 35 | return False, "Error" 36 | except Exception as e: 37 | return False, "Error" 38 | 39 | 40 | @Client.on_message(filters.command("broadcast") & filters.reply) 41 | async def verupikkals(bot, message): 42 | id = bot.me.id 43 | owner = mongo_db.bots.find_one({'bot_id': id}) 44 | ownerid = int(owner['user_id']) 45 | if ownerid != message.from_user.id: 46 | await message.reply_text("ᴏɴʟʏ ᴏᴡɴᴇʀ ᴄᴏᴍᴍᴀɴᴅ❗ Get Access [Get Here](https://https://t.me/what_if_season_2_hindi_dubb)") 47 | return 48 | users = await db.get_all_users() 49 | b_msg = message.reply_to_message 50 | sts = await message.reply_text( 51 | text='Broadcasting your messages...' 52 | ) 53 | start_time = time.time() 54 | total_users = await db.total_users_count() 55 | done = 0 56 | blocked = 0 57 | deleted = 0 58 | failed = 0 59 | success = 0 60 | async for user in users: 61 | if 'id' in user: 62 | pti, sh = await broadcast_messages(int(user['id']), b_msg) 63 | if pti: 64 | success += 1 65 | elif pti == False: 66 | if sh == "Blocked": 67 | blocked += 1 68 | elif sh == "Deleted": 69 | deleted += 1 70 | elif sh == "Error": 71 | failed += 1 72 | done += 1 73 | if not done % 20: 74 | await sts.edit(f"Broadcast in progress:\n\nCompleted: {done}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 75 | else: 76 | # Handle the case where 'id' key is missing in the user dictionary 77 | done += 1 78 | failed += 1 79 | if not done % 20: 80 | await sts.edit(f"Broadcast in progress:\n\nCompleted: {done}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 81 | 82 | time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) 83 | await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nCompleted: {done}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 84 | 85 | -------------------------------------------------------------------------------- /clone_plugins/commands.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | import random 4 | import asyncio 5 | from Script import script 6 | from validators import domain 7 | from clone_plugins.dbusers import db 8 | from clone_plugins.users_api import get_user, update_user_info 9 | from pyrogram import Client, filters, enums 10 | from plugins.database import get_file_details 11 | from pyrogram.errors import ChatAdminRequired, FloodWait 12 | from config import BOT_USERNAME, ADMINS 13 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery, InputMediaPhoto 14 | from config import PICS, CUSTOM_FILE_CAPTION, AUTO_DELETE_TIME, AUTO_DELETE 15 | import re 16 | import json 17 | import base64 18 | from config import DB_URI as MONGO_URL 19 | from pymongo import MongoClient 20 | 21 | mongo_client = MongoClient(MONGO_URL) 22 | mongo_db = mongo_client["cloned_vjbotz"] 23 | 24 | logger = logging.getLogger(__name__) 25 | 26 | # Don't Remove Credit Tg - @VJ_Botz 27 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 28 | # Ask Doubt on telegram @KingVJ01 29 | 30 | def get_size(size): 31 | """Get size in readable format""" 32 | 33 | units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"] 34 | size = float(size) 35 | i = 0 36 | while size >= 1024.0 and i < len(units): 37 | i += 1 38 | size /= 1024.0 39 | return "%.2f %s" % (size, units[i]) 40 | 41 | # Don't Remove Credit Tg - @VJ_Botz 42 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 43 | # Ask Doubt on telegram @KingVJ01 44 | 45 | @Client.on_message(filters.command("start") & filters.incoming) 46 | async def start(client, message): 47 | if not await db.is_user_exist(message.from_user.id): 48 | await db.add_user(message.from_user.id, message.from_user.first_name) 49 | if len(message.command) != 2: 50 | buttons = [[ 51 | InlineKeyboardButton('💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@sastamarvel01?si=JmIkr6a16LRXUaIe') 52 | ],[ 53 | InlineKeyboardButton('🤖 ᴄʀᴇᴀᴛᴇ ʏᴏᴜʀ ᴏᴡɴ ᴄʟᴏɴᴇ ʙᴏᴛ', url=f'https://t.me/{BOT_USERNAME}?start=clone') 54 | ],[ 55 | InlineKeyboardButton('💁‍♀️ ʜᴇʟᴘ', callback_data='help'), 56 | InlineKeyboardButton('ᴀʙᴏᴜᴛ 🔻', callback_data='about') 57 | ]] 58 | me2 = (await client.get_me()).mention 59 | reply_markup = InlineKeyboardMarkup(buttons) 60 | await message.reply_photo( 61 | photo=random.choice(PICS), 62 | caption=script.CLONE_START_TXT.format(message.from_user.mention, me2), 63 | reply_markup=reply_markup 64 | ) 65 | return 66 | 67 | 68 | data = message.command[1] 69 | try: 70 | pre, file_id = data.split('_', 1) 71 | except: 72 | file_id = data 73 | pre = "" 74 | 75 | files_ = await get_file_details(file_id) 76 | if not files_: 77 | pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1) 78 | try: 79 | msg = await client.send_cached_media( 80 | chat_id=message.from_user.id, 81 | file_id=file_id, 82 | protect_content=True if pre == 'filep' else False, 83 | ) 84 | filetype = msg.media 85 | file = getattr(msg, filetype.value) 86 | title = '@aapna_Movies ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split())) 87 | size=get_size(file.file_size) 88 | f_caption = f"{title}" 89 | if CUSTOM_FILE_CAPTION: 90 | try: 91 | f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='') 92 | except: 93 | return 94 | await msg.edit_caption(f_caption) 95 | k = await msg.reply(f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in {AUTO_DELETE} mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there you want again [Get Here](https://t.me/aapna_Movies) ",quote=True) 96 | await asyncio.sleep(AUTO_DELETE_TIME) 97 | await msg.delete() 98 | await k.edit_text("Your File/Video is successfully deleted!!! you want again [Get Here](https://t.me/aapna_Movies) ") 99 | 100 | return 101 | except: 102 | pass 103 | return await message.reply('No such file exist.') 104 | files = files_[0] 105 | title = files.file_name 106 | size=get_size(files.file_size) 107 | f_caption=files.caption 108 | if CUSTOM_FILE_CAPTION: 109 | try: 110 | f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption) 111 | except Exception as e: 112 | logger.exception(e) 113 | f_caption=f_caption 114 | if f_caption is None: 115 | f_caption = f"{files.file_name}" 116 | await client.send_cached_media( 117 | chat_id=message.from_user.id, 118 | file_id=file_id, 119 | caption=f_caption, 120 | protect_content=True if pre == 'filep' else False, 121 | ) 122 | 123 | 124 | @Client.on_message(filters.command('api') & filters.private) 125 | async def shortener_api_handler(client, m: Message): 126 | user_id = m.from_user.id 127 | user = await get_user(user_id) 128 | cmd = m.command 129 | 130 | if len(cmd) == 1: 131 | s = script.SHORTENER_API_MESSAGE.format(base_site=user["base_site"], shortener_api=user["shortener_api"]) 132 | return await m.reply(s) 133 | 134 | elif len(cmd) == 2: 135 | api = cmd[1].strip() 136 | await update_user_info(user_id, {"shortener_api": api}) 137 | await m.reply("Shortener API updated successfully to " + api) 138 | else: 139 | await m.reply("You are not authorized to use this command.") 140 | 141 | # Don't Remove Credit Tg - @Avatar_last_airbender_3_hindi 142 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@sastamarvel01?si=JmIkr6a16LRXUaIe 143 | # Ask Doubt on telegram @hero_botss 144 | 145 | @Client.on_message(filters.command("base_site") & filters.private) 146 | async def base_site_handler(client, m: Message): 147 | user_id = m.from_user.id 148 | user = await get_user(user_id) 149 | cmd = m.command 150 | text = f"/base_site (base_site)\n\nCurrent base site: None\n\n EX: /base_site shortnerdomain.com" 151 | 152 | if len(cmd) == 1: 153 | return await m.reply(text=text, disable_web_page_preview=True) 154 | elif len(cmd) == 2: 155 | base_site = cmd[1].strip() 156 | if not domain(base_site): 157 | return await m.reply(text=text, disable_web_page_preview=True) 158 | await update_user_info(user_id, {"base_site": base_site}) 159 | await m.reply("Base Site updated successfully") 160 | else: 161 | await m.reply("You are not authorized to use this command.") 162 | 163 | # Don't Remove Credit Tg - @Avatar_last_airbender_3_hindi 164 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@sastamarvel01?si=JmIkr6a16LRXUaIe 165 | # Ask Doubt on telegram @hero_botss 166 | 167 | 168 | @Client.on_callback_query() 169 | async def cb_handler(client: Client, query: CallbackQuery): 170 | if query.data == "close_data": 171 | await query.message.delete() 172 | elif query.data == "start": 173 | buttons = [[ 174 | InlineKeyboardButton('💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@sastamarvel01?si=JmIkr6a16LRXUaIe') 175 | ],[ 176 | InlineKeyboardButton('🤖 ᴄʀᴇᴀᴛᴇ ʏᴏᴜʀ ᴏᴡɴ ᴄʟᴏɴᴇ ʙᴏᴛ', url=f'https://t.me/{BOT_USERNAME}?start=clone') 177 | ],[ 178 | InlineKeyboardButton('💁‍♀️ ʜᴇʟᴘ', callback_data='help'), 179 | InlineKeyboardButton('ᴀʙᴏᴜᴛ 🔻', callback_data='about') 180 | ]] 181 | 182 | reply_markup = InlineKeyboardMarkup(buttons) 183 | await client.edit_message_media( 184 | query.message.chat.id, 185 | query.message.id, 186 | InputMediaPhoto(random.choice(PICS)) 187 | ) 188 | me2 = (await client.get_me()).mention 189 | await query.message.edit_text( 190 | text=script.CLONE_START_TXT.format(query.from_user.mention, me2), 191 | reply_markup=reply_markup, 192 | parse_mode=enums.ParseMode.HTML 193 | ) 194 | 195 | 196 | elif query.data == "help": 197 | buttons = [[ 198 | InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), 199 | InlineKeyboardButton('🔒 Cʟᴏsᴇ', callback_data='close_data') 200 | ]] 201 | await client.edit_message_media( 202 | query.message.chat.id, 203 | query.message.id, 204 | InputMediaPhoto(random.choice(PICS)) 205 | ) 206 | reply_markup = InlineKeyboardMarkup(buttons) 207 | await query.message.edit_text( 208 | text=script.CHELP_TXT, 209 | reply_markup=reply_markup, 210 | parse_mode=enums.ParseMode.HTML 211 | ) 212 | 213 | elif query.data == "about": 214 | buttons = [[ 215 | InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), 216 | InlineKeyboardButton('🔒 Cʟᴏsᴇ', callback_data='close_data') 217 | ]] 218 | await client.edit_message_media( 219 | query.message.chat.id, 220 | query.message.id, 221 | InputMediaPhoto(random.choice(PICS)) 222 | ) 223 | me2 = (await client.get_me()).mention 224 | id = client.me.id 225 | owner = mongo_db.bots.find_one({'bot_id': id}) 226 | ownerid = int(owner['user_id']) 227 | reply_markup = InlineKeyboardMarkup(buttons) 228 | await query.message.edit_text( 229 | text=script.CABOUT_TXT.format(me2, ownerid), 230 | reply_markup=reply_markup, 231 | parse_mode=enums.ParseMode.HTML 232 | ) 233 | 234 | -------------------------------------------------------------------------------- /clone_plugins/dbusers.py: -------------------------------------------------------------------------------- 1 | 2 | import motor.motor_asyncio 3 | from config import CDB_NAME, DB_URI 4 | 5 | DATABASE_NAME = CDB_NAME 6 | DATABASE_URI = DB_URI 7 | 8 | 9 | class Database: 10 | 11 | def __init__(self, uri, database_name): 12 | self._client = motor.motor_asyncio.AsyncIOMotorClient(uri) 13 | self.db = self._client[database_name] 14 | self.col = self.db.users 15 | self.grp = self.db.groups 16 | 17 | 18 | def new_user(self, id, name): 19 | return dict( 20 | id = id, 21 | name = name, 22 | ban_status=dict( 23 | is_banned=False, 24 | ban_reason="", 25 | ), 26 | ) 27 | 28 | def new_group(self, id, title): 29 | return dict( 30 | id = id, 31 | title = title, 32 | chat_status=dict( 33 | is_disabled=False, 34 | reason="", 35 | ), 36 | ) 37 | 38 | 39 | async def add_user(self, id, name): 40 | user = self.new_user(id, name) 41 | await self.col.insert_one(user) 42 | 43 | 44 | async def is_user_exist(self, id): 45 | user = await self.col.find_one({'id':int(id)}) 46 | return bool(user) 47 | 48 | 49 | async def total_users_count(self): 50 | count = await self.col.count_documents({}) 51 | return count 52 | 53 | 54 | async def get_all_users(self): 55 | return self.col.find({}) 56 | 57 | 58 | 59 | async def delete_user(self, user_id): 60 | await self.col.delete_many({'id': int(user_id)}) 61 | 62 | 63 | db = Database(DATABASE_URI, DATABASE_NAME) 64 | -------------------------------------------------------------------------------- /clone_plugins/genlink.py: -------------------------------------------------------------------------------- 1 | import re 2 | from pyrogram import filters, Client, enums 3 | from plugins.database import unpack_new_file_id 4 | from clone_plugins.users_api import get_user, get_short_link 5 | import base64 6 | 7 | 8 | 9 | @Client.on_message(filters.command(['link', 'plink'])) 10 | async def gen_link_s(client: Client, message): 11 | replied = message.reply_to_message 12 | if not replied: 13 | return await message.reply('Reply to a message to get a shareable link.') 14 | file_type = replied.media 15 | if file_type not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: 16 | return await message.reply("Reply to a supported media") 17 | if message.has_protected_content: 18 | return await message.reply("okDa") 19 | 20 | 21 | 22 | file_id, ref = unpack_new_file_id((getattr(replied, file_type.value)).file_id) 23 | string = 'filep_' if message.text.lower().strip() == "/plink" else 'file_' 24 | string += file_id 25 | outstr = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") 26 | user_id = message.from_user.id 27 | user = await get_user(user_id) 28 | # Get the bot's username 29 | bot_username = (await client.get_me()).username 30 | share_link = f"https://t.me/{bot_username}?start={outstr}" 31 | await message.reply(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🔗 ᴏʀɪɢɪɴᴀʟ ʟɪɴᴋ :- {share_link}") 32 | short_link = await get_short_link(user, share_link) 33 | await message.reply(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🖇️ sʜᴏʀᴛ ʟɪɴᴋ :- {short_link}") 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /clone_plugins/users_api.py: -------------------------------------------------------------------------------- 1 | 2 | import requests 3 | import json 4 | from motor.motor_asyncio import AsyncIOMotorClient 5 | from config import CLONE_DB_URI, DB_NAME 6 | 7 | 8 | 9 | client = AsyncIOMotorClient(CLONE_DB_URI) 10 | db = client[DB_NAME] 11 | col = db["users"] 12 | 13 | 14 | 15 | async def get_short_link(user, link): 16 | api_key = user["shortener_api"] 17 | base_site = user["base_site"] 18 | print(user) 19 | response = requests.get(f"https://{base_site}/api?api={api_key}&url={link}") 20 | data = response.json() 21 | if data["status"] == "success" or rget.status_code == 200: 22 | return data["shortenedUrl"] 23 | 24 | 25 | 26 | async def get_user(user_id): 27 | 28 | user_id = int(user_id) 29 | 30 | user = await col.find_one({"user_id": user_id}) 31 | 32 | if not user: 33 | res = { 34 | "user_id": user_id, 35 | "shortener_api": None, 36 | "base_site": None, 37 | } 38 | 39 | await col.insert_one(res) 40 | user = await col.find_one({"user_id": user_id}) 41 | 42 | return user 43 | 44 | 45 | 46 | async def update_user_info(user_id, value:dict): 47 | user_id = int(user_id) 48 | myquery = {"user_id": user_id} 49 | newvalues = { "$set": value } 50 | await col.update_one(myquery, newvalues) 51 | 52 | 53 | 54 | async def total_users_count(): 55 | count = await col.count_documents({}) 56 | return count 57 | 58 | 59 | async def get_all_users(): 60 | all_users = col.find({}) 61 | return all_users 62 | 63 | 64 | 65 | async def delete_user(user_id): 66 | await col.delete_one({'user_id': int(user_id)}) 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | 2 | import re 3 | import os 4 | from os import getenv, environ 5 | from Script import script 6 | from dotenv import load_dotenv 7 | 8 | load_dotenv() 9 | 10 | 11 | 12 | 13 | id_pattern = re.compile(r'^.\d+$') 14 | def is_enabled(value, default): 15 | if value.lower() in ["true", "yes", "1", "enable", "y"]: 16 | return True 17 | elif value.lower() in ["false", "no", "0", "disable", "n"]: 18 | return False 19 | else: 20 | return default 21 | 22 | 23 | 24 | # Owner Information 25 | API_ID = int(environ.get("API_ID", "29640476")) 26 | API_HASH = environ.get("API_HASH", "824d5b93ac8c8fddcf4088a67ecd5222") 27 | ADMINS = int(environ.get("ADMINS", "6138367360")) 28 | 29 | # Database Information 30 | CLONE_DB_URI = environ.get("CLONE_DB_URI", "mongodb+srv://infotechhero890:7c2qvHdJUYqTOaMa@cluster0.veojhex.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0") 31 | CDB_NAME = environ.get("CDB_NAME", "clonevjbotz") 32 | DB_URI = environ.get("DB_URI", "mongodb+srv://thahero196:lP9Fb6aKL7T0y47U@cluster0.whs2bkj.mongodb.net/?retryWrites=true&w=majority") 33 | DB_NAME = environ.get("DB_NAME", "vjbotz") 34 | 35 | 36 | # Bot Information 37 | BOT_TOKEN = environ.get("BOT_TOKEN", "7097361555:AAHOhbFWGflLqJQcY5vWleTU-iXvfai_rXs") 38 | BOT_USERNAME = environ.get("BOT_USERNAME", "Anime_file_store1_bot") # your bot username without @ 39 | PICS = (environ.get('PICS', 'https://te.legra.ph/file/66604e5911df5a0c43ffa.jpg https://graph.org/file/f5a26ac21b060d5787ea3.jpg https://graph.org/file/30539d8f1fc92423d6a19.jpg https://graph.org/file/701ff72fb43d85e073f03.jpg')).split() # Bot Start Picture 40 | 41 | # Auto Delete Information 42 | AUTO_DELETE = int(environ.get("AUTO_DELETE", "30")) # Time in Minutes 43 | AUTO_DELETE_TIME = int(environ.get("AUTO_DELETE_TIME", "1800")) # Time in Seconds 44 | 45 | # Channel Information 46 | LOG_CHANNEL = int(environ.get("LOG_CHANNEL", "-1002005121747")) 47 | FILE_STORE_CHANNEL = [int(ch) for ch in (environ.get('FILE_STORE_CHANNEL', '-1002067183105')).split()] 48 | 49 | # Don't Remove Credit Tg - @VJ_Botz 50 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 51 | # Ask Doubt on telegram @KingVJ01 52 | 53 | # File Caption Information 54 | CUSTOM_FILE_CAPTION = environ.get("CUSTOM_FILE_CAPTION", f"{script.CAPTION}") 55 | BATCH_FILE_CAPTION = environ.get("BATCH_FILE_CAPTION", CUSTOM_FILE_CAPTION) 56 | 57 | # Enable - True or Disable - False 58 | PROTECT_CONTENT = is_enabled((environ.get('PROTECT_CONTENT', "False")), False) 59 | PUBLIC_FILE_STORE = is_enabled((environ.get('PUBLIC_FILE_STORE', "True")), True) 60 | 61 | 62 | 63 | # File Stream Config 64 | class Var(object): 65 | MULTI_CLIENT = True 66 | name = str(getenv('name', 'filetolinkvjbot')) 67 | SLEEP_THRESHOLD = int(getenv('SLEEP_THRESHOLD', '60')) 68 | WORKERS = int(getenv('WORKERS', '4')) 69 | BIN_CHANNEL = int(getenv('BIN_CHANNEL', '-1002124914386')) 70 | PORT = int(getenv('PORT', 8080)) 71 | BIND_ADRESS = str(getenv('WEB_SERVER_BIND_ADDRESS', '0.0.0.0')) 72 | PING_INTERVAL = int(environ.get("PING_INTERVAL", "1200")) # 20 minutes 73 | NO_PORT = bool(getenv('NO_PORT', False)) 74 | APP_NAME = None 75 | if 'DYNO' in environ: 76 | ON_HEROKU = True 77 | APP_NAME = str(getenv('APP_NAME')) 78 | 79 | else: 80 | ON_HEROKU = False 81 | FQDN = str(getenv('FQDN', BIND_ADRESS)) if not ON_HEROKU or getenv('FQDN') else APP_NAME+'.herokuapp.com' 82 | HAS_SSL=bool(getenv('HAS_SSL',False)) 83 | if HAS_SSL: 84 | URL = "https://file-store-bot-ajay-client.onrender.com" 85 | else: 86 | URL = "https://file-store-bot-ajay-client.onrender.com" 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /logging.conf: -------------------------------------------------------------------------------- 1 | [loggers] 2 | keys=root 3 | 4 | [handlers] 5 | keys=consoleHandler,fileHandler 6 | 7 | [formatters] 8 | keys=consoleFormatter,fileFormatter 9 | 10 | [logger_root] 11 | level=DEBUG 12 | handlers=consoleHandler,fileHandler 13 | 14 | [handler_consoleHandler] 15 | class=StreamHandler 16 | level=INFO 17 | formatter=consoleFormatter 18 | args=(sys.stdout,) 19 | 20 | [handler_fileHandler] 21 | class=FileHandler 22 | level=ERROR 23 | formatter=fileFormatter 24 | args=('TELEGRAM BOT.LOG','w',) 25 | 26 | [formatter_consoleFormatter] 27 | format=%(asctime)s - %(lineno)d - %(name)s - %(module)s - %(levelname)s - %(message)s 28 | datefmt=%I:%M:%S %p 29 | 30 | [formatter_fileFormatter] 31 | format=[%(asctime)s:%(name)s:%(lineno)d:%(levelname)s] %(message)s 32 | datefmt=%m/%d/%Y %I:%M:%S %p 33 | -------------------------------------------------------------------------------- /plugins/TechVJ: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /plugins/broadcast.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid 4 | from plugins.dbusers import db 5 | from pyrogram import Client, filters 6 | from config import ADMINS 7 | import asyncio 8 | import datetime 9 | import time 10 | import logging 11 | 12 | 13 | 14 | logger = logging.getLogger(__name__) 15 | logger.setLevel(logging.INFO) 16 | 17 | 18 | 19 | async def broadcast_messages(user_id, message): 20 | try: 21 | await message.copy(chat_id=user_id) 22 | return True, "Success" 23 | except FloodWait as e: 24 | await asyncio.sleep(e.x) 25 | return await broadcast_messages(user_id, message) 26 | except InputUserDeactivated: 27 | await db.delete_user(int(user_id)) 28 | logging.info(f"{user_id}-Removed from Database, since deleted account.") 29 | return False, "Deleted" 30 | except UserIsBlocked: 31 | logging.info(f"{user_id} -Blocked the bot.") 32 | return False, "Blocked" 33 | except PeerIdInvalid: 34 | await db.delete_user(int(user_id)) 35 | logging.info(f"{user_id} - PeerIdInvalid") 36 | return False, "Error" 37 | except Exception as e: 38 | return False, "Error" 39 | 40 | 41 | 42 | 43 | @Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply) 44 | async def verupikkals(bot, message): 45 | users = await db.get_all_users() 46 | b_msg = message.reply_to_message 47 | sts = await message.reply_text( 48 | text='Broadcasting your messages...' 49 | ) 50 | start_time = time.time() 51 | total_users = await db.total_users_count() 52 | done = 0 53 | blocked = 0 54 | deleted = 0 55 | failed =0 56 | 57 | 58 | 59 | success = 0 60 | async for user in users: 61 | if 'id' in user: 62 | pti, sh = await broadcast_messages(int(user['id']), b_msg) 63 | if pti: 64 | success += 1 65 | elif pti == False: 66 | if sh == "Blocked": 67 | blocked += 1 68 | elif sh == "Deleted": 69 | deleted += 1 70 | elif sh == "Error": 71 | failed += 1 72 | done += 1 73 | if not done % 20: 74 | await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 75 | else: 76 | # Handle the case where 'id' key is missing in the user dictionary 77 | done += 1 78 | failed += 1 79 | if not done % 20: 80 | await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 81 | 82 | time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) 83 | await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /plugins/clone.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import re 4 | import logging 5 | from pymongo import MongoClient 6 | from Script import script 7 | from pyrogram import Client, filters 8 | from pyrogram.types import Message 9 | from pyrogram.errors.exceptions.bad_request_400 import AccessTokenExpired, AccessTokenInvalid 10 | from config import API_ID, API_HASH, ADMINS, DB_NAME 11 | from config import DB_URI as MONGO_URL 12 | 13 | mongo_client = MongoClient(MONGO_URL) 14 | mongo_db = mongo_client["cloned_vjbotz"] 15 | mongo_collection = mongo_db[DB_NAME] 16 | 17 | @Client.on_message(filters.command("clone") & filters.private) 18 | async def clone(client, message): 19 | await message.reply_text(script.CLONE_TXT) 20 | 21 | 22 | 23 | @Client.on_message((filters.regex(r'\d[0-9]{8,10}:[0-9A-Za-z_-]{35}')) & filters.private) 24 | async def on_clone(client, message): 25 | try: 26 | user_id = message.from_user.id 27 | user_name = message.from_user.first_name 28 | bot_token = re.findall(r'\d[0-9]{8,10}:[0-9A-Za-z_-]{35}', message.text, re.IGNORECASE) 29 | bot_token = bot_token[0] if bot_token else None 30 | bot_id = re.findall(r'\d[0-9]{8,10}', message.text) 31 | bots = list(mongo_db.bots.find()) 32 | bot_tokens = None # Initialize bot_tokens variable 33 | 34 | for bot in bots: 35 | bot_tokens = bot['token'] 36 | 37 | forward_from_id = message.forward_from.id if message.forward_from else None 38 | if bot_tokens == bot_token and forward_from_id == 93372553: 39 | await message.reply_text("**©️ ᴛʜɪs ʙᴏᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴄʟᴏɴᴇᴅ ʙᴀʙʏ 🐥**") 40 | return 41 | 42 | if not forward_from_id != 93372553: 43 | msg = await message.reply_text("**👨‍💻 ᴡᴀɪᴛ ᴀ ᴍɪɴᴜᴛᴇ ɪ ᴀᴍ ᴄʀᴇᴀᴛɪɴɢ ʏᴏᴜʀ ʙᴏᴛ ❣️@hero_botss**") 44 | try: 45 | ai = Client( 46 | f"{bot_token}", API_ID, API_HASH, 47 | bot_token=bot_token, 48 | plugins={"root": "clone_plugins"}, 49 | ) 50 | 51 | await ai.start() 52 | bot = await ai.get_me() 53 | details = { 54 | 'bot_id': bot.id, 55 | 'is_bot': True, 56 | 'user_id': user_id, 57 | 'name': bot.first_name, 58 | 'token': bot_token, 59 | 'username': bot.username 60 | } 61 | mongo_db.bots.insert_one(details) 62 | await msg.edit_text(f"sᴜᴄᴄᴇssғᴜʟʟʏ ᴄʟᴏɴᴇᴅ ʏᴏᴜʀ ʙᴏᴛ: @{bot.username}.\n\nʏᴏᴜ ᴄᴀɴ ᴀʟsᴏ sᴇᴛ ʏᴏᴜʀ sʜᴏʀᴛɴᴇʀ ɪɴ ʏᴏᴜʀ ᴄʟᴏɴᴇᴅ ʙᴏᴛ ғᴏʀ ᴍᴏʀᴇ ɪɴғᴏ sᴛᴀʀᴛ ʏᴏᴜʀ ᴄʟᴏɴᴇᴅ ʙᴏᴛ @hero_botss") 63 | except BaseException as e: 64 | logging.exception("Error while cloning bot.") 65 | await msg.edit_text(f"⚠️ Bot Error:\n\n{e}\n\n**Kindly forward this message to @hero_botss to get assistance.**") 66 | except Exception as e: 67 | logging.exception("Error while handling message.") 68 | 69 | @Client.on_message(filters.command("deletecloned") & filters.private) 70 | async def delete_cloned_bot(client, message): 71 | try: 72 | bot_token = re.findall(r'\d[0-9]{8,10}:[0-9A-Za-z_-]{35}', message.text, re.IGNORECASE) 73 | bot_token = bot_token[0] if bot_token else None 74 | bot_id = re.findall(r'\d[0-9]{8,10}', message.text) 75 | 76 | mongo_collection = mongo_db.bots 77 | 78 | cloned_bot = mongo_collection.find_one({"token": bot_token}) 79 | if cloned_bot: 80 | mongo_collection.delete_one({"token": bot_token}) 81 | await message.reply_text("**🤖 ᴛʜᴇ ᴄʟᴏɴᴇᴅ ʙᴏᴛ ʜᴀs ʙᴇᴇɴ ʀᴇᴍᴏᴠᴇᴅ ғʀᴏᴍ ᴛʜᴇ ʟɪsᴛ ᴀɴᴅ ɪᴛs ᴅᴇᴛᴀɪʟs ʜᴀᴠᴇ ʙᴇᴇɴ ʀᴇᴍᴏᴠᴇᴅ ғʀᴏᴍ ᴛʜᴇ ᴅᴀᴛᴀʙᴀsᴇ.@hero_botss ☠️**") 82 | else: 83 | await message.reply_text("**⚠️ ᴛʜᴇ ʙᴏᴛ ᴛᴏᴋᴇɴ ᴘʀᴏᴠɪᴅᴇᴅ ɪs ɴᴏᴛ ɪɴ ᴛʜᴇ ᴄʟᴏɴᴇᴅ ʟɪsᴛ.@hero_botss**") 84 | except Exception as e: 85 | logging.exception("Error while deleting cloned bot.") 86 | await message.reply_text("An error occurred while deleting the cloned bot.@hero_botss") 87 | 88 | # Don't Remove Credit Tg - @VJ_Botz 89 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 90 | # Ask Doubt on telegram @KingVJ01 91 | 92 | async def restart_bots(): 93 | logging.info("Restarting all bots........@hero_botss") 94 | bots = list(mongo_db.bots.find()) 95 | for bot in bots: 96 | bot_token = bot['token'] 97 | try: 98 | ai = Client( 99 | f"{bot_token}", API_ID, API_HASH, 100 | bot_token=bot_token, 101 | plugins={"root": "clone_plugins"}, 102 | ) 103 | await ai.start() 104 | except Exception as e: 105 | logging.exception(f"Error while restarting bot with token {bot_token}: {e}") 106 | 107 | -------------------------------------------------------------------------------- /plugins/commands.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | import random 4 | import asyncio 5 | from validators import domain 6 | from Script import script 7 | from plugins.dbusers import db 8 | from pyrogram import Client, filters, enums 9 | from plugins.users_api import get_user, update_user_info 10 | from plugins.database import get_file_details 11 | from pyrogram.errors import ChatAdminRequired, FloodWait 12 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery, InputMediaPhoto 13 | from config import Var, LOG_CHANNEL, PICS, BATCH_FILE_CAPTION, CUSTOM_FILE_CAPTION, AUTO_DELETE_TIME, AUTO_DELETE, ADMINS 14 | import re 15 | import json 16 | import base64 17 | from urllib.parse import quote_plus 18 | from TechVJ.utils.file_properties import get_name, get_hash, get_media_file_size 19 | logger = logging.getLogger(__name__) 20 | 21 | BATCH_FILES = {} 22 | 23 | # Don't Remove Credit Tg - @VJ_Botz 24 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 25 | # Ask Doubt on telegram @KingVJ01 26 | 27 | 28 | def get_size(size): 29 | """Get size in readable format""" 30 | 31 | units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"] 32 | size = float(size) 33 | i = 0 34 | while size >= 1024.0 and i < len(units): 35 | i += 1 36 | size /= 1024.0 37 | return "%.2f %s" % (size, units[i]) 38 | 39 | 40 | async def delete_after_delay(message: Message, delay): 41 | await asyncio.sleep(AUTO_DELETE_TIME) 42 | await message.delete() 43 | 44 | # Don't Remove Credit Tg - @VJ_Botz 45 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 46 | # Ask Doubt on telegram @KingVJ0 47 | 48 | 49 | @Client.on_message(filters.command("start") & filters.incoming) 50 | async def start(client, message): 51 | if not await db.is_user_exist(message.from_user.id): 52 | await db.add_user(message.from_user.id, message.from_user.first_name) 53 | await client.send_message(LOG_CHANNEL, script.LOG_TEXT.format(message.from_user.id, message.from_user.mention)) 54 | if len(message.command) != 2: 55 | buttons = [[ 56 | InlineKeyboardButton( '💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@sastamarvel01?si=KiYYZ5mByFO-O_fl') 57 | ],[ 58 | InlineKeyboardButton( '💝 movies ', url='https://t.me/+ccx-5xVHyro3ZjNl') 59 | ],[ 60 | InlineKeyboardButton('🔍 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ', url='https://t.me/+ccx-5xVHyro3ZjNl'), 61 | InlineKeyboardButton('🤖 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ', url='https://t.me/aapna_Movies') 62 | ],[ 63 | InlineKeyboardButton('🤖 ᴄʀᴇᴀᴛᴇ ʏᴏᴜʀ ᴏᴡɴ ᴄʟᴏɴᴇ ʙᴏᴛ', callback_data='clone') 64 | ],[ 65 | InlineKeyboardButton('💁‍♀️ ʜᴇʟᴘ', callback_data='help'), 66 | InlineKeyboardButton('😊 ᴀʙᴏᴜᴛ', callback_data='about') 67 | ]] 68 | reply_markup = InlineKeyboardMarkup(buttons) 69 | me2 = (await client.get_me()).mention 70 | m=await message.reply_sticker("CAACAgUAAxkBAAIhuGTHNIDjN6W-9OgK2xPXQSiDYpm-AAIFAgACD_PRVn7ikCL5fe76HgQ") 71 | await asyncio.sleep(1) 72 | await m.delete() 73 | await message.reply_photo( 74 | photo=random.choice(PICS), 75 | caption=script.START_TXT.format(message.from_user.mention, me2), 76 | reply_markup=reply_markup 77 | ) 78 | return 79 | 80 | 81 | data = message.command[1] 82 | try: 83 | pre, file_id = data.split('_', 1) 84 | except: 85 | file_id = data 86 | pre = "" 87 | if data.split("-", 1)[0] == "BATCH": 88 | sts = await message.reply("**🔺 ᴘʟᴇᴀsᴇ ᴡᴀɪᴛ**") 89 | file_id = data.split("-", 1)[1] 90 | msgs = BATCH_FILES.get(file_id) 91 | if not msgs: 92 | file = await client.download_media(file_id) 93 | try: 94 | with open(file) as file_data: 95 | msgs=json.loads(file_data.read()) 96 | except: 97 | await sts.edit("FAILED") 98 | return await client.send_message(LOG_CHANNEL, "UNABLE TO OPEN FILE.") 99 | os.remove(file) 100 | BATCH_FILES[file_id] = msgs 101 | 102 | for msg in msgs: 103 | title = msg.get("title") 104 | size=get_size(int(msg.get("size", 0))) 105 | f_caption=msg.get("caption", "") 106 | if BATCH_FILE_CAPTION: 107 | try: 108 | f_caption=BATCH_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption) 109 | except Exception as e: 110 | logger.exception(e) 111 | f_caption=f_caption 112 | if f_caption is None: 113 | f_caption = f"{title}" 114 | try: 115 | h = await message.reply_text(f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in {AUTO_DELETE} minutes 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there ") 116 | quote=True, 117 | 118 | k = await client.send_cached_media( 119 | chat_id=message.from_user.id, 120 | file_id=msg.get("file_id"), 121 | caption=f_caption, 122 | protect_content=msg.get('protect', False), 123 | ) 124 | 125 | asyncio.create_task(delete_after_delay(k, AUTO_DELETE_TIME)) 126 | asyncio.create_task(delete_after_delay(h, AUTO_DELETE_TIME)) 127 | except FloodWait as e: 128 | await asyncio.sleep(e.x) 129 | logger.warning(f"Floodwait of {e.x} sec.") 130 | await client.send_cached_media( 131 | chat_id=message.from_user.id, 132 | file_id=msg.get("file_id"), 133 | caption=f_caption, 134 | protect_content=msg.get('protect', False), 135 | ) 136 | except Exception as e: 137 | logger.warning(e, exc_info=True) 138 | continue 139 | await asyncio.sleep(1) 140 | await sts.delete() 141 | return 142 | 143 | 144 | elif data.split("-", 1)[0] == "DSTORE": 145 | sts = await message.reply("**🔺 ᴘʟᴇᴀsᴇ ᴡᴀɪᴛ**") 146 | b_string = data.split("-", 1)[1] 147 | decoded = (base64.urlsafe_b64decode(b_string + "=" * (-len(b_string) % 4))).decode("ascii") 148 | await message.reply_text(f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in {AUTO_DELETE} mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there you want again @group_discd") 149 | 150 | try: 151 | f_msg_id, l_msg_id, f_chat_id, protect = decoded.split("_", 3) 152 | except: 153 | f_msg_id, l_msg_id, f_chat_id = decoded.split("_", 2) 154 | protect = "/pbatch" if PROTECT_CONTENT else "batch" 155 | diff = int(l_msg_id) - int(f_msg_id) 156 | async for msg in client.iter_messages(int(f_chat_id), int(l_msg_id), int(f_msg_id)): 157 | if msg.media: 158 | media = getattr(msg, msg.media.value) 159 | if BATCH_FILE_CAPTION: 160 | try: 161 | f_caption=BATCH_FILE_CAPTION.format(file_name=getattr(media, 'file_name', ''), file_size=getattr(media, 'file_size', ''), file_caption=getattr(msg, 'caption', '')) 162 | except Exception as e: 163 | logger.exception(e) 164 | f_caption = getattr(msg, 'caption', '') 165 | else: 166 | media = getattr(msg, msg.media) 167 | file_name = getattr(media, 'file_name', '') 168 | f_caption = getattr(msg, 'caption', file_name) 169 | try: 170 | h = await message.reply_text(f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in {AUTO_DELETE} minutes 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there If you want File again @group_discd") 171 | k = await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False) 172 | 173 | asyncio.create_task(delete_after_delay(k, AUTO_DELETE_TIME)) 174 | asyncio.create_task(delete_after_delay(h, AUTO_DELETE_TIME)) 175 | except FloodWait as e: 176 | await asyncio.sleep(e.x) 177 | await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False) 178 | except Exception as e: 179 | logger.exception(e) 180 | continue 181 | elif msg.empty: 182 | continue 183 | else: 184 | try: 185 | await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False) 186 | except FloodWait as e: 187 | await asyncio.sleep(e.x) 188 | await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False) 189 | except Exception as e: 190 | logger.exception(e) 191 | continue 192 | await asyncio.sleep(1) 193 | return await sts.delete() 194 | 195 | 196 | 197 | files_ = await get_file_details(file_id) 198 | if not files_: 199 | pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1) 200 | try: 201 | msg = await client.send_cached_media( 202 | chat_id=message.from_user.id, 203 | file_id=file_id, 204 | protect_content=True if pre == 'filep' else False, 205 | ) 206 | filetype = msg.media 207 | file = getattr(msg, filetype.value) 208 | title = '' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split())) 209 | size=get_size(file.file_size) 210 | f_caption = f"{title}" 211 | if CUSTOM_FILE_CAPTION: 212 | try: 213 | f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='') 214 | except: 215 | return 216 | 217 | await msg.edit_caption(f_caption) 218 | g = await msg.reply_text( 219 | text=f"**••If Any Problem To Open File Please Message In Here👇👇**", 220 | quote=True, 221 | disable_web_page_preview=True, 222 | reply_markup=InlineKeyboardMarkup( 223 | [ 224 | [ 225 | InlineKeyboardButton('🚀 New Anime Update🖥️', url="https://t.me/group_discd")] 226 | ] 227 | ) 228 | ) 229 | k = await msg.reply(f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in {AUTO_DELETE} mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there You Want Again @group_discd ",quote=True) 230 | await asyncio.sleep(AUTO_DELETE_TIME) 231 | await msg.delete() 232 | await g.delete() 233 | await k.edit_text("Your File/Video is successfully deleted!!! You Want Again [Get Here](https://t.me/aapna_Movies).") 234 | await m.edit_text("❤️‍🔥.") 235 | await asyncio.sleep(1) 236 | await m.delete() 237 | return 238 | except: 239 | pass 240 | return await message.reply('No such file exist.') 241 | 242 | 243 | 244 | files = files_[0] 245 | title = files.file_name 246 | size=get_size(files.file_size) 247 | f_caption=files.caption 248 | if CUSTOM_FILE_CAPTION: 249 | try: 250 | f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption) 251 | except Exception as e: 252 | logger.exception(e) 253 | f_caption=f_caption 254 | if f_caption is None: 255 | f_caption = f"{files.file_name}" 256 | await client.send_cached_media( 257 | chat_id=message.from_user.id, 258 | file_id=file_id, 259 | caption=f_caption, 260 | protect_content=True if pre == 'filep' else False, 261 | ) 262 | 263 | # Don't Remove Credit Tg - @VJ_Botz 264 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 265 | # Ask Doubt on telegram @KingVJ01 266 | 267 | @Client.on_message(filters.command('api') & filters.private) 268 | async def shortener_api_handler(client, m: Message): 269 | user_id = m.from_user.id 270 | user = await get_user(user_id) 271 | cmd = m.command 272 | 273 | if len(cmd) == 1: 274 | s = script.SHORTENER_API_MESSAGE.format(base_site=user["base_site"], shortener_api=user["shortener_api"]) 275 | return await m.reply(s) 276 | 277 | elif len(cmd) == 2: 278 | api = cmd[1].strip() 279 | await update_user_info(user_id, {"shortener_api": api}) 280 | await m.reply("Shortener API updated successfully to " + api) 281 | 282 | 283 | 284 | @Client.on_message(filters.command("base_site") & filters.private) 285 | async def base_site_handler(client, m: Message): 286 | user_id = m.from_user.id 287 | user = await get_user(user_id) 288 | cmd = m.command 289 | text = f"`/base_site (base_site)`\n\nCurrent base site: None\n\n EX: `/base_site shortnerdomain.com`" 290 | if len(cmd) == 1: 291 | return await m.reply(text=text, disable_web_page_preview=True) 292 | elif len(cmd) == 2: 293 | base_site = cmd[1].strip() 294 | if not domain(base_site): 295 | return await m.reply(text=text, disable_web_page_preview=True) 296 | await update_user_info(user_id, {"base_site": base_site}) 297 | await m.reply("Base Site updated successfully") 298 | 299 | 300 | 301 | @Client.on_callback_query() 302 | async def cb_handler(client: Client, query: CallbackQuery): 303 | if query.data == "close_data": 304 | await query.message.delete() 305 | elif query.data == "about": 306 | buttons = [[ 307 | InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), 308 | InlineKeyboardButton('🔒 Cʟᴏsᴇ', callback_data='close_data') 309 | ]] 310 | await client.edit_message_media( 311 | query.message.chat.id, 312 | query.message.id, 313 | InputMediaPhoto(random.choice(PICS)) 314 | ) 315 | reply_markup = InlineKeyboardMarkup(buttons) 316 | me2 = (await client.get_me()).mention 317 | await query.message.edit_text( 318 | text=script.ABOUT_TXT.format(me2), 319 | reply_markup=reply_markup, 320 | parse_mode=enums.ParseMode.HTML 321 | ) 322 | 323 | 324 | 325 | elif query.data == "start": 326 | buttons = [[ 327 | InlineKeyboardButton( '💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@sastamarvel01?si=KiYYZ5mByFO-O_fl') 328 | ],[ 329 | InlineKeyboardButton( '💝 movies ', url='https://t.me/+ccx-5xVHyro3ZjNl') 330 | ],[ 331 | InlineKeyboardButton('🔍 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ', url='https://t.me/+ccx-5xVHyro3ZjNl'), 332 | InlineKeyboardButton('🤖 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ', url='https://t.me/aapna_Movies') 333 | ],[ 334 | InlineKeyboardButton('🤖 ᴄʀᴇᴀᴛᴇ ʏᴏᴜʀ ᴏᴡɴ ᴄʟᴏɴᴇ ʙᴏᴛ', callback_data='clone') 335 | ],[ 336 | InlineKeyboardButton('💁‍♀️ ʜᴇʟᴘ', callback_data='help'), 337 | InlineKeyboardButton('😊 ᴀʙᴏᴜᴛ', callback_data='about') 338 | ]] 339 | 340 | reply_markup = InlineKeyboardMarkup(buttons) 341 | await client.edit_message_media( 342 | query.message.chat.id, 343 | query.message.id, 344 | InputMediaPhoto(random.choice(PICS)) 345 | ) 346 | me2 = (await client.get_me()).mention 347 | m=await message.reply_sticker("CAACAgUAAxkBAAIhuGTHNIDjN6W-9OgK2xPXQSiDYpm-AAIFAgACD_PRVn7ikCL5fe76HgQ") 348 | await asyncio.sleep(1) 349 | await m.delete() 350 | await query.message.edit_text( 351 | text=script.START_TXT.format(query.from_user.mention, me2), 352 | reply_markup=reply_markup, 353 | parse_mode=enums.ParseMode.HTML 354 | ) 355 | 356 | # Don't Remove Credit Tg - @VJ_Botz 357 | # Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ 358 | # Ask Doubt on telegram @KingVJ01 359 | 360 | elif query.data == "clone": 361 | buttons = [[ 362 | InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), 363 | InlineKeyboardButton('🔒 Cʟᴏsᴇ', callback_data='close_data') 364 | ]] 365 | await client.edit_message_media( 366 | query.message.chat.id, 367 | query.message.id, 368 | InputMediaPhoto(random.choice(PICS)) 369 | ) 370 | reply_markup = InlineKeyboardMarkup(buttons) 371 | await query.message.edit_text( 372 | text=script.CLONE_TXT.format(query.from_user.mention), 373 | reply_markup=reply_markup, 374 | parse_mode=enums.ParseMode.HTML 375 | ) 376 | 377 | 378 | 379 | elif query.data == "help": 380 | buttons = [[ 381 | InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), 382 | InlineKeyboardButton('🔒 Cʟᴏsᴇ', callback_data='close_data') 383 | ]] 384 | await client.edit_message_media( 385 | query.message.chat.id, 386 | query.message.id, 387 | InputMediaPhoto(random.choice(PICS)) 388 | ) 389 | reply_markup = InlineKeyboardMarkup(buttons) 390 | await query.message.edit_text( 391 | text=script.HELP_TXT, 392 | reply_markup=reply_markup, 393 | parse_mode=enums.ParseMode.HTML 394 | ) 395 | 396 | 397 | 398 | elif query.data.startswith("generate_stream_link"): 399 | _, file_id = query.data.split(":") 400 | try: 401 | user_id = query.from_user.id 402 | username = query.from_user.mention 403 | 404 | log_msg = await client.send_cached_media( 405 | chat_id=LOG_CHANNEL, 406 | file_id=file_id, 407 | ) 408 | fileName = {quote_plus(get_name(log_msg))} 409 | stream = f"{Var.URL}watch/{str(log_msg.id)}/{quote_plus(get_name(log_msg))}?hash={get_hash(log_msg)}" 410 | download = f"{Var.URL}{str(log_msg.id)}/{quote_plus(get_name(log_msg))}?hash={get_hash(log_msg)}" 411 | 412 | m = await message.reply_sticker("CAACAgUAAxkBAAIhuGTHNIDjN6W-9OgK2xPXQSiDYpm-AAIFAgACD_PRVn7ikCL5fe76HgQ") 413 | await asyncio.sleep(1) 414 | await m.delete() 415 | 416 | xo = await query.message.reply_text(f'👾') 417 | await asyncio.sleep(1) 418 | await xo.delete() 419 | 420 | await log_msg.reply_text( 421 | text=f"•• ʟɪɴᴋ ɢᴇɴᴇʀᴀᴛᴇᴅ ꜰᴏʀ ɪᴅ #{user_id} \n•• ᴜꜱᴇʀɴᴀᴍᴇ : {username} \n\n•• ᖴᎥᒪᗴ Nᗩᗰᗴ : {fileName}", 422 | quote=True, 423 | disable_web_page_preview=True, 424 | reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("🚀 Fast Download 🚀", url= download), # we download Link 425 | InlineKeyboardButton('🖥️ Watch online 🖥️', url= stream)]]) # web stream Link 426 | ) 427 | await query.message.reply_text( 428 | text="•• ʟɪɴᴋ ɢᴇɴᴇʀᴀᴛᴇᴅ ☠︎⚔", 429 | quote=True, 430 | disable_web_page_preview=True, 431 | reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("🚀 Fast Download 🚀", url= download)], # we download Link 432 | [ 433 | InlineKeyboardButton('🖥️ Watch online 🖥️', url= stream)], # web stream Link 434 | [ 435 | InlineKeyboardButton('📁 Want File again ', url='https://t.me/aapna_Movies')], 436 | [ 437 | InlineKeyboardButton('🔍 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ', url='https://t.me/+ccx-5xVHyro3ZjNl')] 438 | ] 439 | ) 440 | ) 441 | except Exception as e: 442 | print(e) # print the error message 443 | await query.answer(f"☣something went wrong\n\n{e}", show_alert=True) 444 | return 445 | 446 | 447 | -------------------------------------------------------------------------------- /plugins/database.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import logging 4 | from struct import pack 5 | import re 6 | import base64 7 | from pyrogram.file_id import FileId 8 | from pymongo.errors import DuplicateKeyError 9 | from umongo import Instance, Document, fields 10 | from motor.motor_asyncio import AsyncIOMotorClient 11 | from config import DB_URI, DB_NAME 12 | 13 | 14 | logger = logging.getLogger(__name__) 15 | logger.setLevel(logging.INFO) 16 | 17 | 18 | 19 | COLLECTION_NAME = "Telegram_Files" 20 | 21 | 22 | 23 | 24 | client = AsyncIOMotorClient(DB_URI) 25 | db = client[DB_NAME] 26 | instance = Instance.from_db(db) 27 | 28 | 29 | 30 | @instance.register 31 | class Media(Document): 32 | file_id = fields.StrField(attribute='_id') 33 | file_ref = fields.StrField(allow_none=True) 34 | file_name = fields.StrField(required=True) 35 | file_size = fields.IntField(required=True) 36 | file_type = fields.StrField(allow_none=True) 37 | mime_type = fields.StrField(allow_none=True) 38 | caption = fields.StrField(allow_none=True) 39 | 40 | class Meta: 41 | indexes = ('$file_name', ) 42 | collection_name = COLLECTION_NAME 43 | 44 | 45 | 46 | 47 | async def get_file_details(query): 48 | filter = {'file_id': query} 49 | cursor = Media.find(filter) 50 | filedetails = await cursor.to_list(length=1) 51 | return filedetails 52 | 53 | 54 | 55 | def encode_file_id(s: bytes) -> str: 56 | r = b"" 57 | n = 0 58 | 59 | for i in s + bytes([22]) + bytes([4]): 60 | if i == 0: 61 | n += 1 62 | else: 63 | if n: 64 | r += b"\x00" + bytes([n]) 65 | n = 0 66 | 67 | r += bytes([i]) 68 | 69 | return base64.urlsafe_b64encode(r).decode().rstrip("=") 70 | 71 | 72 | 73 | 74 | def encode_file_ref(file_ref: bytes) -> str: 75 | return base64.urlsafe_b64encode(file_ref).decode().rstrip("=") 76 | 77 | 78 | 79 | def unpack_new_file_id(new_file_id): 80 | """Return file_id, file_ref""" 81 | decoded = FileId.decode(new_file_id) 82 | file_id = encode_file_id( 83 | pack( 84 | "⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🔗 ᴏʀɪɢɪɴᴀʟ ʟɪɴᴋ :- {share_link}
") 42 | short_link = await get_short_link(user, share_link) 43 | await message.reply(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🖇️ sʜᴏʀᴛ ʟɪɴᴋ :- {short_link}") 44 | 45 | 46 | @Client.on_message(filters.command(['batch', 'pbatch'])) 47 | async def gen_link_batch(bot, message): 48 | if " " not in message.text: 49 | return await message.reply("Use correct format.\nExample /batch https://t.me/vj_botz/10 https://t.me/vj_botz/20.") 50 | links = message.text.strip().split(" ") 51 | if len(links) != 3: 52 | return await message.reply("Use correct format.\nExample /batch https://t.me/vj_botz/10 https://t.me/vj_botz/20.") 53 | cmd, first, last = links 54 | regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") 55 | match = regex.match(first) 56 | if not match: 57 | return await message.reply('Invalid link') 58 | f_chat_id = match.group(4) 59 | f_msg_id = int(match.group(5)) 60 | if f_chat_id.isnumeric(): 61 | f_chat_id = int(("-100" + f_chat_id)) 62 | 63 | 64 | 65 | match = regex.match(last) 66 | if not match: 67 | return await message.reply('Invalid link') 68 | l_chat_id = match.group(4) 69 | l_msg_id = int(match.group(5)) 70 | if l_chat_id.isnumeric(): 71 | l_chat_id = int(("-100" + l_chat_id)) 72 | 73 | if f_chat_id != l_chat_id: 74 | return await message.reply("Chat ids not matched.") 75 | try: 76 | chat_id = (await bot.get_chat(f_chat_id)).id 77 | except ChannelInvalid: 78 | return await message.reply('@what_if_dubb_bot This may be a private channel / group. Make me an admin over there to index the files.') 79 | except (UsernameInvalid, UsernameNotModified): 80 | return await message.reply('Invalid Link specified.') 81 | except Exception as e: 82 | return await message.reply(f'Errors - {e}') 83 | 84 | 85 | 86 | sts = await message.reply("**ɢᴇɴᴇʀᴀᴛɪɴɢ ʟɪɴᴋ ғᴏʀ ʏᴏᴜʀ ᴍᴇssᴀɢᴇ**.\n**ᴛʜɪs ᴍᴀʏ ᴛᴀᴋᴇ ᴛɪᴍᴇ ᴅᴇᴘᴇɴᴅɪɴɢ ᴜᴘᴏɴ ɴᴜᴍʙᴇʀ ᴏғ ᴍᴇssᴀɢᴇs**") 87 | if chat_id in FILE_STORE_CHANNEL: 88 | string = f"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}" 89 | b_64 = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") 90 | user_id = message.from_user.id 91 | user = await get_user(user_id) 92 | share_link = f"https://t.me/{BOT_USERNAME}?start=DSTORE-{b_64}" 93 | await sts.edit(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🔗 ᴏʀɪɢɪɴᴀʟ ʟɪɴᴋ :- {share_link}") 94 | short_link = await get_short_link(user, share_link) 95 | await message.reply(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🖇️ sʜᴏʀᴛ ʟɪɴᴋ :- {short_link}") 96 | return 97 | 98 | FRMT = "**ɢᴇɴᴇʀᴀᴛɪɴɢ ʟɪɴᴋ...**\n**ᴛᴏᴛᴀʟ ᴍᴇssᴀɢᴇs:** {total}\n**ᴅᴏɴᴇ:** {current}\n**ʀᴇᴍᴀɪɴɪɴɢ:** {rem}\n**sᴛᴀᴛᴜs:** {sts}" 99 | 100 | outlist = [] 101 | 102 | 103 | 104 | # file store without db channel 105 | og_msg = 0 106 | tot = 0 107 | async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id): 108 | tot += 1 109 | if msg.empty or msg.service: 110 | continue 111 | if not msg.media: 112 | # only media messages supported. 113 | continue 114 | try: 115 | file_type = msg.media 116 | file = getattr(msg, file_type.value) 117 | caption = getattr(msg, 'caption', '') 118 | if caption: 119 | caption = caption.html 120 | if file: 121 | file = { 122 | "file_id": file.file_id, 123 | "caption": caption, 124 | "title": getattr(file, "file_name", ""), 125 | "size": file.file_size, 126 | "protect": cmd.lower().strip() == "/pbatch", 127 | } 128 | 129 | 130 | 131 | og_msg +=1 132 | outlist.append(file) 133 | except: 134 | pass 135 | if not og_msg % 20: 136 | try: 137 | await sts.edit(FRMT.format(total=l_msg_id-f_msg_id, current=tot, rem=((l_msg_id-f_msg_id) - tot), sts="Saving Messages")) 138 | except: 139 | pass 140 | with open(f"batchmode_{message.from_user.id}.json", "w+") as out: 141 | json.dump(outlist, out) 142 | post = await bot.send_document(LOG_CHANNEL, f"batchmode_{message.from_user.id}.json", file_name="Batch.json", caption="⚠️Generated for filestore.") 143 | os.remove(f"batchmode_{message.from_user.id}.json") 144 | file_id, ref = unpack_new_file_id(post.document.file_id) 145 | user_id = message.from_user.id 146 | user = await get_user(user_id) 147 | share_link = f"https://t.me/{BOT_USERNAME}?start=BATCH-{file_id}" 148 | await sts.edit(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\nContains `{og_msg}` files.\n🔗 ᴏʀɪɢɪɴᴀʟ ʟɪɴᴋ :- {share_link}") 149 | short_link = await get_short_link(user, share_link) 150 | await message.reply(f"⭕ ʜᴇʀᴇ ɪs ʏᴏᴜʀ ʟɪɴᴋ:\n\n🖇️ sʜᴏʀᴛ ʟɪɴᴋ :- {short_link}") 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /plugins/users_api.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import requests 4 | import json 5 | from motor.motor_asyncio import AsyncIOMotorClient 6 | from config import DB_URI, DB_NAME 7 | 8 | 9 | 10 | client = AsyncIOMotorClient(DB_URI) 11 | db = client[DB_NAME] 12 | col = db["users"] 13 | 14 | 15 | async def get_short_link(user, link): 16 | api_key = user["shortener_api"] 17 | base_site = user["base_site"] 18 | print(user) 19 | response = requests.get(f"https://{base_site}/api?api={api_key}&url={link}") 20 | data = response.json() 21 | if data["status"] == "success" or rget.status_code == 200: 22 | return data["shortenedUrl"] 23 | 24 | 25 | 26 | async def get_user(user_id): 27 | 28 | user_id = int(user_id) 29 | 30 | user = await col.find_one({"user_id": user_id}) 31 | 32 | if not user: 33 | res = { 34 | "user_id": user_id, 35 | "shortener_api": None, 36 | "base_site": None, 37 | } 38 | 39 | await col.insert_one(res) 40 | user = await col.find_one({"user_id": user_id}) 41 | 42 | return user 43 | 44 | 45 | 46 | async def update_user_info(user_id, value:dict): 47 | user_id = int(user_id) 48 | myquery = {"user_id": user_id} 49 | newvalues = { "$set": value } 50 | await col.update_one(myquery, newvalues) 51 | 52 | 53 | 54 | async def total_users_count(): 55 | count = await col.count_documents({}) 56 | return count 57 | 58 | 59 | 60 | async def get_all_users(): 61 | all_users = col.find({}) 62 | return all_users 63 | 64 | 65 | 66 | async def delete_user(user_id): 67 | await col.delete_one({'user_id': int(user_id)}) 68 | 69 | 70 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Pyrogram 2 | Tgcrypto 3 | asyncio 4 | aiohttp 5 | pymongo[srv]==3.12.3 6 | motor==2.5.1 7 | marshmallow==3.14.1 8 | umongo==3.0.1 9 | validators 10 | requests 11 | bs4 12 | pytz 13 | python-dotenv==0.21.1 14 | Flask==1.1.2 15 | gunicorn==20.1.0 16 | Jinja2==3.0.3 17 | werkzeug==2.0.2 18 | itsdangerous==2.0.1 19 | -------------------------------------------------------------------------------- /run cmd.txt: -------------------------------------------------------------------------------- 1 | gunicorn app:app & python3 bot.py 2 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.10.8 2 | --------------------------------------------------------------------------------