├── Dockerfile ├── LICENSE ├── Procfile ├── README.md ├── app.json ├── bot.py ├── config.py ├── database.py ├── heroku.yml ├── logging.conf ├── main.py ├── plugins ├── admin.py ├── broadcast.py ├── commands.py ├── public.py ├── regix.py ├── settings.py ├── test.py ├── unequify.py └── utils.py ├── requirements.txt ├── start.sh └── translation.py /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8-slim-buster 2 | 3 | RUN apt update && apt upgrade -y 4 | RUN apt install git -y 5 | COPY requirements.txt /requirements.txt 6 | 7 | RUN cd / 8 | RUN pip3 install -U pip && pip3 install -U -r requirements.txt 9 | RUN JishuDeveloper /Ultra-Forward-Bot 10 | WORKDIR /Ultra-Forward-Bot 11 | COPY start.sh /start.sh 12 | CMD ["/bin/bash", "/start.sh"] 13 | -------------------------------------------------------------------------------- /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 | worker: python3 main.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | logo 2 | 3 |

4 | Ultra Forward Bot 5 |

6 | 7 |

🩵 Thanks for Being Here 🩵

8 | 9 | 10 | ### CONFIGS VARIABLES 11 | 12 | * `BOT_TOKEN` - Get bot token from Bot Father 13 | * `API_ID` - Get api id from Telegram Auth 14 | * `API_HASH` - Get api hash from Telegram Auth 15 | * `OWNER_ID` - Bot admin/owner user id. 16 | * `DATABASE_URI` - Mongo Database URL from Mongo DB 17 | * `DATABASE_NAME` - Your database name from mongoDB. (Optional) 18 | * `BOT_SESSION` - Your Bot session name. (Optional) 19 | 20 | 21 | 22 | ### DEPLOYEMENT SUPPORT 23 | 24 | Deploy To Koyeb 25 |

26 |
27 | 28 | Deploy 29 | 30 |

31 | 32 | Deploy To Heroku 33 |

34 |
35 | 36 | Deploy 37 | 38 |

39 | 40 | 41 | 42 | 43 | 44 | ### FEATURES 45 | - Forward Message From Public Channel To Your Channel. 46 | - Forward Message From Private Channel To Your Channel. 47 | - Supports Broadcasts. 48 | - Set custom caption. 49 | - Custom Button. 50 | - Support Restricted Chats. 51 | - Skip Duplicate Messages. 52 | - Filter Type Of Messages. 53 | - Skip Messages Based On Extensions & Keywords & Size. 54 | - Deploy to Koyeb + Heroku + Railway. 55 | - Developer Service 24x7. 56 | 57 | 58 | 59 | ### ALL COMMANDS 60 | 61 | ``` 62 | start - Start the bot. 63 | forward - Forward messages. 64 | unequify - Delete dublicate files in channel. 65 | settings - Configure your settings. 66 | ping - To check bot ping. 67 | cancel - Cancel ongoing forwarding. 68 | reset - To reset all settings. 69 | donate - To support developer. 70 | stats - To check bot stats (Admin Only) 71 | resetall - To reset all user settings. (Admin Only) 72 | broadcast - To broadcast any message to all users (Admin Only) 73 | restart - Restart the bot (Admin Only) 74 | ``` 75 | 76 | 77 | 78 | ### ❤️ RESPECTING ❤️ 79 | - [JishuDeveloper](https://github.com/JishuDeveloper) 80 | - [Madflix Official](https://github.com/jishusinha) 81 | 82 | ### 😍 BOTS CHANNEL 😍 83 | - [Madflix Botz](https://t.me/Madflix_Bots) 84 | - [Jishu Botz](https://t.me/JishuBotz) 85 | 86 | ### 💕 CONTACT DEVELOPER 💕 87 | - [Jishu Developer](https://t.me/JishuDeveloper) 88 | - [Madflix Official](https://t.me/MadflixOfficials) 89 | 90 | ### ☕ BUY ME A COFFEE ☕ 91 | - [PayPal](https://paypal.me/jishudeveloper/2.50USD) 92 | - [PhonePe](https://graph.org/file/6822df5af3a2e80637172.jpg) 93 | - [UPI](https://graph.org/file/b831109be4acff5c966d2.jpg) 94 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Ultra Forward Bot", 3 | "description": "Telegram Ultra Forward Bot ", 4 | "logo": "https://graph.org/file/2f461540c83b362772714.jpg", 5 | "keywords": ["Auto Renamer Bot", "Mongo DB"], 6 | "repository": "https://github.com/JishuDeveloper/Ultra-Forward-Bot", 7 | "success_url": "https://t.me/Madflix_Bots", 8 | "env": { 9 | "API_ID": { 10 | "description": "Your APP ID From my.telegram.org ", 11 | "value": "", 12 | "required": true 13 | }, 14 | "API_HASH": { 15 | "description": "Your API Hash From my.telegram.org ", 16 | "value": "", 17 | "required": true 18 | }, 19 | "BOT_TOKEN": { 20 | "description": "Your Bot Token From @BotFather", 21 | "value": "", 22 | "required": true 23 | }, 24 | "OWNER_ID": { 25 | "description":"Add Your User ID multiple is use space to split", 26 | "value": "", 27 | "required": true 28 | }, 29 | "BOT_SESSION": { 30 | "description":"Your Bot session name.", 31 | "value": "forward-bot", 32 | "required": false 33 | }, 34 | "DB_URL": { 35 | "description": "Your Mongo DB URL Obtained From mongodb.com", 36 | "value": "", 37 | "required": true 38 | }, 39 | "DB_NAME":{ 40 | "description":"Your Mongo DB Database Name", 41 | "value": "madflixbotz", 42 | "required": false 43 | } 44 | }, 45 | "buildpacks": [ 46 | { 47 | "url": "heroku/python" 48 | } 49 | ] 50 | } 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import asyncio 11 | import logging 12 | import logging.config 13 | from database import db 14 | from config import Config 15 | from pyrogram import Client, __version__ 16 | from pyrogram.raw.all import layer 17 | from pyrogram.enums import ParseMode 18 | from pyrogram.errors import FloodWait 19 | 20 | logging.config.fileConfig('logging.conf') 21 | logging.getLogger().setLevel(logging.INFO) 22 | logging.getLogger("pyrogram").setLevel(logging.ERROR) 23 | 24 | class Bot(Client): 25 | def __init__(self): 26 | super().__init__( 27 | Config.BOT_SESSION, 28 | api_hash=Config.API_HASH, 29 | api_id=Config.API_ID, 30 | plugins={ 31 | "root": "plugins" 32 | }, 33 | workers=50, 34 | bot_token=Config.BOT_TOKEN 35 | ) 36 | self.log = logging 37 | 38 | async def start(self): 39 | await super().start() 40 | me = await self.get_me() 41 | logging.info(f"{me.first_name} with for pyrogram v{__version__} (Layer {layer}) started on @{me.username}.") 42 | self.id = me.id 43 | self.username = me.username 44 | self.first_name = me.first_name 45 | self.set_parse_mode(ParseMode.DEFAULT) 46 | text = "**Bot Restarted !**" 47 | logging.info(text) 48 | success = failed = 0 49 | users = await db.get_all_frwd() 50 | async for user in users: 51 | chat_id = user['user_id'] 52 | try: 53 | await self.send_message(chat_id, text) 54 | success += 1 55 | except FloodWait as e: 56 | await asyncio.sleep(e.value + 1) 57 | await self.send_message(chat_id, text) 58 | success += 1 59 | except Exception: 60 | failed += 1 61 | # await self.send_message("venombotsupport", text) 62 | if (success + failed) != 0: 63 | await db.rmve_frwd(all=True) 64 | logging.info(f"Restart message status" 65 | f"success: {success}" 66 | f"failed: {failed}") 67 | 68 | async def stop(self, *args): 69 | msg = f"@{self.username} stopped. Bye." 70 | await super().stop() 71 | logging.info(msg) 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | # Jishu Developer 82 | # Don't Remove Credit 🥺 83 | # Telegram Channel @Madflix_Bots 84 | # Backup Channel @JishuBotz 85 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | import os 10 | 11 | class Config: 12 | API_ID = os.environ.get("API_ID", "") 13 | API_HASH = os.environ.get("API_HASH", "") 14 | BOT_TOKEN = os.environ.get("BOT_TOKEN", "") 15 | BOT_SESSION = os.environ.get("BOT_SESSION", "forward-bot") 16 | DB_URL = os.environ.get("DB_URL", "") 17 | DB_NAME = os.environ.get("DB_NAME", "madflixbotz") 18 | OWNER_ID = [int(id) for id in os.environ.get("OWNER_ID", '').split()] 19 | 20 | 21 | class temp(object): 22 | lock = {} 23 | CANCEL = {} 24 | forwardings = 0 25 | BANNED_USERS = [] 26 | IS_FRWD_CHAT = [] 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | # Jishu Developer 35 | # Don't Remove Credit 🥺 36 | # Telegram Channel @Madflix_Bots 37 | # Backup Channel @JishuBotz 38 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /database.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | from os import environ 10 | from config import Config 11 | import motor.motor_asyncio 12 | from pymongo import MongoClient 13 | 14 | async def mongodb_version(): 15 | x = MongoClient(Config.DB_URL) 16 | mongodb_version = x.server_info()['version'] 17 | return mongodb_version 18 | 19 | class Database: 20 | 21 | def __init__(self, uri, database_name): 22 | self._client = motor.motor_asyncio.AsyncIOMotorClient(uri) 23 | self.db = self._client[database_name] 24 | self.bot = self.db.bots 25 | self.col = self.db.users 26 | self.nfy = self.db.notify 27 | self.chl = self.db.channels 28 | 29 | def new_user(self, id, name): 30 | return dict( 31 | id = id, 32 | name = name, 33 | ban_status=dict( 34 | is_banned=False, 35 | ban_reason="", 36 | ), 37 | ) 38 | 39 | async def add_user(self, id, name): 40 | user = self.new_user(id, name) 41 | await self.col.insert_one(user) 42 | 43 | async def is_user_exist(self, id): 44 | user = await self.col.find_one({'id':int(id)}) 45 | return bool(user) 46 | 47 | async def total_users_bots_count(self): 48 | bcount = await self.bot.count_documents({}) 49 | count = await self.col.count_documents({}) 50 | return count, bcount 51 | 52 | async def total_channels(self): 53 | count = await self.chl.count_documents({}) 54 | return count 55 | 56 | async def remove_ban(self, id): 57 | ban_status = dict( 58 | is_banned=False, 59 | ban_reason='' 60 | ) 61 | await self.col.update_one({'id': id}, {'$set': {'ban_status': ban_status}}) 62 | 63 | async def ban_user(self, user_id, ban_reason="No Reason"): 64 | ban_status = dict( 65 | is_banned=True, 66 | ban_reason=ban_reason 67 | ) 68 | await self.col.update_one({'id': user_id}, {'$set': {'ban_status': ban_status}}) 69 | 70 | async def get_ban_status(self, id): 71 | default = dict( 72 | is_banned=False, 73 | ban_reason='' 74 | ) 75 | user = await self.col.find_one({'id':int(id)}) 76 | if not user: 77 | return default 78 | return user.get('ban_status', default) 79 | 80 | async def get_all_users(self): 81 | return self.col.find({}) 82 | 83 | async def delete_user(self, user_id): 84 | await self.col.delete_many({'id': int(user_id)}) 85 | 86 | async def get_banned(self): 87 | users = self.col.find({'ban_status.is_banned': True}) 88 | b_users = [user['id'] async for user in users] 89 | return b_users 90 | 91 | async def update_configs(self, id, configs): 92 | await self.col.update_one({'id': int(id)}, {'$set': {'configs': configs}}) 93 | 94 | async def get_configs(self, id): 95 | default = { 96 | 'caption': None, 97 | 'duplicate': True, 98 | 'forward_tag': False, 99 | 'file_size': 0, 100 | 'size_limit': None, 101 | 'extension': None, 102 | 'keywords': None, 103 | 'protect': None, 104 | 'button': None, 105 | 'db_uri': None, 106 | 'filters': { 107 | 'poll': True, 108 | 'text': True, 109 | 'audio': True, 110 | 'voice': True, 111 | 'video': True, 112 | 'photo': True, 113 | 'document': True, 114 | 'animation': True, 115 | 'sticker': True 116 | } 117 | } 118 | user = await self.col.find_one({'id':int(id)}) 119 | if user: 120 | return user.get('configs', default) 121 | return default 122 | 123 | async def add_bot(self, datas): 124 | if not await self.is_bot_exist(datas['user_id']): 125 | await self.bot.insert_one(datas) 126 | 127 | async def remove_bot(self, user_id): 128 | await self.bot.delete_many({'user_id': int(user_id)}) 129 | 130 | async def get_bot(self, user_id: int): 131 | bot = await self.bot.find_one({'user_id': user_id}) 132 | return bot if bot else None 133 | 134 | async def is_bot_exist(self, user_id): 135 | bot = await self.bot.find_one({'user_id': user_id}) 136 | return bool(bot) 137 | 138 | async def in_channel(self, user_id: int, chat_id: int) -> bool: 139 | channel = await self.chl.find_one({"user_id": int(user_id), "chat_id": int(chat_id)}) 140 | return bool(channel) 141 | 142 | async def add_channel(self, user_id: int, chat_id: int, title, username): 143 | channel = await self.in_channel(user_id, chat_id) 144 | if channel: 145 | return False 146 | return await self.chl.insert_one({"user_id": user_id, "chat_id": chat_id, "title": title, "username": username}) 147 | 148 | async def remove_channel(self, user_id: int, chat_id: int): 149 | channel = await self.in_channel(user_id, chat_id ) 150 | if not channel: 151 | return False 152 | return await self.chl.delete_many({"user_id": int(user_id), "chat_id": int(chat_id)}) 153 | 154 | async def get_channel_details(self, user_id: int, chat_id: int): 155 | return await self.chl.find_one({"user_id": int(user_id), "chat_id": int(chat_id)}) 156 | 157 | async def get_user_channels(self, user_id: int): 158 | channels = self.chl.find({"user_id": int(user_id)}) 159 | return [channel async for channel in channels] 160 | 161 | async def get_filters(self, user_id): 162 | filters = [] 163 | filter = (await self.get_configs(user_id))['filters'] 164 | for k, v in filter.items(): 165 | if v == False: 166 | filters.append(str(k)) 167 | return filters 168 | 169 | async def add_frwd(self, user_id): 170 | return await self.nfy.insert_one({'user_id': int(user_id)}) 171 | 172 | async def rmve_frwd(self, user_id=0, all=False): 173 | data = {} if all else {'user_id': int(user_id)} 174 | return await self.nfy.delete_many(data) 175 | 176 | async def get_all_frwd(self): 177 | return self.nfy.find({}) 178 | 179 | db = Database(Config.DB_URL, Config.DB_NAME) 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | # Jishu Developer 189 | # Don't Remove Credit 🥺 190 | # Telegram Channel @Madflix_Bots 191 | # Backup Channel @JishuBotz 192 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | worker: Dockerfile 4 | -------------------------------------------------------------------------------- /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=('TelegramBot.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 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | from bot import Bot 10 | 11 | app = Bot() 12 | app.run() 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | # Jishu Developer 21 | # Don't Remove Credit 🥺 22 | # Telegram Channel @Madflix_Bots 23 | # Backup Channel @JishuBotz 24 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/admin.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import os, sys, asyncio, time 11 | from config import * 12 | from database import * 13 | from .utils import get_readable_time 14 | from translation import * 15 | from pyrogram import filters, Client 16 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 17 | 18 | botStartTime = time.time() 19 | 20 | 21 | @Client.on_message(filters.private & filters.command(["ping", "p"])) 22 | async def ping(_, message): 23 | start_t = time.time() 24 | rm = await message.reply_text("Pinging....", quote=True) 25 | end_t = time.time() 26 | time_taken_s = (end_t - start_t) * 1000 27 | await rm.edit(f"Ping 🔥!\n{time_taken_s:.3f} ms") 28 | return time_taken_s 29 | 30 | 31 | 32 | @Client.on_message(filters.command(["stats", "status", "s"]) & filters.user(Config.OWNER_ID)) 33 | async def get_stats(bot, message): 34 | users_count, bots_count = await db.total_users_bots_count() 35 | total_channels = await db.total_channels() 36 | uptime = get_readable_time(time.time() - botStartTime) 37 | start_t = time.time() 38 | st = await message.reply('**Processing The Details.....**') 39 | end_t = time.time() 40 | time_taken_s = (end_t - start_t) * 1000 41 | await st.edit(text=f"**--Bot Status--** \n\n**⌚ Bot Uptime :** `{uptime}` \n**🐌 Current Ping :** `{time_taken_s:.3f} ms` \n**👭 Total Users :** `{users_count}` \n\n**🤖 Total Bots :** `{bots_count}` \n**✅ Forwarding :** `{temp.forwardings}` \n**🔥 Total Channel :** `{total_channels}` \n**🚫 Banned Users :** `{temp.BANNED_USERS}`") 42 | 43 | 44 | 45 | @Client.on_message(filters.private & filters.command(["donate", "d"])) 46 | async def donate(client, message): 47 | text = "🥲 Thanks For Showing Interest In Donation! ❤️ \n\nIf You Like My Bots & Projects, You Can 🎁 Donate Me Any Amount From 10 Rs Upto Your Choice. \n\n🛍 UPI ID: madflixofficial@axl" 48 | keybord = InlineKeyboardMarkup([ 49 | [InlineKeyboardButton("🦋 Admin",url = "https://t.me/CallAdminRobot"), 50 | InlineKeyboardButton("✖️ Close",callback_data = "close_btn") ]]) 51 | await message.reply_text(text = text,reply_markup = keybord) 52 | 53 | 54 | 55 | 56 | 57 | 58 | # Jishu Developer 59 | # Don't Remove Credit 🥺 60 | # Telegram Channel @Madflix_Bots 61 | # Backup Channel @JishuBotz 62 | # Developer @JishuDeveloper 63 | -------------------------------------------------------------------------------- /plugins/broadcast.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import asyncio 11 | import time, datetime 12 | from database import db 13 | from config import Config 14 | from pyrogram import Client, filters 15 | from pyrogram.errors import InputUserDeactivated, FloodWait, UserIsBlocked 16 | 17 | 18 | 19 | @Client.on_message(filters.command(["broadcast", "b"]) & filters.user(Config.OWNER_ID) & filters.reply) 20 | async def broadcast (bot, message): 21 | users = await db.get_all_users() 22 | b_msg = message.reply_to_message 23 | sts = await message.reply_text( 24 | text='Broadcasting Your Messages...' 25 | ) 26 | start_time = time.time() 27 | total_users, k = await db.total_users_bots_count() 28 | done = 0 29 | blocked = 0 30 | deleted = 0 31 | failed = 0 32 | success = 0 33 | async for user in users: 34 | pti, sh = await broadcast_messages(int(user['id']), b_msg, bot.log) 35 | if pti: 36 | success += 1 37 | await asyncio.sleep(2) 38 | elif pti == False: 39 | if sh == "Blocked": 40 | blocked+=1 41 | elif sh == "Deleted": 42 | deleted += 1 43 | elif sh == "Error": 44 | failed += 1 45 | done += 1 46 | if not done % 20: 47 | await sts.edit(f"Broadcast In Progress :\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 48 | time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) 49 | await sts.edit(f"Broadcast Completed :\n\nCompleted in {time_taken} seconds.\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 50 | 51 | async def broadcast_messages(user_id, message, log): 52 | try: 53 | await message.copy(chat_id=user_id) 54 | return True, "Success" 55 | except FloodWait as e: 56 | await asyncio.sleep(e.x) 57 | return await broadcast_messages(user_id, message, log) 58 | except InputUserDeactivated: 59 | await db.delete_user(int(user_id)) 60 | log.info(f"{user_id}-Removed from Database, since deleted account.") 61 | return False, "Deleted" 62 | except UserIsBlocked: 63 | log.info(f"{user_id} -Blocked the bot.") 64 | return False, "Blocked" 65 | except Exception as e: 66 | return False, "Error" 67 | 68 | 69 | 70 | 71 | 72 | 73 | # Jishu Developer 74 | # Don't Remove Credit 🥺 75 | # Telegram Channel @Madflix_Bots 76 | # Backup Channel @JishuBotz 77 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/commands.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import os 11 | import sys 12 | import asyncio 13 | from database import db, mongodb_version 14 | from config import Config, temp 15 | from platform import python_version 16 | from translation import Translation 17 | from pyrogram import Client, filters, enums, __version__ as pyrogram_version 18 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InputMediaDocument 19 | 20 | main_buttons = [[ 21 | InlineKeyboardButton('📢 Updates', url='https://t.me/Madflix_Bots'), 22 | InlineKeyboardButton('💬 Support', url='https://t.me/MadflixBots_Support') 23 | ],[ 24 | InlineKeyboardButton('🛠️ Help', callback_data='help'), 25 | InlineKeyboardButton('🩷 About', callback_data='about') 26 | ],[ 27 | InlineKeyboardButton('🧑‍💻 Developer 🧑‍💻', url='https://t.me/CallAdminRobot') 28 | ]] 29 | 30 | 31 | 32 | #===================Start Function===================# 33 | 34 | @Client.on_message(filters.private & filters.command(['start'])) 35 | async def start(client, message): 36 | user = message.from_user 37 | if not await db.is_user_exist(user.id): 38 | await db.add_user(user.id, user.first_name) 39 | reply_markup = InlineKeyboardMarkup(main_buttons) 40 | jishubotz = await message.reply_sticker("CAACAgUAAxkBAAECEEBlLA-nYcsWmsNWgE8-xqIkriCWAgACJwEAAsiUZBTiPWKAkUSmmh4E") 41 | await asyncio.sleep(2) 42 | await jishubotz.delete() 43 | text=Translation.START_TXT.format(user.mention) 44 | await message.reply_text( 45 | text=text, 46 | reply_markup=reply_markup, 47 | quote=True 48 | ) 49 | 50 | 51 | 52 | #==================Restart Function==================# 53 | 54 | @Client.on_message(filters.private & filters.command(['restart', "r"]) & filters.user(Config.OWNER_ID)) 55 | async def restart(client, message): 56 | msg = await message.reply_text( 57 | text="Trying To Restarting.....", 58 | quote=True 59 | ) 60 | await asyncio.sleep(5) 61 | await msg.edit("Server Restarted Successfully ✅") 62 | os.execl(sys.executable, sys.executable, *sys.argv) 63 | 64 | 65 | 66 | #==================Callback Functions==================# 67 | 68 | @Client.on_callback_query(filters.regex(r'^help')) 69 | async def helpcb(bot, query): 70 | await query.message.edit_text( 71 | text=Translation.HELP_TXT, 72 | reply_markup=InlineKeyboardMarkup( 73 | [[ 74 | InlineKeyboardButton('🛠️ How To Use Me 🛠️', callback_data='how_to_use') 75 | ],[ 76 | InlineKeyboardButton('⚙️ Settings ⚙️', callback_data='settings#main'), 77 | InlineKeyboardButton('📊 Stats 📊', callback_data='status') 78 | ],[ 79 | InlineKeyboardButton('🔙 Back', callback_data='back') 80 | ]] 81 | )) 82 | 83 | 84 | 85 | @Client.on_callback_query(filters.regex(r'^how_to_use')) 86 | async def how_to_use(bot, query): 87 | await query.message.edit_text( 88 | text=Translation.HOW_USE_TXT, 89 | reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('🔙 Back', callback_data='help')]]), 90 | disable_web_page_preview=True 91 | ) 92 | 93 | 94 | 95 | @Client.on_callback_query(filters.regex(r'^back')) 96 | async def back(bot, query): 97 | reply_markup = InlineKeyboardMarkup(main_buttons) 98 | await query.message.edit_text( 99 | reply_markup=reply_markup, 100 | text=Translation.START_TXT.format( 101 | query.from_user.first_name)) 102 | 103 | 104 | 105 | @Client.on_callback_query(filters.regex(r'^about')) 106 | async def about(bot, query): 107 | await query.message.edit_text( 108 | text=Translation.ABOUT_TXT.format(bot.me.mention), 109 | reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('🔙 Back', callback_data='back')]]), 110 | disable_web_page_preview=True, 111 | parse_mode=enums.ParseMode.HTML, 112 | ) 113 | 114 | 115 | 116 | @Client.on_callback_query(filters.regex(r'^status')) 117 | async def status(bot, query): 118 | users_count, bots_count = await db.total_users_bots_count() 119 | total_channels = await db.total_channels() 120 | await query.message.edit_text( 121 | text=Translation.STATUS_TXT.format(users_count, bots_count, temp.forwardings, total_channels, temp.BANNED_USERS ), 122 | reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('🔙 Back', callback_data='help')]]), 123 | parse_mode=enums.ParseMode.HTML, 124 | disable_web_page_preview=True, 125 | ) 126 | 127 | 128 | 129 | 130 | 131 | 132 | # Jishu Developer 133 | # Don't Remove Credit 🥺 134 | # Telegram Channel @Madflix_Bots 135 | # Backup Channel @JishuBotz 136 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/public.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | 11 | import re 12 | import asyncio 13 | from .utils import STS 14 | from database import db 15 | from config import temp 16 | from translation import Translation 17 | from pyrogram import Client, filters, enums 18 | from pyrogram.errors import FloodWait 19 | from pyrogram.errors.exceptions.not_acceptable_406 import ChannelPrivate as PrivateChat 20 | from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, ChatAdminRequired, UsernameInvalid, UsernameNotModified, ChannelPrivate 21 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove 22 | 23 | 24 | 25 | 26 | #===================Run Function===================# 27 | 28 | @Client.on_message(filters.private & filters.command(["fwd", "forward"])) 29 | async def run(bot, message): 30 | buttons = [] 31 | btn_data = {} 32 | user_id = message.from_user.id 33 | _bot = await db.get_bot(user_id) 34 | if not _bot: 35 | return await message.reply("You Did Not Added Any Bot. Please Add A Bot Using /settings !") 36 | channels = await db.get_user_channels(user_id) 37 | if not channels: 38 | return await message.reply_text("Please Set A To Channel In /settings Before Forwarding") 39 | if len(channels) > 1: 40 | for channel in channels: 41 | buttons.append([KeyboardButton(f"{channel['title']}")]) 42 | btn_data[channel['title']] = channel['chat_id'] 43 | buttons.append([KeyboardButton("cancel")]) 44 | _toid = await bot.ask(message.chat.id, Translation.TO_MSG.format(_bot['name'], _bot['username']), reply_markup=ReplyKeyboardMarkup(buttons, one_time_keyboard=True, resize_keyboard=True)) 45 | if _toid.text.startswith(('/', 'cancel')): 46 | return await message.reply_text(Translation.CANCEL, reply_markup=ReplyKeyboardRemove()) 47 | to_title = _toid.text 48 | toid = btn_data.get(to_title) 49 | if not toid: 50 | return await message.reply_text("Wrong Channel Choosen !", reply_markup=ReplyKeyboardRemove()) 51 | else: 52 | toid = channels[0]['chat_id'] 53 | to_title = channels[0]['title'] 54 | fromid = await bot.ask(message.chat.id, Translation.FROM_MSG, reply_markup=ReplyKeyboardRemove()) 55 | if fromid.text and fromid.text.startswith('/'): 56 | await message.reply(Translation.CANCEL) 57 | return 58 | if fromid.text and not fromid.forward_date: 59 | regex = re.compile(r"(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") 60 | match = regex.match(fromid.text.replace("?single", "")) 61 | if not match: 62 | return await message.reply('Invalid Link') 63 | chat_id = match.group(4) 64 | last_msg_id = int(match.group(5)) 65 | if chat_id.isnumeric(): 66 | chat_id = int(("-100" + chat_id)) 67 | elif fromid.forward_from_chat.type in [enums.ChatType.CHANNEL]: 68 | last_msg_id = fromid.forward_from_message_id 69 | chat_id = fromid.forward_from_chat.username or fromid.forward_from_chat.id 70 | if last_msg_id == None: 71 | return await message.reply_text("This May Be A Forwarded Message From A Group And Sended By Anonymous Admin. Instead Of This Please Send Last Message Link From Group") 72 | else: 73 | await message.reply_text("Invalid !") 74 | return 75 | try: 76 | title = (await bot.get_chat(chat_id)).title 77 | # except ChannelInvalid: 78 | #return await fromid.reply("**Given source chat is copyrighted channel/group. you can't forward messages from there**") 79 | except (PrivateChat, ChannelPrivate, ChannelInvalid): 80 | title = "private" if fromid.text else fromid.forward_from_chat.title 81 | except (UsernameInvalid, UsernameNotModified): 82 | return await message.reply('Invalid Link Specified.') 83 | except Exception as e: 84 | return await message.reply(f'Errors - {e}') 85 | skipno = await bot.ask(message.chat.id, Translation.SKIP_MSG) 86 | if skipno.text.startswith('/'): 87 | await message.reply(Translation.CANCEL) 88 | return 89 | forward_id = f"{user_id}-{skipno.id}" 90 | buttons = [[ 91 | InlineKeyboardButton('Yes', callback_data=f"start_public_{forward_id}"), 92 | InlineKeyboardButton('No', callback_data="close_btn") 93 | ]] 94 | reply_markup = InlineKeyboardMarkup(buttons) 95 | await message.reply_text( 96 | text=Translation.DOUBLE_CHECK.format(botname=_bot['name'], botuname=_bot['username'], from_chat=title, to_chat=to_title, skip=skipno.text), 97 | disable_web_page_preview=True, 98 | reply_markup=reply_markup 99 | ) 100 | STS(forward_id).store(chat_id, toid, int(skipno.text), int(last_msg_id)) 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | # Jishu Developer 109 | # Don't Remove Credit 🥺 110 | # Telegram Channel @Madflix_Bots 111 | # Backup Channel @JishuBotz 112 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/regix.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import os 11 | import sys 12 | import math 13 | import time 14 | import asyncio 15 | import logging 16 | from .utils import STS 17 | from database import db 18 | from .test import CLIENT , start_clone_bot 19 | from config import Config, temp 20 | from translation import Translation 21 | from pyrogram import Client, filters 22 | #from pyropatch.utils import unpack_new_file_id 23 | from pyrogram.errors import FloodWait, MessageNotModified, RPCError 24 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message 25 | 26 | CLIENT = CLIENT() 27 | logger = logging.getLogger(__name__) 28 | logger.setLevel(logging.INFO) 29 | TEXT = Translation.TEXT 30 | 31 | 32 | 33 | 34 | 35 | @Client.on_callback_query(filters.regex(r'^start_public')) 36 | async def pub_(bot, message): 37 | user = message.from_user.id 38 | temp.CANCEL[user] = False 39 | frwd_id = message.data.split("_")[2] 40 | if temp.lock.get(user) and str(temp.lock.get(user))=="True": 41 | return await message.answer("Please Wait Until Previous Task Complete", show_alert=True) 42 | sts = STS(frwd_id) 43 | if not sts.verify(): 44 | await message.answer("Your Are Clicking On My Old Button", show_alert=True) 45 | return await message.message.delete() 46 | i = sts.get(full=True) 47 | if i.TO in temp.IS_FRWD_CHAT: 48 | return await message.answer("In Target Chat A Task Is Progressing. Please Wait Until Task Complete", show_alert=True) 49 | m = await msg_edit(message.message, "Verifying Your Data's, Please Wait.") 50 | _bot, caption, forward_tag, data, protect, button = await sts.get_data(user) 51 | if not _bot: 52 | return await msg_edit(m, "You Didn't Added Any Bot. Please Add A Bot Using /settings !", wait=True) 53 | try: 54 | client = await start_clone_bot(CLIENT.client(_bot)) 55 | except Exception as e: 56 | return await m.edit(e) 57 | await msg_edit(m, "Processing...") 58 | try: 59 | await client.get_messages(sts.get("FROM"), sts.get("limit")) 60 | except: 61 | await msg_edit(m, f"Source Chat May Be A Private Channel / Group. Use Userbot (User Must Be Member Over There) Or If Make Your [Bot](t.me/{_bot['username']}) An Admin Over There", retry_btn(frwd_id), True) 62 | return await stop(client, user) 63 | try: 64 | k = await client.send_message(i.TO, "Testing") 65 | await k.delete() 66 | except: 67 | await msg_edit(m, f"Please Make Your [UserBot / Bot](t.me/{_bot['username']}) Admin In Target Channel With Full Permissions", retry_btn(frwd_id), True) 68 | return await stop(client, user) 69 | temp.forwardings += 1 70 | await db.add_frwd(user) 71 | await send(client, user, "🩷 Forwarding Started") 72 | sts.add(time=True) 73 | sleep = 1 if _bot['is_bot'] else 10 74 | await msg_edit(m, "Processing...") 75 | temp.IS_FRWD_CHAT.append(i.TO) 76 | temp.lock[user] = locked = True 77 | if locked: 78 | try: 79 | MSG = [] 80 | pling=0 81 | await edit(m, 'Progressing', 10, sts) 82 | print(f"Starting Forwarding Process... From :{sts.get('FROM')} To: {sts.get('TO')} Totel: {sts.get('limit')} Stats : {sts.get('skip')})") 83 | async for message in client.iter_messages( 84 | client, 85 | chat_id=sts.get('FROM'), 86 | limit=int(sts.get('limit')), 87 | offset=int(sts.get('skip')) if sts.get('skip') else 0 88 | ): 89 | if await is_cancelled(client, user, m, sts): 90 | return 91 | if pling %20 == 0: 92 | await edit(m, 'Progressing', 10, sts) 93 | pling += 1 94 | sts.add('fetched') 95 | if message == "DUPLICATE": 96 | sts.add('duplicate') 97 | continue 98 | elif message == "FILTERED": 99 | sts.add('filtered') 100 | continue 101 | if message.empty or message.service: 102 | sts.add('deleted') 103 | continue 104 | if forward_tag: 105 | MSG.append(message.id) 106 | notcompleted = len(MSG) 107 | completed = sts.get('total') - sts.get('fetched') 108 | if ( notcompleted >= 100 109 | or completed <= 100): 110 | await forward(client, MSG, m, sts, protect) 111 | sts.add('total_files', notcompleted) 112 | await asyncio.sleep(10) 113 | MSG = [] 114 | else: 115 | new_caption = custom_caption(message, caption) 116 | details = {"msg_id": message.id, "media": media(message), "caption": new_caption, 'button': button, "protect": protect} 117 | await copy(client, details, m, sts) 118 | sts.add('total_files') 119 | await asyncio.sleep(sleep) 120 | except Exception as e: 121 | await msg_edit(m, f'Error :\n{e}', wait=True) 122 | temp.IS_FRWD_CHAT.remove(sts.TO) 123 | return await stop(client, user) 124 | temp.IS_FRWD_CHAT.remove(sts.TO) 125 | await send(client, user, "🎉 Forwarding Completed") 126 | await edit(m, 'Completed', "completed", sts) 127 | await stop(client, user) 128 | 129 | async def copy(bot, msg, m, sts): 130 | try: 131 | if msg.get("media") and msg.get("caption"): 132 | await bot.send_cached_media( 133 | chat_id=sts.get('TO'), 134 | file_id=msg.get("media"), 135 | caption=msg.get("caption"), 136 | reply_markup=msg.get('button'), 137 | protect_content=msg.get("protect")) 138 | else: 139 | await bot.copy_message( 140 | chat_id=sts.get('TO'), 141 | from_chat_id=sts.get('FROM'), 142 | caption=msg.get("caption"), 143 | message_id=msg.get("msg_id"), 144 | reply_markup=msg.get('button'), 145 | protect_content=msg.get("protect")) 146 | except FloodWait as e: 147 | await edit(m, 'Progressing', e.value, sts) 148 | await asyncio.sleep(e.value) 149 | await edit(m, 'Progressing', 10, sts) 150 | await copy(bot, msg, m, sts) 151 | except Exception as e: 152 | print(e) 153 | sts.add('deleted') 154 | 155 | async def forward(bot, msg, m, sts, protect): 156 | try: 157 | await bot.forward_messages( 158 | chat_id=sts.get('TO'), 159 | from_chat_id=sts.get('FROM'), 160 | protect_content=protect, 161 | message_ids=msg) 162 | except FloodWait as e: 163 | await edit(m, 'Progressing', e.value, sts) 164 | await asyncio.sleep(e.value) 165 | await edit(m, 'Progressing', 10, sts) 166 | await forward(bot, msg, m, sts, protect) 167 | 168 | PROGRESS = """ 169 | 📈 Percetage : {0} % 170 | 171 | ♻️ Fetched : {1} 172 | 173 | 🔥 Forwarded : {2} 174 | 175 | 🫠 Remaining : {3} 176 | 177 | 📊 Status : {4} 178 | 179 | ⏳️ ETA : {5} 180 | """ 181 | 182 | async def msg_edit(msg, text, button=None, wait=None): 183 | try: 184 | return await msg.edit(text, reply_markup=button) 185 | except MessageNotModified: 186 | pass 187 | except FloodWait as e: 188 | if wait: 189 | await asyncio.sleep(e.value) 190 | return await msg_edit(msg, text, button, wait) 191 | 192 | async def edit(msg, title, status, sts): 193 | i = sts.get(full=True) 194 | status = 'Forwarding' if status == 10 else f"Sleeping {status} s" if str(status).isnumeric() else status 195 | percentage = "{:.0f}".format(float(i.fetched)*100/float(i.total)) 196 | 197 | now = time.time() 198 | diff = int(now - i.start) 199 | speed = sts.divide(i.fetched, diff) 200 | elapsed_time = round(diff) * 1000 201 | time_to_completion = round(sts.divide(i.total - i.fetched, int(speed))) * 1000 202 | estimated_total_time = elapsed_time + time_to_completion 203 | progress = "▰{0}{1}".format( 204 | ''.join(["▰" for i in range(math.floor(int(percentage) / 10))]), 205 | ''.join(["▱" for i in range(10 - math.floor(int(percentage) / 10))])) 206 | button = [[InlineKeyboardButton(title, f'fwrdstatus#{status}#{estimated_total_time}#{percentage}#{i.id}')]] 207 | estimated_total_time = TimeFormatter(milliseconds=estimated_total_time) 208 | estimated_total_time = estimated_total_time if estimated_total_time != '' else '0 s' 209 | 210 | text = TEXT.format(i.fetched, i.total_files, i.duplicate, i.deleted, i.skip, status, percentage, estimated_total_time, progress) 211 | if status in ["cancelled", "completed"]: 212 | button.append( 213 | [InlineKeyboardButton('📢 Updates', url='https://t.me/Madflix_Bots'), 214 | InlineKeyboardButton('💬 Support', url='https://t.me/MadflixBots_Support')] 215 | ) 216 | else: 217 | button.append([InlineKeyboardButton('✖️ Cancel ✖️', 'terminate_frwd')]) 218 | await msg_edit(msg, text, InlineKeyboardMarkup(button)) 219 | 220 | async def is_cancelled(client, user, msg, sts): 221 | if temp.CANCEL.get(user)==True: 222 | temp.IS_FRWD_CHAT.remove(sts.TO) 223 | await edit(msg, "Cancelled", "completed", sts) 224 | await send(client, user, "❌ Forwarding Process Cancelled") 225 | await stop(client, user) 226 | return True 227 | return False 228 | 229 | async def stop(client, user): 230 | try: 231 | await client.stop() 232 | except: 233 | pass 234 | await db.rmve_frwd(user) 235 | temp.forwardings -= 1 236 | temp.lock[user] = False 237 | 238 | async def send(bot, user, text): 239 | try: 240 | await bot.send_message(user, text=text) 241 | except: 242 | pass 243 | 244 | def custom_caption(msg, caption): 245 | if msg.media: 246 | if (msg.video or msg.document or msg.audio or msg.photo): 247 | media = getattr(msg, msg.media.value, None) 248 | if media: 249 | file_name = getattr(media, 'file_name', '') 250 | file_size = getattr(media, 'file_size', '') 251 | fcaption = getattr(msg, 'caption', '') 252 | if fcaption: 253 | fcaption = fcaption.html 254 | if caption: 255 | return caption.format(filename=file_name, size=get_size(file_size), caption=fcaption) 256 | return fcaption 257 | return None 258 | 259 | def get_size(size): 260 | units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"] 261 | size = float(size) 262 | i = 0 263 | while size >= 1024.0 and i < len(units): 264 | i += 1 265 | size /= 1024.0 266 | return "%.2f %s" % (size, units[i]) 267 | 268 | def media(msg): 269 | if msg.media: 270 | media = getattr(msg, msg.media.value, None) 271 | if media: 272 | return getattr(media, 'file_id', None) 273 | return None 274 | 275 | def TimeFormatter(milliseconds: int) -> str: 276 | seconds, milliseconds = divmod(int(milliseconds), 1000) 277 | minutes, seconds = divmod(seconds, 60) 278 | hours, minutes = divmod(minutes, 60) 279 | days, hours = divmod(hours, 24) 280 | tmp = ((str(days) + "d, ") if days else "") + \ 281 | ((str(hours) + "h, ") if hours else "") + \ 282 | ((str(minutes) + "m, ") if minutes else "") + \ 283 | ((str(seconds) + "s, ") if seconds else "") + \ 284 | ((str(milliseconds) + "ms, ") if milliseconds else "") 285 | return tmp[:-2] 286 | 287 | def retry_btn(id): 288 | return InlineKeyboardMarkup([[InlineKeyboardButton('♻️ Retry ♻️', f"start_public_{id}")]]) 289 | 290 | 291 | 292 | 293 | @Client.on_callback_query(filters.regex(r'^terminate_frwd$')) 294 | async def terminate_frwding(bot, m): 295 | user_id = m.from_user.id 296 | temp.lock[user_id] = False 297 | temp.CANCEL[user_id] = True 298 | await m.answer("Forwarding Cancelled !", show_alert=True) 299 | 300 | 301 | 302 | 303 | @Client.on_callback_query(filters.regex(r'^fwrdstatus')) 304 | async def status_msg(bot, msg): 305 | _, status, est_time, percentage, frwd_id = msg.data.split("#") 306 | sts = STS(frwd_id) 307 | if not sts.verify(): 308 | fetched, forwarded, remaining = 0 309 | else: 310 | fetched, forwarded = sts.get('fetched'), sts.get('total_files') 311 | remaining = fetched - forwarded 312 | est_time = TimeFormatter(milliseconds=est_time) 313 | est_time = est_time if (est_time != '' or status not in ['completed', 'cancelled']) else '0 s' 314 | return await msg.answer(PROGRESS.format(percentage, fetched, forwarded, remaining, status, est_time), show_alert=True) 315 | 316 | 317 | 318 | 319 | @Client.on_callback_query(filters.regex(r'^close_btn$')) 320 | async def close(bot, update): 321 | await update.answer() 322 | await update.message.delete() 323 | await update.message.reply_to_message.delete() 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | # Jishu Developer 332 | # Don't Remove Credit 🥺 333 | # Telegram Channel @Madflix_Bots 334 | # Backup Channel @JishuBotz 335 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/settings.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import asyncio 11 | from database import db 12 | from config import Config 13 | from translation import Translation 14 | from pyrogram import Client, filters 15 | from .test import get_configs, update_configs, CLIENT, parse_buttons 16 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 17 | 18 | CLIENT = CLIENT() 19 | 20 | 21 | 22 | @Client.on_message(filters.private & filters.command(['settings'])) 23 | async def settings(client, message): 24 | text="Change Your Settings As Your Wish" 25 | await message.reply_text( 26 | text=text, 27 | reply_markup=main_buttons(), 28 | quote=True 29 | ) 30 | 31 | 32 | 33 | 34 | @Client.on_callback_query(filters.regex(r'^settings')) 35 | async def settings_query(bot, query): 36 | user_id = query.from_user.id 37 | i, type = query.data.split("#") 38 | buttons = [[InlineKeyboardButton('🔙 Back', callback_data="settings#main")]] 39 | 40 | if type=="main": 41 | await query.message.edit_text( 42 | "Change Your Settings As Your Wish", 43 | reply_markup=main_buttons()) 44 | 45 | elif type=="bots": 46 | buttons = [] 47 | _bot = await db.get_bot(user_id) 48 | if _bot is not None: 49 | buttons.append([InlineKeyboardButton(_bot['name'], 50 | callback_data=f"settings#editbot")]) 51 | else: 52 | buttons.append([InlineKeyboardButton('✚ Add Bot ✚', 53 | callback_data="settings#addbot")]) 54 | buttons.append([InlineKeyboardButton('✚ Add User Bot ✚', 55 | callback_data="settings#adduserbot")]) 56 | buttons.append([InlineKeyboardButton('🔙 Back', 57 | callback_data="settings#main")]) 58 | await query.message.edit_text( 59 | "My Bots\n\nYou Can Manage Your Bots In Here", 60 | reply_markup=InlineKeyboardMarkup(buttons)) 61 | 62 | elif type=="addbot": 63 | await query.message.delete() 64 | bot = await CLIENT.add_bot(bot, query) 65 | if bot != True: return 66 | await query.message.reply_text( 67 | "Bot Token Successfully Added To Database", 68 | reply_markup=InlineKeyboardMarkup(buttons)) 69 | 70 | elif type=="adduserbot": 71 | await query.message.delete() 72 | user = await CLIENT.add_session(bot, query) 73 | if user != True: return 74 | await query.message.reply_text( 75 | "Session Successfully Added To Database", 76 | reply_markup=InlineKeyboardMarkup(buttons)) 77 | 78 | elif type=="channels": 79 | buttons = [] 80 | channels = await db.get_user_channels(user_id) 81 | for channel in channels: 82 | buttons.append([InlineKeyboardButton(f"{channel['title']}", 83 | callback_data=f"settings#editchannels_{channel['chat_id']}")]) 84 | buttons.append([InlineKeyboardButton('✚ Add Channel ✚', 85 | callback_data="settings#addchannel")]) 86 | buttons.append([InlineKeyboardButton('🔙 Back', 87 | callback_data="settings#main")]) 88 | await query.message.edit_text( 89 | "My Channels\n\nYou Can Manage Your Target Chats In Here", 90 | reply_markup=InlineKeyboardMarkup(buttons)) 91 | 92 | elif type=="addchannel": 93 | await query.message.delete() 94 | try: 95 | text = await bot.send_message(user_id, "Set Target Chat\n\nForward A Message From Your Target Chat\n/cancel - To Cancel This Process") 96 | chat_ids = await bot.listen(chat_id=user_id, timeout=300) 97 | if chat_ids.text=="/cancel": 98 | await chat_ids.delete() 99 | return await text.edit_text( 100 | "Process Canceled", 101 | reply_markup=InlineKeyboardMarkup(buttons)) 102 | elif not chat_ids.forward_date: 103 | await chat_ids.delete() 104 | return await text.edit_text("This Is Not A Forward Message") 105 | else: 106 | chat_id = chat_ids.forward_from_chat.id 107 | title = chat_ids.forward_from_chat.title 108 | username = chat_ids.forward_from_chat.username 109 | username = "@" + username if username else "private" 110 | chat = await db.add_channel(user_id, chat_id, title, username) 111 | await chat_ids.delete() 112 | await text.edit_text( 113 | "Successfully Updated" if chat else "This Channel Already Added", 114 | reply_markup=InlineKeyboardMarkup(buttons)) 115 | except asyncio.exceptions.TimeoutError: 116 | await text.edit_text('Process Has Been Automatically Cancelled', reply_markup=InlineKeyboardMarkup(buttons)) 117 | 118 | elif type=="editbot": 119 | bot = await db.get_bot(user_id) 120 | TEXT = Translation.BOT_DETAILS if bot['is_bot'] else Translation.USER_DETAILS 121 | buttons = [[InlineKeyboardButton('❌ Remove ❌', callback_data=f"settings#removebot") 122 | ], 123 | [InlineKeyboardButton('🔙 Back', callback_data="settings#bots")]] 124 | await query.message.edit_text( 125 | TEXT.format(bot['name'], bot['id'], bot['username']), 126 | reply_markup=InlineKeyboardMarkup(buttons)) 127 | 128 | elif type=="removebot": 129 | await db.remove_bot(user_id) 130 | await query.message.edit_text( 131 | "Successfully Updated", 132 | reply_markup=InlineKeyboardMarkup(buttons)) 133 | 134 | elif type.startswith("editchannels"): 135 | chat_id = type.split('_')[1] 136 | chat = await db.get_channel_details(user_id, chat_id) 137 | buttons = [[InlineKeyboardButton('❌ Remove ❌', callback_data=f"settings#removechannel_{chat_id}") 138 | ], 139 | [InlineKeyboardButton('🔙 Back', callback_data="settings#channels")]] 140 | await query.message.edit_text( 141 | f"📄 Channel Details\n\nTitle : {chat['title']}\nChannel ID : {chat['chat_id']}\nUsername : {chat['username']}", 142 | reply_markup=InlineKeyboardMarkup(buttons)) 143 | 144 | elif type.startswith("removechannel"): 145 | chat_id = type.split('_')[1] 146 | await db.remove_channel(user_id, chat_id) 147 | await query.message.edit_text( 148 | "Successfully Updated", 149 | reply_markup=InlineKeyboardMarkup(buttons)) 150 | 151 | elif type=="caption": 152 | buttons = [] 153 | data = await get_configs(user_id) 154 | caption = data['caption'] 155 | if caption is None: 156 | buttons.append([InlineKeyboardButton('✚ Add Caption ✚', 157 | callback_data="settings#addcaption")]) 158 | else: 159 | buttons.append([InlineKeyboardButton('👀 See Caption', 160 | callback_data="settings#seecaption")]) 161 | buttons[-1].append(InlineKeyboardButton('🗑️ Delete Caption', 162 | callback_data="settings#deletecaption")) 163 | buttons.append([InlineKeyboardButton('🔙 Back', 164 | callback_data="settings#main")]) 165 | await query.message.edit_text( 166 | "Custom Caption\n\nYou Can Set A Custom Caption To Videos And Documents. Normaly Use Its Default Caption\n\nAvailable Fillings :\n\n{filename} : Filename\n{size} : File Size\n{caption} : Default Caption", 167 | reply_markup=InlineKeyboardMarkup(buttons)) 168 | 169 | elif type=="seecaption": 170 | data = await get_configs(user_id) 171 | buttons = [[InlineKeyboardButton('✏️ Edit Caption', 172 | callback_data="settings#addcaption") 173 | ],[ 174 | InlineKeyboardButton('🔙 Back', 175 | callback_data="settings#caption")]] 176 | await query.message.edit_text( 177 | f"Your Custom Caption\n\n{data['caption']}", 178 | reply_markup=InlineKeyboardMarkup(buttons)) 179 | 180 | elif type=="deletecaption": 181 | await update_configs(user_id, 'caption', None) 182 | await query.message.edit_text( 183 | "Successfully Updated", 184 | reply_markup=InlineKeyboardMarkup(buttons)) 185 | 186 | elif type=="addcaption": 187 | await query.message.delete() 188 | try: 189 | text = await bot.send_message(query.message.chat.id, "Send your custom caption\n/cancel - cancel this process") 190 | caption = await bot.listen(chat_id=user_id, timeout=300) 191 | if caption.text=="/cancel": 192 | await caption.delete() 193 | return await text.edit_text( 194 | "Process Canceled !", 195 | reply_markup=InlineKeyboardMarkup(buttons)) 196 | try: 197 | caption.text.format(filename='', size='', caption='') 198 | except KeyError as e: 199 | await caption.delete() 200 | return await text.edit_text( 201 | f"Wrong Filling {e} Used In Your Caption. Change It", 202 | reply_markup=InlineKeyboardMarkup(buttons)) 203 | await update_configs(user_id, 'caption', caption.text) 204 | await caption.delete() 205 | await text.edit_text( 206 | "Successfully Updated", 207 | reply_markup=InlineKeyboardMarkup(buttons)) 208 | except asyncio.exceptions.TimeoutError: 209 | await text.edit_text('Process Has Been Automatically Cancelled', reply_markup=InlineKeyboardMarkup(buttons)) 210 | 211 | elif type=="button": 212 | buttons = [] 213 | button = (await get_configs(user_id))['button'] 214 | if button is None: 215 | buttons.append([InlineKeyboardButton('✚ Add Button ✚', 216 | callback_data="settings#addbutton")]) 217 | else: 218 | buttons.append([InlineKeyboardButton('👀 See Button', 219 | callback_data="settings#seebutton")]) 220 | buttons[-1].append(InlineKeyboardButton('🗑️ Remove Button ', 221 | callback_data="settings#deletebutton")) 222 | buttons.append([InlineKeyboardButton('🔙 Back', 223 | callback_data="settings#main")]) 224 | await query.message.edit_text( 225 | "Custom Button\n\nYou Can Set A Inline Button To Messages.\n\nFormat :\n`[Madflix Botz][buttonurl:https://t.me/Madflix_Bots]`\n", 226 | reply_markup=InlineKeyboardMarkup(buttons)) 227 | 228 | elif type=="addbutton": 229 | await query.message.delete() 230 | try: 231 | txt = await bot.send_message(user_id, text="**Send your custom button.\n\nFORMAT:**\n`[forward bot][buttonurl:https://t.me/KR_Forward_Bot]`\n") 232 | ask = await bot.listen(chat_id=user_id, timeout=300) 233 | button = parse_buttons(ask.text.html) 234 | if not button: 235 | await ask.delete() 236 | return await txt.edit_text("Invalid Button") 237 | await update_configs(user_id, 'button', ask.text.html) 238 | await ask.delete() 239 | await txt.edit_text("Successfully Button Added", 240 | reply_markup=InlineKeyboardMarkup(buttons)) 241 | except asyncio.exceptions.TimeoutError: 242 | await txt.edit_text('Process Has Been Automatically Cancelled', reply_markup=InlineKeyboardMarkup(buttons)) 243 | 244 | elif type=="seebutton": 245 | button = (await get_configs(user_id))['button'] 246 | button = parse_buttons(button, markup=False) 247 | button.append([InlineKeyboardButton("🔙 Back", "settings#button")]) 248 | await query.message.edit_text( 249 | "**Your Custom Button**", 250 | reply_markup=InlineKeyboardMarkup(button)) 251 | 252 | elif type=="deletebutton": 253 | await update_configs(user_id, 'button', None) 254 | await query.message.edit_text( 255 | "Successfully Button Deleted", 256 | reply_markup=InlineKeyboardMarkup(buttons)) 257 | 258 | elif type=="database": 259 | buttons = [] 260 | db_uri = (await get_configs(user_id))['db_uri'] 261 | if db_uri is None: 262 | buttons.append([InlineKeyboardButton('✚ Add URL ✚', 263 | callback_data="settings#addurl")]) 264 | else: 265 | buttons.append([InlineKeyboardButton('👀 See URL', 266 | callback_data="settings#seeurl")]) 267 | buttons[-1].append(InlineKeyboardButton('🗑️ Remove URL', 268 | callback_data="settings#deleteurl")) 269 | buttons.append([InlineKeyboardButton('🔙 Back', 270 | callback_data="settings#main")]) 271 | await query.message.edit_text( 272 | "Database\n\nDatabase Is Required For Store Your Duplicate Messages Permenant. Other Wise Stored Duplicate Media May Be Disappeared When After Bot Restart.", 273 | reply_markup=InlineKeyboardMarkup(buttons)) 274 | 275 | elif type=="addurl": 276 | await query.message.delete() 277 | uri = await bot.ask(user_id, "please send your mongodb url.\n\nget your Mongodb url from [here](https://mongodb.com)", disable_web_page_preview=True) 278 | if uri.text=="/cancel": 279 | return await uri.reply_text( 280 | "Process Cancelled !", 281 | reply_markup=InlineKeyboardMarkup(buttons)) 282 | if not uri.text.startswith("mongodb+srv://") and not uri.text.endswith("majority"): 283 | return await uri.reply("Invalid Mongodb URL", 284 | reply_markup=InlineKeyboardMarkup(buttons)) 285 | await update_configs(user_id, 'db_uri', uri.text) 286 | await uri.reply("Successfully Database URL Added ✅", 287 | reply_markup=InlineKeyboardMarkup(buttons)) 288 | 289 | elif type=="seeurl": 290 | db_uri = (await get_configs(user_id))['db_uri'] 291 | await query.answer(f"Database URL : {db_uri}", show_alert=True) 292 | 293 | elif type=="deleteurl": 294 | await update_configs(user_id, 'db_uri', None) 295 | await query.message.edit_text( 296 | "Successfully Your Database URL Deleted", 297 | reply_markup=InlineKeyboardMarkup(buttons)) 298 | 299 | elif type=="filters": 300 | await query.message.edit_text( 301 | "Custom Filters\n\nConfigure The Type Of Messages Which You Want Forward", 302 | reply_markup=await filters_buttons(user_id)) 303 | 304 | elif type=="nextfilters": 305 | await query.edit_message_reply_markup( 306 | reply_markup=await next_filters_buttons(user_id)) 307 | 308 | elif type.startswith("updatefilter"): 309 | i, key, value = type.split('-') 310 | if value=="True": 311 | await update_configs(user_id, key, False) 312 | else: 313 | await update_configs(user_id, key, True) 314 | if key in ['poll', 'protect']: 315 | return await query.edit_message_reply_markup( 316 | reply_markup=await next_filters_buttons(user_id)) 317 | await query.edit_message_reply_markup( 318 | reply_markup=await filters_buttons(user_id)) 319 | 320 | elif type.startswith("file_size"): 321 | settings = await get_configs(user_id) 322 | size = settings.get('file_size', 0) 323 | i, limit = size_limit(settings['size_limit']) 324 | await query.message.edit_text( 325 | f'Size Limit\n\nYou Can Set File Size Limit To Forward\n\nStatus : Files With {limit} `{size} MB` Will Forward', 326 | reply_markup=size_button(size)) 327 | 328 | elif type.startswith("update_size"): 329 | size = int(query.data.split('-')[1]) 330 | if 0 < size > 2000: 331 | return await query.answer("Size Limit Exceeded", show_alert=True) 332 | await update_configs(user_id, 'file_size', size) 333 | i, limit = size_limit((await get_configs(user_id))['size_limit']) 334 | await query.message.edit_text( 335 | f'Size Limit\n\nYou Can Set File Size Limit To Forward\n\nStatus : Files With {limit} `{size} MB` Will Forward', 336 | reply_markup=size_button(size)) 337 | 338 | elif type.startswith('update_limit'): 339 | i, limit, size = type.split('-') 340 | limit, sts = size_limit(limit) 341 | await update_configs(user_id, 'size_limit', limit) 342 | await query.message.edit_text( 343 | f'Size Limit\n\nYou Can Set File Size Limit To Forward\n\nStatus : Files With {sts} `{size} MB` Will Forward', 344 | reply_markup=size_button(int(size))) 345 | 346 | elif type == "add_extension": 347 | await query.message.delete() 348 | ext = await bot.ask(user_id, text="Please Send Your Extensions (Seperete By Space)") 349 | if ext.text == '/cancel': 350 | return await ext.reply_text( 351 | "Process Cancelled", 352 | reply_markup=InlineKeyboardMarkup(buttons)) 353 | extensions = ext.text.split(" ") 354 | extension = (await get_configs(user_id))['extension'] 355 | if extension: 356 | for extn in extensions: 357 | extension.append(extn) 358 | else: 359 | extension = extensions 360 | await update_configs(user_id, 'extension', extension) 361 | await ext.reply_text( 362 | f"Successfully Updated", 363 | reply_markup=InlineKeyboardMarkup(buttons)) 364 | 365 | elif type == "get_extension": 366 | extensions = (await get_configs(user_id))['extension'] 367 | btn = extract_btn(extensions) 368 | btn.append([InlineKeyboardButton('✚ Add ✚', 'settings#add_extension')]) 369 | btn.append([InlineKeyboardButton('Remove All', 'settings#rmve_all_extension')]) 370 | btn.append([InlineKeyboardButton('🔙 Back', 'settings#main')]) 371 | await query.message.edit_text( 372 | text='Extensions\n\nFiles With These Extiontions Will Not Forward', 373 | reply_markup=InlineKeyboardMarkup(btn)) 374 | 375 | elif type == "rmve_all_extension": 376 | await update_configs(user_id, 'extension', None) 377 | await query.message.edit_text(text="Successfully Deleted", 378 | reply_markup=InlineKeyboardMarkup(buttons)) 379 | elif type == "add_keyword": 380 | await query.message.delete() 381 | ask = await bot.ask(user_id, text="Please Send The Keywords (Seperete By Space)") 382 | if ask.text == '/cancel': 383 | return await ask.reply_text( 384 | "Process Canceled", 385 | reply_markup=InlineKeyboardMarkup(buttons)) 386 | keywords = ask.text.split(" ") 387 | keyword = (await get_configs(user_id))['keywords'] 388 | if keyword: 389 | for word in keywords: 390 | keyword.append(word) 391 | else: 392 | keyword = keywords 393 | await update_configs(user_id, 'keywords', keyword) 394 | await ask.reply_text( 395 | f"Successfully Updated", 396 | reply_markup=InlineKeyboardMarkup(buttons)) 397 | 398 | elif type == "get_keyword": 399 | keywords = (await get_configs(user_id))['keywords'] 400 | btn = extract_btn(keywords) 401 | btn.append([InlineKeyboardButton('✚ Add ✚', 'settings#add_keyword')]) 402 | btn.append([InlineKeyboardButton('Remove All', 'settings#rmve_all_keyword')]) 403 | btn.append([InlineKeyboardButton('🔙 Back', 'settings#main')]) 404 | await query.message.edit_text( 405 | text='Keywords\n\nFile With These Keywords In File Name Will Forwad', 406 | reply_markup=InlineKeyboardMarkup(btn)) 407 | 408 | elif type == "rmve_all_keyword": 409 | await update_configs(user_id, 'keywords', None) 410 | await query.message.edit_text(text="Successfully Deleted", 411 | reply_markup=InlineKeyboardMarkup(buttons)) 412 | elif type.startswith("alert"): 413 | alert = type.split('_')[1] 414 | await query.answer(alert, show_alert=True) 415 | 416 | def main_buttons(): 417 | buttons = [[ 418 | InlineKeyboardButton('🤖 Bots', 419 | callback_data=f'settings#bots'), 420 | InlineKeyboardButton('🔥 Channels', 421 | callback_data=f'settings#channels') 422 | ],[ 423 | InlineKeyboardButton('✏️ Caption', 424 | callback_data=f'settings#caption'), 425 | InlineKeyboardButton('🗃 MongoDB', 426 | callback_data=f'settings#database') 427 | ],[ 428 | InlineKeyboardButton('🕵‍♀ Filters', 429 | callback_data=f'settings#filters'), 430 | InlineKeyboardButton('🏓 Button', 431 | callback_data=f'settings#button') 432 | ],[ 433 | InlineKeyboardButton('⚙️ Extra Settings', 434 | callback_data='settings#nextfilters') 435 | ],[ 436 | InlineKeyboardButton('🔙 Back', callback_data='back') 437 | ]] 438 | return InlineKeyboardMarkup(buttons) 439 | 440 | def size_limit(limit): 441 | if str(limit) == "None": 442 | return None, "" 443 | elif str(limit) == "True": 444 | return True, "more than" 445 | else: 446 | return False, "less than" 447 | 448 | def extract_btn(datas): 449 | i = 0 450 | btn = [] 451 | if datas: 452 | for data in datas: 453 | if i >= 5: 454 | i = 0 455 | if i == 0: 456 | btn.append([InlineKeyboardButton(data, f'settings#alert_{data}')]) 457 | i += 1 458 | continue 459 | elif i > 0: 460 | btn[-1].append(InlineKeyboardButton(data, f'settings#alert_{data}')) 461 | i += 1 462 | return btn 463 | 464 | def size_button(size): 465 | buttons = [[ 466 | InlineKeyboardButton('+', 467 | callback_data=f'settings#update_limit-True-{size}'), 468 | InlineKeyboardButton('=', 469 | callback_data=f'settings#update_limit-None-{size}'), 470 | InlineKeyboardButton('-', 471 | callback_data=f'settings#update_limit-False-{size}') 472 | ],[ 473 | InlineKeyboardButton('+1', 474 | callback_data=f'settings#update_size-{size + 1}'), 475 | InlineKeyboardButton('-1', 476 | callback_data=f'settings#update_size_-{size - 1}') 477 | ],[ 478 | InlineKeyboardButton('+5', 479 | callback_data=f'settings#update_size-{size + 5}'), 480 | InlineKeyboardButton('-5', 481 | callback_data=f'settings#update_size_-{size - 5}') 482 | ],[ 483 | InlineKeyboardButton('+10', 484 | callback_data=f'settings#update_size-{size + 10}'), 485 | InlineKeyboardButton('-10', 486 | callback_data=f'settings#update_size_-{size - 10}') 487 | ],[ 488 | InlineKeyboardButton('+50', 489 | callback_data=f'settings#update_size-{size + 50}'), 490 | InlineKeyboardButton('-50', 491 | callback_data=f'settings#update_size_-{size - 50}') 492 | ],[ 493 | InlineKeyboardButton('+100', 494 | callback_data=f'settings#update_size-{size + 100}'), 495 | InlineKeyboardButton('-100', 496 | callback_data=f'settings#update_size_-{size - 100}') 497 | ],[ 498 | InlineKeyboardButton('↩ Back', 499 | callback_data="settings#main") 500 | ]] 501 | return InlineKeyboardMarkup(buttons) 502 | 503 | async def filters_buttons(user_id): 504 | filter = await get_configs(user_id) 505 | filters = filter['filters'] 506 | buttons = [[ 507 | InlineKeyboardButton('🏷️ Forward Tag', 508 | callback_data=f'settings_#updatefilter-forward_tag-{filter["forward_tag"]}'), 509 | InlineKeyboardButton('✅' if filter['forward_tag'] else '❌', 510 | callback_data=f'settings#updatefilter-forward_tag-{filter["forward_tag"]}') 511 | ],[ 512 | InlineKeyboardButton('🖍️ Texts', 513 | callback_data=f'settings_#updatefilter-text-{filters["text"]}'), 514 | InlineKeyboardButton('✅' if filters['text'] else '❌', 515 | callback_data=f'settings#updatefilter-text-{filters["text"]}') 516 | ],[ 517 | InlineKeyboardButton('📁 Documents', 518 | callback_data=f'settings_#updatefilter-document-{filters["document"]}'), 519 | InlineKeyboardButton('✅' if filters['document'] else '❌', 520 | callback_data=f'settings#updatefilter-document-{filters["document"]}') 521 | ],[ 522 | InlineKeyboardButton('🎞️ Videos', 523 | callback_data=f'settings_#updatefilter-video-{filters["video"]}'), 524 | InlineKeyboardButton('✅' if filters['video'] else '❌', 525 | callback_data=f'settings#updatefilter-video-{filters["video"]}') 526 | ],[ 527 | InlineKeyboardButton('📷 Photos', 528 | callback_data=f'settings_#updatefilter-photo-{filters["photo"]}'), 529 | InlineKeyboardButton('✅' if filters['photo'] else '❌', 530 | callback_data=f'settings#updatefilter-photo-{filters["photo"]}') 531 | ],[ 532 | InlineKeyboardButton('🎧 Audios', 533 | callback_data=f'settings_#updatefilter-audio-{filters["audio"]}'), 534 | InlineKeyboardButton('✅' if filters['audio'] else '❌', 535 | callback_data=f'settings#updatefilter-audio-{filters["audio"]}') 536 | ],[ 537 | InlineKeyboardButton('🎤 Voices', 538 | callback_data=f'settings_#updatefilter-voice-{filters["voice"]}'), 539 | InlineKeyboardButton('✅' if filters['voice'] else '❌', 540 | callback_data=f'settings#updatefilter-voice-{filters["voice"]}') 541 | ],[ 542 | InlineKeyboardButton('🎭 Animations', 543 | callback_data=f'settings_#updatefilter-animation-{filters["animation"]}'), 544 | InlineKeyboardButton('✅' if filters['animation'] else '❌', 545 | callback_data=f'settings#updatefilter-animation-{filters["animation"]}') 546 | ],[ 547 | InlineKeyboardButton('🃏 Stickers', 548 | callback_data=f'settings_#updatefilter-sticker-{filters["sticker"]}'), 549 | InlineKeyboardButton('✅' if filters['sticker'] else '❌', 550 | callback_data=f'settings#updatefilter-sticker-{filters["sticker"]}') 551 | ],[ 552 | InlineKeyboardButton('▶️ Skip Duplicate', 553 | callback_data=f'settings_#updatefilter-duplicate-{filter["duplicate"]}'), 554 | InlineKeyboardButton('✅' if filter['duplicate'] else '❌', 555 | callback_data=f'settings#updatefilter-duplicate-{filter["duplicate"]}') 556 | ],[ 557 | InlineKeyboardButton('🔙 back', 558 | callback_data="settings#main") 559 | ]] 560 | return InlineKeyboardMarkup(buttons) 561 | 562 | async def next_filters_buttons(user_id): 563 | filter = await get_configs(user_id) 564 | filters = filter['filters'] 565 | buttons = [[ 566 | InlineKeyboardButton('📊 Poll', 567 | callback_data=f'settings_#updatefilter-poll-{filters["poll"]}'), 568 | InlineKeyboardButton('✅' if filters['poll'] else '❌', 569 | callback_data=f'settings#updatefilter-poll-{filters["poll"]}') 570 | ],[ 571 | InlineKeyboardButton('🔒 Secure Message', 572 | callback_data=f'settings_#updatefilter-protect-{filter["protect"]}'), 573 | InlineKeyboardButton('✅' if filter['protect'] else '❌', 574 | callback_data=f'settings#updatefilter-protect-{filter["protect"]}') 575 | ],[ 576 | InlineKeyboardButton('🛑 Size Limit', 577 | callback_data='settings#file_size') 578 | ],[ 579 | InlineKeyboardButton('💾 Extension', 580 | callback_data='settings#get_extension') 581 | ],[ 582 | InlineKeyboardButton('📌 Keywords', 583 | callback_data='settings#get_keyword') 584 | ],[ 585 | InlineKeyboardButton('🔙 Back', 586 | callback_data="settings#main") 587 | ]] 588 | return InlineKeyboardMarkup(buttons) 589 | 590 | 591 | 592 | 593 | 594 | 595 | # Jishu Developer 596 | # Don't Remove Credit 🥺 597 | # Telegram Channel @Madflix_Bots 598 | # Backup Channel @JishuBotz 599 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/test.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import os 11 | import re 12 | import sys 13 | import typing 14 | import asyncio 15 | import logging 16 | from database import db 17 | from config import Config, temp 18 | from pyrogram import Client, filters 19 | from pyrogram.raw.all import layer 20 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message 21 | from pyrogram.errors.exceptions.bad_request_400 import AccessTokenExpired, AccessTokenInvalid 22 | from pyrogram.errors import FloodWait 23 | from config import Config 24 | from translation import Translation 25 | 26 | from typing import Union, Optional, AsyncGenerator 27 | 28 | logger = logging.getLogger(__name__) 29 | logger.setLevel(logging.INFO) 30 | 31 | BTN_URL_REGEX = re.compile(r"(\[([^\[]+?)]\[buttonurl:/{0,2}(.+?)(:same)?])") 32 | BOT_TOKEN_TEXT = "1) Create A Bot Using @BotFather\n\n2) Then You Will Get A Message With Bot Token\n\n3) Forward That Message To Me" 33 | SESSION_STRING_SIZE = 351 34 | 35 | 36 | 37 | async def start_clone_bot(FwdBot, data=None): 38 | await FwdBot.start() 39 | # 40 | async def iter_messages( 41 | self, 42 | chat_id: Union[int, str], 43 | limit: int, 44 | offset: int = 0, 45 | search: str = None, 46 | filter: "types.TypeMessagesFilter" = None, 47 | ) -> Optional[AsyncGenerator["types.Message", None]]: 48 | """Iterate through a chat sequentially. 49 | This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving 50 | you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a 51 | single call. 52 | Parameters: 53 | chat_id (``int`` | ``str``): 54 | Unique identifier (int) or username (str) of the target chat. 55 | For your personal cloud (Saved Messages) you can simply use "me" or "self". 56 | For a contact that exists in your Telegram address book you can use his phone number (str). 57 | 58 | limit (``int``): 59 | Identifier of the last message to be returned. 60 | 61 | offset (``int``, *optional*): 62 | Identifier of the first message to be returned. 63 | Defaults to 0. 64 | Returns: 65 | ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects. 66 | Example: 67 | .. code-block:: python 68 | for message in app.iter_messages("pyrogram", 1, 15000): 69 | print(message.text) 70 | """ 71 | current = offset 72 | while True: 73 | new_diff = min(200, limit - current) 74 | if new_diff <= 0: 75 | return 76 | messages = await self.get_messages(chat_id, list(range(current, current+new_diff+1))) 77 | for message in messages: 78 | yield message 79 | current += 1 80 | # 81 | FwdBot.iter_messages = iter_messages 82 | return FwdBot 83 | 84 | 85 | 86 | class CLIENT: 87 | def __init__(self): 88 | self.api_id = Config.API_ID 89 | self.api_hash = Config.API_HASH 90 | 91 | def client(self, data, user=None): 92 | if user == None and data.get('is_bot') == False: 93 | return Client("USERBOT", self.api_id, self.api_hash, session_string=data.get('session')) 94 | elif user == True: 95 | return Client("USERBOT", self.api_id, self.api_hash, session_string=data) 96 | elif user != False: 97 | data = data.get('token') 98 | return Client("BOT", self.api_id, self.api_hash, bot_token=data, in_memory=True) 99 | 100 | 101 | 102 | async def add_bot(self, bot, message): 103 | user_id = int(message.from_user.id) 104 | msg = await bot.ask(chat_id=user_id, text=BOT_TOKEN_TEXT) 105 | if msg.text=='/cancel': 106 | return await msg.reply('Process Cancelled !') 107 | elif not msg.forward_date: 108 | return await msg.reply_text("This Is Not A Forward Message") 109 | elif str(msg.forward_from.id) != "93372553": 110 | return await msg.reply_text("This Message Was Not Forward From Bot Father") 111 | bot_token = re.findall(r'\d[0-9]{8,10}:[0-9A-Za-z_-]{35}', msg.text, re.IGNORECASE) 112 | bot_token = bot_token[0] if bot_token else None 113 | if not bot_token: 114 | return await msg.reply_text("There Is No Bot Token In That Message") 115 | try: 116 | _client = await start_clone_bot(self.client(bot_token, False), True) 117 | except Exception as e: 118 | await msg.reply_text(f"Bot Error :
`{e}`") 119 | _bot = _client.me 120 | details = { 121 | 'id': _bot.id, 122 | 'is_bot': True, 123 | 'user_id': user_id, 124 | 'name': _bot.first_name, 125 | 'token': bot_token, 126 | 'username': _bot.username 127 | } 128 | await db.add_bot(details) 129 | return True 130 | 131 | 132 | 133 | async def add_session(self, bot, message): 134 | user_id = int(message.from_user.id) 135 | text = "⚠️ Disclaimer ⚠️\n\nYou Can Use Your Session For Forward Message From Private Chat To Another Chat.\nPlease Add Your Pyrogram Session With Your Own Risk. Their Is A Chance To Ban Your Account. My Developer Is Not Responsible If Your Account May Get Banned." 136 | await bot.send_message(user_id, text=text) 137 | msg = await bot.ask(chat_id=user_id, text="Send your pyrogram session.\nget it from @mdsessiongenbot\n\n/cancel - cancel the process") 138 | if msg.text=='/cancel': 139 | return await msg.reply('Process Cancelled !') 140 | elif len(msg.text) < SESSION_STRING_SIZE: 141 | return await msg.reply('Invalid Session String') 142 | try: 143 | client = await start_clone_bot(self.client(msg.text, True), True) 144 | except Exception as e: 145 | await msg.reply_text(f"User Bot Error : `{e}`") 146 | user = client.me 147 | details = { 148 | 'id': user.id, 149 | 'is_bot': False, 150 | 'user_id': user_id, 151 | 'name': user.first_name, 152 | 'session': msg.text, 153 | 'username': user.username 154 | } 155 | await db.add_bot(details) 156 | return True 157 | 158 | 159 | 160 | 161 | 162 | 163 | @Client.on_message(filters.private & filters.command('reset')) 164 | async def forward_tag(bot, m): 165 | default = await db.get_configs("01") 166 | temp.CONFIGS[m.from_user.id] = default 167 | await db.update_configs(m.from_user.id, default) 168 | await m.reply("Successfully Settings Reseted ✔️") 169 | 170 | 171 | 172 | 173 | @Client.on_message(filters.command('resetall') & filters.user(Config.OWNER_ID)) 174 | async def resetall(bot, message): 175 | users = await db.get_all_users() 176 | sts = await message.reply("Processing") 177 | TEXT = "Total: {}\nSuccess: {}\nFailed: {}\nExcept: {}" 178 | total = success = failed = already = 0 179 | ERRORS = [] 180 | async for user in users: 181 | user_id = user['id'] 182 | default = await get_configs(user_id) 183 | default['db_uri'] = None 184 | total += 1 185 | if total %10 == 0: 186 | await sts.edit(TEXT.format(total, success, failed, already)) 187 | try: 188 | await db.update_configs(user_id, default) 189 | success += 1 190 | except Exception as e: 191 | ERRORS.append(e) 192 | failed += 1 193 | if ERRORS: 194 | await message.reply(ERRORS[:100]) 195 | await sts.edit("Completed\n" + TEXT.format(total, success, failed, already)) 196 | 197 | 198 | 199 | async def get_configs(user_id): 200 | #configs = temp.CONFIGS.get(user_id) 201 | #if not configs: 202 | configs = await db.get_configs(user_id) 203 | #temp.CONFIGS[user_id] = configs 204 | return configs 205 | 206 | 207 | 208 | async def update_configs(user_id, key, value): 209 | current = await db.get_configs(user_id) 210 | if key in ['caption', 'duplicate', 'db_uri', 'forward_tag', 'protect', 'file_size', 'size_limit', 'extension', 'keywords', 'button']: 211 | current[key] = value 212 | else: 213 | current['filters'][key] = value 214 | # temp.CONFIGS[user_id] = value 215 | await db.update_configs(user_id, current) 216 | 217 | 218 | def parse_buttons(text, markup=True): 219 | buttons = [] 220 | for match in BTN_URL_REGEX.finditer(text): 221 | n_escapes = 0 222 | to_check = match.start(1) - 1 223 | while to_check > 0 and text[to_check] == "\\": 224 | n_escapes += 1 225 | to_check -= 1 226 | 227 | if n_escapes % 2 == 0: 228 | if bool(match.group(4)) and buttons: 229 | buttons[-1].append(InlineKeyboardButton( 230 | text=match.group(2), 231 | url=match.group(3).replace(" ", ""))) 232 | else: 233 | buttons.append([InlineKeyboardButton( 234 | text=match.group(2), 235 | url=match.group(3).replace(" ", ""))]) 236 | if markup and buttons: 237 | buttons = InlineKeyboardMarkup(buttons) 238 | return buttons if buttons else None 239 | 240 | 241 | 242 | 243 | 244 | 245 | # Jishu Developer 246 | # Don't Remove Credit 🥺 247 | # Telegram Channel @Madflix_Bots 248 | # Backup Channel @JishuBotz 249 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/unequify.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import re, asyncio 11 | from database import db 12 | from config import temp 13 | from .test import CLIENT , start_clone_bot 14 | from translation import Translation 15 | from pyrogram import Client, filters 16 | #from pyropatch.utils import unpack_new_file_id 17 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 18 | 19 | CLIENT = CLIENT() 20 | COMPLETED_BTN = InlineKeyboardMarkup( 21 | [ 22 | [InlineKeyboardButton('📢 Updates', url='https://t.me/Madflix_Bots')], 23 | [InlineKeyboardButton('💬 Support', url='https://t.me/MadflixBots_Support')] 24 | ] 25 | ) 26 | 27 | CANCEL_BTN = InlineKeyboardMarkup([[InlineKeyboardButton('✖️ Cancel ✖️', 'terminate_frwd')]]) 28 | 29 | 30 | 31 | 32 | 33 | @Client.on_message(filters.command("unequify") & filters.private) 34 | async def unequify(client, message): 35 | user_id = message.from_user.id 36 | temp.CANCEL[user_id] = False 37 | if temp.lock.get(user_id) and str(temp.lock.get(user_id))=="True": 38 | return await message.reply("Please Wait Until Previous Task Complete") 39 | _bot = await db.get_bot(user_id) 40 | if not _bot or _bot['is_bot']: 41 | return await message.reply("Need Userbot To Fo This Process. Please Add A Userbot Using /settings") 42 | target = await client.ask(user_id, text="Forward The Last Message From Target Chat Or Send Last Message Link.\n/cancel - To Cancel This Process") 43 | if target.text.startswith("/"): 44 | return await message.reply("Process Cancelled !") 45 | elif target.text: 46 | regex = re.compile(r"(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") 47 | match = regex.match(target.text.replace("?single", "")) 48 | if not match: 49 | return await message.reply('Invalid Link') 50 | chat_id = match.group(4) 51 | last_msg_id = int(match.group(5)) 52 | if chat_id.isnumeric(): 53 | chat_id = int(("-100" + chat_id)) 54 | elif fromid.forward_from_chat.type in ['channel', 'supergroup']: 55 | last_msg_id = target.forward_from_message_id 56 | chat_id = target.forward_from_chat.username or target.forward_from_chat.id 57 | else: 58 | return await message.reply_text("Invalid !") 59 | confirm = await client.ask(user_id, text="Send /yes To Start The Process And /no To Cancel This Process") 60 | if confirm.text.lower() == '/no': 61 | return await confirm.reply("Process Cancelled !") 62 | sts = await confirm.reply("Processing..") 63 | try: 64 | bot = await start_clone_bot(CLIENT.client(_bot)) 65 | except Exception as e: 66 | return await sts.edit(e) 67 | try: 68 | k = await bot.send_message(chat_id, text="testing") 69 | await k.delete() 70 | except: 71 | await sts.edit(f"Please Make Your [Userbot](t.me/{_bot['username']}) Admin In Target Chat With Full Permissions") 72 | return await bot.stop() 73 | MESSAGES = [] 74 | DUPLICATE = [] 75 | total=deleted=0 76 | temp.lock[user_id] = True 77 | try: 78 | await sts.edit(Translation.DUPLICATE_TEXT.format(total, deleted, "Progressing"), reply_markup=CANCEL_BTN) 79 | async for message in bot.search_messages(chat_id=chat_id, filter="document"): 80 | if temp.CANCEL.get(user_id) == True: 81 | await sts.edit(Translation.DUPLICATE_TEXT.format(total, deleted, "Cancelled"), reply_markup=COMPLETED_BTN) 82 | return await bot.stop() 83 | file = message.document 84 | file_id = unpack_new_file_id(file.file_id) 85 | if file_id in MESSAGES: 86 | DUPLICATE.append(message.id) 87 | else: 88 | MESSAGES.append(file_id) 89 | total += 1 90 | if total %10000 == 0: 91 | await sts.edit(Translation.DUPLICATE_TEXT.format(total, deleted, "Progressing"), reply_markup=CANCEL_BTN) 92 | if len(DUPLICATE) >= 100: 93 | await bot.delete_messages(chat_id, DUPLICATE) 94 | deleted += 100 95 | await sts.edit(Translation.DUPLICATE_TEXT.format(total, deleted, "Cancelled"), reply_markup=CANCEL_BTN) 96 | DUPLICATE = [] 97 | if DUPLICATE: 98 | await bot.delete_messages(chat_id, DUPLICATE) 99 | deleted += len(DUPLICATE) 100 | except Exception as e: 101 | temp.lock[user_id] = False 102 | await sts.edit(f"**Error**\n\n`{e}`") 103 | return await bot.stop() 104 | temp.lock[user_id] = False 105 | await sts.edit(Translation.DUPLICATE_TEXT.format(total, deleted, "Completed"), reply_markup=COMPLETED_BTN) 106 | await bot.stop() 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | # Jishu Developer 115 | # Don't Remove Credit 🥺 116 | # Telegram Channel @Madflix_Bots 117 | # Backup Channel @JishuBotz 118 | # Developer @JishuDeveloper -------------------------------------------------------------------------------- /plugins/utils.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import time as tm 11 | from database import db 12 | from .test import parse_buttons 13 | 14 | STATUS = {} 15 | 16 | class STS: 17 | def __init__(self, id): 18 | self.id = id 19 | self.data = STATUS 20 | 21 | def verify(self): 22 | return self.data.get(self.id) 23 | 24 | def store(self, From, to, skip, limit): 25 | self.data[self.id] = {"FROM": From, 'TO': to, 'total_files': 0, 'skip': skip, 'limit': limit, 26 | 'fetched': skip, 'filtered': 0, 'deleted': 0, 'duplicate': 0, 'total': limit, 'start': 0} 27 | self.get(full=True) 28 | return STS(self.id) 29 | 30 | def get(self, value=None, full=False): 31 | values = self.data.get(self.id) 32 | if not full: 33 | return values.get(value) 34 | for k, v in values.items(): 35 | setattr(self, k, v) 36 | return self 37 | 38 | def add(self, key=None, value=1, time=False): 39 | if time: 40 | return self.data[self.id].update({'start': tm.time()}) 41 | self.data[self.id].update({key: self.get(key) + value}) 42 | 43 | def divide(self, no, by): 44 | by = 1 if int(by) == 0 else by 45 | return int(no) / by 46 | 47 | async def get_data(self, user_id): 48 | bot = await db.get_bot(user_id) 49 | k, filters = self, await db.get_filters(user_id) 50 | size, configs = None, await db.get_configs(user_id) 51 | if configs['duplicate']: 52 | duplicate = [configs['db_uri'], self.TO] 53 | else: 54 | duplicate = False 55 | button = parse_buttons(configs['button'] if configs['button'] else '') 56 | if configs['file_size'] != 0: 57 | size = [configs['file_size'], configs['size_limit']] 58 | return bot, configs['caption'], configs['forward_tag'], {'chat_id': k.FROM, 'limit': k.limit, 'offset': k.skip, 'filters': filters, 59 | 'keywords': configs['keywords'], 'media_size': size, 'extensions': configs['extension'], 'skip_duplicate': duplicate}, configs['protect'], button 60 | 61 | 62 | def get_readable_time(seconds: int) -> str: 63 | result = "" 64 | (days, remainder) = divmod(seconds, 86400) 65 | days = int(days) 66 | if days != 0: 67 | result += f"{days}d" 68 | (hours, remainder) = divmod(remainder, 3600) 69 | hours = int(hours) 70 | if hours != 0: 71 | result += f"{hours}h" 72 | (minutes, seconds) = divmod(remainder, 60) 73 | minutes = int(minutes) 74 | if minutes != 0: 75 | result += f"{minutes}m" 76 | seconds = int(seconds) 77 | result += f"{seconds}s" 78 | return result 79 | 80 | 81 | 82 | # Jishu Developer 83 | # Don't Remove Credit 🥺 84 | # Telegram Channel @Madflix_Bots 85 | # Backup Channel @JishuBotz 86 | # Developer @JishuDeveloper 87 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrofork 2 | motor 3 | TgCrypto 4 | Dnspython 5 | aiohttp 6 | pytz -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | echo "Cloning Repo...." 2 | if [ -z $BRANCH ] 3 | then 4 | echo "Cloning main branch...." 5 | git clone https://github.com/JishuDeveloper/Ultra-Forward-Bot JishuDeveloper/Ultra-Forward-Bot 6 | else 7 | echo "Cloning $BRANCH branch...." 8 | git clone https://github.com/JishuDeveloper/Ultra-Forward-Bot -b $BRANCH /Ultra-Forward-Bot 9 | fi 10 | cd JishuDeveloper/Ultra-Forward-Bot 11 | pip3 install -U -r requirements.txt 12 | echo "Starting Bot...." 13 | python3 main.py 14 | -------------------------------------------------------------------------------- /translation.py: -------------------------------------------------------------------------------- 1 | # Jishu Developer 2 | # Don't Remove Credit 🥺 3 | # Telegram Channel @Madflix_Bots 4 | # Backup Channel @JishuBotz 5 | # Developer @JishuDeveloper 6 | 7 | 8 | 9 | 10 | import os 11 | from config import Config 12 | 13 | class Translation(object): 14 | START_TXT = """Hey {} 15 | 16 | ➻ I Am A Advanced Auto Forward Bot 17 | 18 | ➻ I Can Forward All Message From One Channel To Another Channel 19 | 20 | ➻ Click Help Button To Know More About Me 21 | 22 | Bot Is Made By @Madflix_Bots""" 23 | 24 | 25 | HELP_TXT = """🛠️ Help 26 | 27 | 📚 Available Commands : 28 | ⏣ __/start - Check I'm Alive__ 29 | ⏣ __/forward - Forward Messages__ 30 | ⏣ __/unequify - Delete Duplicate Messages In Channels__ 31 | ⏣ __/settings - Configure Your Settings__ 32 | ⏣ __/reset - Reset Your Settings__ 33 | 34 | 💢 Features : 35 | ► __Forward Message From Public Channel To Your Channel Without Admin Permission. If The Channel Is Private Need Admin Permission__ 36 | ► __Forward Message From Private Channel To Your Channel By Using Userbot(User Must Be Member In There)__ 37 | ► __Custom Caption__ 38 | ► __Custom Button__ 39 | ► __Support Restricted Chats__ 40 | ► __Skip Duplicate Messages__ 41 | ► __Filter Type Of Messages__ 42 | ► __Skip Messages Based On Extensions & Keywords & Size__ 43 | """ 44 | 45 | HOW_USE_TXT = """⚠️ Before Forwarding : 46 | 47 | ► __Add A Bot Or Userbot__ 48 | ► __Add Atleast One To Channel (Your Bot/Userbot Must Be Admin In There)__ 49 | ► __You Can Add Chats Or Bots By Using /settings__ 50 | ► __If The **From Channel** Is Private Your Userbot Must Be Member In There Or Your Bot Must Need Admin Permission In There Also__ 51 | ► __Then Use /forward To Forward Messages__""" 52 | 53 | ABOUT_TXT = """🤖 My Name : {} 54 | 📝 Language : Python 3 55 | 📚 Library : Pyrogram 2.0 56 | 🚀 Server : Heroku 57 | 📢 Channel : Madflix Botz 58 | 🧑‍💻 Developer : Jishu Developer 59 | 60 | ♻️ Bot Made By : @Madflix_Bots""" 61 | 62 | STATUS_TXT = """Bot Status 63 | 64 | 👱 Total Users : {} 65 | 66 | 🤖 Total Bots : {} 67 | 68 | 🔃 Forwardings : {} 69 | """ 70 | 71 | FROM_MSG = "Set Source Chat\n\nForward The Last Message Or Last Message Link Of Source Chat.\n/cancel - To Cancel This Process" 72 | TO_MSG = "Choose Target Chat\n\nChoose Your Target Chat From The Given Buttons.\n/cancel - To Cancel This Process" 73 | SKIP_MSG = "Set Message Skiping Number\n\nSkip The Message As Much As You Enter The Number And The Rest Of The Message Will Be Forwarded\nDefault Skip Number = 0\neg: You Enter 0 = 0 Message Skiped\nYou Enter 5 = 5 Message Skiped\n/cancel - To Cancel This Process" 74 | CANCEL = "Process Cancelled Succefully !" 75 | BOT_DETAILS = "📄 Bot Details\n\n➣ Name : {}\n➣ Bot ID : {}\n➣ Username : @{}" 76 | USER_DETAILS = "📄 UserBot Details\n\n➣ Name : {}\n➣ User ID : {}\n➣ Username : @{}" 77 | 78 | TEXT = """Forward Status 79 | 80 | 🕵 Fetch Message : {} 81 | 82 | ✅ Successfully Forward : {} 83 | 84 | 👥 Dublicate Message : {} 85 | 86 | 🗑 Deleted Message : {} 87 | 88 | 🪆 Skipped Message : {} 89 | 90 | 🔁 Filtered Message : {} 91 | 92 | 📊 Current Status : {} 93 | 94 | 🔥 Percentage : {} % 95 | 96 | {} 97 | """ 98 | 99 | TEXT1 = """Forwarded Status 100 | 101 | 🕵 Fetched Message : {} 102 | 103 | ✅ Successfully Forward : {} 104 | 105 | 👥 Dublicate Message : {} 106 | 107 | 🗑 Deleted Message : {} 108 | 109 | 🪆 Skipped : {} 110 | 111 | 📊 Stats : {} 112 | 113 | ⏳ Progress : {} 114 | 115 | ⏰ ETA : {} 116 | 117 | {}""" 118 | 119 | DUPLICATE_TEXT = """Unequify Status 120 | 121 | 🕵 Fetched Files : {} 122 | 123 | 👥 Dublicate Deleted : {} 124 | 125 | {} 126 | """ 127 | DOUBLE_CHECK = """Double Checking 128 | 129 | Before Forwarding The Messages Click The Yes Button Only After Checking The Following 130 | 131 | ★ Your Bot : [{botname}](t.me/{botuname}) 132 | ★ From Channel : {from_chat}<> 133 | ★ To Channel : {to_chat} 134 | ★ Skip Messages : {skip} 135 | 136 | ° [{botname}](t.me/{botuname}) Must Be Admin In Target Chat ({to_chat}) 137 | ° If The Source Chat Is Private Your Userbot Must Be Member Or Your Bot Must Be Admin In There Also 138 | 139 | If The Above Is Checked Then The Yes Button Can Be Clicked""" 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | # Jishu Developer 151 | # Don't Remove Credit 🥺 152 | # Telegram Channel @Madflix_Bots 153 | # Backup Channel @JishuBotz 154 | # Developer @JishuDeveloper --------------------------------------------------------------------------------