From 161ed14ed37a3f6b577c11387dcd967e888342e3 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:12:10 +0530 Subject: [PATCH 01/45] Created All Files --- Dockerfile | 12 + LICENSE | 678 +++++++++++++++++++++++------------------------ Procfile | 1 + bot.py | 97 +++++++ heroku.yml | 3 + logging.conf | 32 +++ render.yaml | 15 ++ requirements.txt | 5 + runtime.txt | 1 + script.py | 26 ++ start.sh | 12 + utils.py | 8 + vars.py | 21 ++ 13 files changed, 572 insertions(+), 339 deletions(-) create mode 100644 Dockerfile create mode 100644 Procfile create mode 100644 bot.py create mode 100644 heroku.yml create mode 100644 logging.conf create mode 100644 render.yaml create mode 100644 requirements.txt create mode 100644 runtime.txt create mode 100644 script.py create mode 100644 start.sh create mode 100644 utils.py create mode 100644 vars.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..160516a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.10.8-slim-buster + +RUN apt update && apt upgrade -y +RUN apt install git -y +COPY requirements.txt /requirements.txt + +RUN cd / +RUN pip3 install -U pip && pip3 install -U -r requirements.txt +RUN mkdir /ForwardBot +WORKDIR /ForwardBot +COPY start.sh /start.sh +CMD ["/bin/bash", "/start.sh"] \ No newline at end of file diff --git a/LICENSE b/LICENSE index d159169..89e08fb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,339 +1,339 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..5c1d509 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python3 bot.py diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..c4e8a86 --- /dev/null +++ b/bot.py @@ -0,0 +1,97 @@ +from pyrogram import Client, __version__ +from pyrogram.raw.all import layer +from datetime import date, datetime +from vars import SESSION, API_HASH, API_ID, BOT_TOKEN, LOG_CHANNEL, PORT +from typing import Union, Optional, AsyncGenerator +from script import scripts +from pyrogram import types +from utils import temp_utils +from aiohttp import web +from plugins import web_server +import logging +import pytz +import logging.config + +#Get logging configuration +logging.config.fileConfig('logging.conf') +logging.getLogger().setLevel(logging.INFO) +logging.getLogger("pyrogram").setLevel(logging.ERROR) + + +class Bot(Client): + + def __init__(self): + super().__init__( + name=SESSION, + api_id=API_ID, + api_hash=API_HASH, + bot_token=BOT_TOKEN, + workers=50, + plugins={"root": "plugins"}, + sleep_threshold=5, + ) + + async def start(self): + await super().start() + me = await self.get_me() + temp_utils.ME = me.id + temp_utils.USER_NAME = me.username + temp_utils.BOT_NAME = me.first_name + self.username = '@' + me.username + logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.") + tz = pytz.timezone('Asia/Kolkata') + today = date.today() + now = datetime.now(tz) + time = now.strftime("%H:%M:%S %p") + await self.send_message(chat_id=LOG_CHANNEL, text=scripts.RESTART_TXT.format(today, time)) + app = web.AppRunner(await web_server()) + await app.setup() + bind_address = "0.0.0.0" + await web.TCPSite(app, bind_address, PORT).start() + + async def stop(self, *args): + await super().stop() + logging.info("Bot stopped. Bye.") + + async def iter_messages( + self, + chat_id: Union[int, str], + limit: int, + offset: int = 0, + ) -> Optional[AsyncGenerator["types.Message", None]]: + """Iterate through a chat sequentially. + This convenience method does the same as repeatedly calling :meth:`~pyrogram.Client.get_messages` in a loop, thus saving + you from the hassle of setting up boilerplate code. It is useful for getting the whole chat messages with a + single call. + Parameters: + chat_id (``int`` | ``str``): + Unique identifier (int) or username (str) of the target chat. + For your personal cloud (Saved Messages) you can simply use "me" or "self". + For a contact that exists in your Telegram address book you can use his phone number (str). + + limit (``int``): + Identifier of the last message to be returned. + + offset (``int``, *optional*): + Identifier of the first message to be returned. + Defaults to 0. + Returns: + ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects. + Example: + .. code-block:: python + for message in app.iter_messages("pyrogram", 1, 15000): + print(message.text) + """ + current = offset + while True: + new_diff = min(200, limit - current) + if new_diff <= 0: + return + messages = await self.get_messages(chat_id, list(range(current, current+new_diff+1))) + for message in messages: + yield message + current += 1 + + +app = Bot() +app.run() \ No newline at end of file diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..96d0a77 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + worker: Dockerfile \ No newline at end of file diff --git a/logging.conf b/logging.conf new file mode 100644 index 0000000..a3bb28e --- /dev/null +++ b/logging.conf @@ -0,0 +1,32 @@ +[loggers] +keys=root + +[handlers] +keys=consoleHandler,fileHandler + +[formatters] +keys=consoleFormatter,fileFormatter + +[logger_root] +level=DEBUG +handlers=consoleHandler,fileHandler + +[handler_consoleHandler] +class=StreamHandler +level=INFO +formatter=consoleFormatter +args=(sys.stdout,) + +[handler_fileHandler] +class=FileHandler +level=ERROR +formatter=fileFormatter +args=('Logs.txt','w',) + +[formatter_consoleFormatter] +format=%(asctime)s - %(lineno)d - %(name)s - %(module)s - %(levelname)s - %(message)s +datefmt=%I:%M:%S %p + +[formatter_fileFormatter] +format=[%(asctime)s:%(name)s:%(lineno)d:%(levelname)s] %(message)s +datefmt=%m/%d/%Y %I:%M:%S %p \ No newline at end of file diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..cff376c --- /dev/null +++ b/render.yaml @@ -0,0 +1,15 @@ +services: + # A Docker web service + - type: web + name: File-Forward-Bot + env: python + startCommand: python3 bot.py + buildCommand: pip3 install -U -r requirements.txt + repo: https://github.com/Joelkb/File-Forward-Bot.git # optional + region: oregon # optional (defaults to oregon) + plan: free # optional (defaults to starter) + branch: web # optional (defaults to master) + numInstances: 1 # optional (defaults to 1) + healthCheckPath: / + +#End of yaml diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..842cd19 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +pyrogram +tgcrypto +pytz +aiohttp +datetime \ No newline at end of file diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..684075a --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.10.9 diff --git a/script.py b/script.py new file mode 100644 index 0000000..71144f7 --- /dev/null +++ b/script.py @@ -0,0 +1,26 @@ +class scripts(object): + RESTART_TXT = """ +Bᴏᴛ Rᴇsᴛᴀʀᴛᴇᴅ ! + +📅 Dᴀᴛᴇ : {} +⏰ Tɪᴍᴇ : {} +🌐 Tɪᴍᴇᴢᴏɴᴇ : Asia/Kolkata +🛠️ Bᴜɪʟᴅ Sᴛᴀᴛᴜs: v2.7.1 [ Sᴛᴀʙʟᴇ ]""" + + START_TXT = """ +Hᴇʟʟᴏ {}, +Mʏ Nᴀᴍᴇ Is {}, I'm Just A Private Forward Bot Made By Jᴏᴇʟ ᠰ TɢX.""" + + ABOUT_TXT = """ +✯ Mʏ Nᴀᴍᴇ: {} +✯ Cʀᴇᴀᴛᴏʀ: Jᴏᴇʟ ᠰ TɢX +✯ Lɪʙʀᴀʀʏ: Pʏʀᴏɢʀᴀᴍ +✯ Lᴀɴɢᴜᴀɢᴇ: Pʏᴛʜᴏɴ 3 +✯ Bᴜɪʟᴅ Sᴛᴀᴛᴜs: v1.0.1 [ Sᴛᴀʙʟᴇ ]""" + + SOURCE_TXT = """ +ɴᴏᴛᴇ: +- ᴛʜɪꜱ ʙᴏᴛ ɪꜱ ᴀɴ ᴏᴘᴇɴ ꜱᴏᴜʀᴄᴇ ᴘʀᴏᴊᴇᴄᴛ. +- ꜱᴏᴜʀᴄᴇ - ʜᴇʀᴇ +Dᴇᴠᴇʟᴏᴘᴇʀ: +- Jᴏᴇʟ ᠰ TɢX""" \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..233cc33 --- /dev/null +++ b/start.sh @@ -0,0 +1,12 @@ +if [ -z $UPSTREAM_REPO ] +then + echo "Cloning main Repository" + git clone https://github.com/Joelkb/File-Forward-Bot.git /Forward +else + echo "Cloning Custom Repo from $UPSTREAM_REPO " + git clone $UPSTREAM_REPO /Forward +fi +cd /Forward +pip3 install -U -r requirements.txt +echo "Starting DQ-The-File-Donor...." +python3 bot.py diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..cf0a03b --- /dev/null +++ b/utils.py @@ -0,0 +1,8 @@ +import os + +class temp_utils(object): + USER_NAME = None + BOT_NAME = None + ME = None + CURRENT = int(os.environ.get("SKIP", 0)) + CANCEL = False \ No newline at end of file diff --git a/vars.py b/vars.py new file mode 100644 index 0000000..e4997cf --- /dev/null +++ b/vars.py @@ -0,0 +1,21 @@ +from os import environ +import re + +id_pattern = re.compile(r'^.\d+$') +def is_enabled(value, default): + if value.lower() in ["true", "yes", "1", "enable", "y"]: + return True + elif value.lower() in ["false", "no", "0", "disable", "n"]: + return False + else: + return default + +SESSION = environ.get("SESSION", "forward bot") +API_ID = int(environ.get("API_ID", "")) +API_HASH = environ.get("API_HASH", "") +BOT_TOKEN = environ.get("BOT_TOKEN", "") +LOG_CHANNEL = int(environ.get("LOG_CHANNEL", "")) +PORT = int(environ.get("PORT", "8080")) +ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()] +TARGET_DB = int(environ.get("TARGET_DB", "")) +UPSTREAM_REPO = environ.get("UPSTREAM_REPO", "https://github.com/Joelkb/File-Forward-Bot") \ No newline at end of file From 309e0573a3492a15a877bae3e825e1448c717e45 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:14:54 +0530 Subject: [PATCH 02/45] Create __init__.py --- plugins/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plugins/__init__.py diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 0000000..280f615 --- /dev/null +++ b/plugins/__init__.py @@ -0,0 +1,8 @@ +from aiohttp import web +from .route import routes + + +async def web_server(): + web_app = web.Application(client_max_size=30000000) + web_app.add_routes(routes) + return web_app From 3984b8870b87fb26c771ffd151a37f2c504260ee Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:15:17 +0530 Subject: [PATCH 03/45] Add files via upload --- plugins/callbacks.py | 41 +++++++++++++++++++ plugins/commands.py | 93 ++++++++++++++++++++++++++++++++++++++++++++ plugins/route.py | 7 ++++ 3 files changed, 141 insertions(+) create mode 100644 plugins/callbacks.py create mode 100644 plugins/commands.py create mode 100644 plugins/route.py diff --git a/plugins/callbacks.py b/plugins/callbacks.py new file mode 100644 index 0000000..f8e8bf6 --- /dev/null +++ b/plugins/callbacks.py @@ -0,0 +1,41 @@ +from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup +from pyrogram import Client +from script import scripts +from utils import temp_utils + +@Client.on_callback_query() +async def query_handler(bot: Client, query: CallbackQuery): + if query.data == "close": + await query.message.reply_to_message.delete() + await query.message.delete() + elif query.data == "about": + btn = [[ + InlineKeyboardButton("Go Back", callback_data="home"), + InlineKeyboardButton("Close", callback_data="close") + ]] + await query.message.edit_text( + text=scripts.ABOUT_TXT.format(temp_utils.BOT_NAME), + reply_markup=InlineKeyboardMarkup(btn) + ) + elif query.data == "home": + btn = [[ + InlineKeyboardButton("About", callback_data="about"), + InlineKeyboardButton("Souce Code", callback_data="source") + ],[ + InlineKeyboardButton("Close", callback_data="close") + ]] + await query.message.edit_text( + text=scripts.START_TXT.format(query.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), + reply_markup=InlineKeyboardMarkup(btn) + ) + elif query.data == "source": + btn = [[ + InlineKeyboardButton("Go Back", callback_data="home"), + InlineKeyboardButton("Close", callback_data="close") + ]] + await query.message.edit_text( + text=scripts.SOURCE_TXT, + reply_markup=InlineKeyboardMarkup(btn) + ) + elif query.data == "cancel_forward": + temp_utils.CANCEL = True \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py new file mode 100644 index 0000000..65ab04a --- /dev/null +++ b/plugins/commands.py @@ -0,0 +1,93 @@ +from utils import temp_utils +from pyrogram import Client, filters +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified +from pyrogram.errors import FloodWait +from script import scripts +from vars import ADMINS, TARGET_DB +import asyncio +import logging +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) +lock = asyncio.Lock() + +@Client.on_message(filters.command("start")) +async def start_message(bot, message): + btn = [[ + InlineKeyboardButton("About", callback_data="about"), + InlineKeyboardButton("Souce Code", callback_data="source") + ],[ + InlineKeyboardButton("Close", callback_data="close") + ]] + await message.reply_text( + text=scripts.START_TXT.format(message.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), + reply_markup=InlineKeyboardMarkup(btn) + ) + +@Client.on_message(filters.command("forward") & filters.user(ADMINS)) +async def forward_cmd(bot, message): + cmd = message.text + if lock.locked(): + return await message.reply_text('Wait until previous process complete.') + try: + cmd_name, source_chat_id, last_msg_id = cmd.split(" ") + except: + return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example:\n/forward -1001xxxxxx 93793") + try: + await bot.get_chat(int(source_chat_id)) + except ChannelInvalid: + return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') + except (UsernameInvalid, UsernameNotModified): + return await message.reply('Invalid Link specified.') + except Exception as e: + logger.exception(e) + return await message.reply(f'Errors - {e}') + try: + k = await bot.get_messages(int(source_chat_id), int(last_msg_id)) + except: + return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') + if k.empty: + return await message.reply('This may be group and iam not a admin of the group.') + btn = [[ + InlineKeyboardButton("CANCEL", callback_data="cancel_forward") + ]] + active_msg = await message.reply_text( + text="Starting Forward Process...", + reply_markup = InlineKeyboardMarkup(btn) + ) + forwarded = 0 + empty = 0 + left = int(last_msg_id)-int(forwarded) + async with lock: + try: + current = temp_utils.CURRENT + temp_utils.CANCEL = False + async for msg in bot.iter_messages(int(source_chat_id), int(last_msg_id), int(temp_utils.CURRENT)): + if temp_utils.CANCEL: + await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") + break + current += 1 + if current % 20 == 0: + btn = [[ + InlineKeyboardButton("CANCEL", callback_data="cancel_forward") + ]] + await active_msg.edit( + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}", + reply_markup=InlineKeyboardMarkup(btn) + ) + if message.empty: + empty+=1 + continue + try: + await msg.copy(chat_id=int(TARGET_DB)) + forwarded+=1 + except FloodWait as e: + await asyncio.sleep(e.x) + await msg.copy(chat_id=int(TARGET_DB)) + forwarded+=1 + continue + except Exception as e: + logger.exception(e) + await active_msg.edit(f'Error: {e}') + else: + await active_msg.edit(f"Successfully Completed Forward Process !\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") \ No newline at end of file diff --git a/plugins/route.py b/plugins/route.py new file mode 100644 index 0000000..9dc87d3 --- /dev/null +++ b/plugins/route.py @@ -0,0 +1,7 @@ +from aiohttp import web + +routes = web.RouteTableDef() + +@routes.get("/", allow_head=True) +async def root_route_handler(request): + return web.json_response("DQTheFileDonor") From ba8dd17adb89343a99a87ad66916cd62f9dbfbee Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:17:00 +0530 Subject: [PATCH 04/45] Added deploy to render button --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fdc4dae..7916c1a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ # File-Forward-Bot -File-Forward-Bot +
Deploy To Render +
+ +Use these commands: +
+
+• Build Command: pip3 install -U -r requirements.txt +
+
+• Start Command: python3 bot.py +
+
+Go to https://uptimerobot.com/ and add a monitor to keep your bot alive. +
+
+Use these settings when adding a monitor:
+
+
+render template +
+
+Click on the below button to deploy directly to render ↓ +
+
+ +Deploy to Render + +
From efd135f05fd0d87bfef27e9c0c052e91565c4f6d Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:31:39 +0530 Subject: [PATCH 05/45] Added Logging --- plugins/callbacks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/callbacks.py b/plugins/callbacks.py index f8e8bf6..ac0669b 100644 --- a/plugins/callbacks.py +++ b/plugins/callbacks.py @@ -2,6 +2,10 @@ from pyrogram import Client from script import scripts from utils import temp_utils +import logging + +logger = logging.getLogger(__name__) +logger.setLevel(logging.ERROR) @Client.on_callback_query() async def query_handler(bot: Client, query: CallbackQuery): @@ -38,4 +42,4 @@ async def query_handler(bot: Client, query: CallbackQuery): reply_markup=InlineKeyboardMarkup(btn) ) elif query.data == "cancel_forward": - temp_utils.CANCEL = True \ No newline at end of file + temp_utils.CANCEL = True From 4923a34ca9f3a8e1243d6e854803db39c791b269 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:33:31 +0530 Subject: [PATCH 06/45] Added /logs --- plugins/commands.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index 65ab04a..6ac3589 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -90,4 +90,12 @@ async def forward_cmd(bot, message): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - await active_msg.edit(f"Successfully Completed Forward Process !\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") \ No newline at end of file + await active_msg.edit(f"Successfully Completed Forward Process !\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") + +@Client.on_message(filters.command('logs') & filters.user(ADMINS)) +async def log_file(bot, message): + """Send log file""" + try: + await message.reply_document('Logs.txt') + except Exception as e: + await message.reply(str(e)) From 3cc456dc2c966557083e54b82b3407003f40c20d Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:37:22 +0530 Subject: [PATCH 07/45] Disable --- plugins/callbacks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/callbacks.py b/plugins/callbacks.py index ac0669b..68e2e17 100644 --- a/plugins/callbacks.py +++ b/plugins/callbacks.py @@ -19,6 +19,7 @@ async def query_handler(bot: Client, query: CallbackQuery): ]] await query.message.edit_text( text=scripts.ABOUT_TXT.format(temp_utils.BOT_NAME), + disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(btn) ) elif query.data == "home": @@ -30,6 +31,7 @@ async def query_handler(bot: Client, query: CallbackQuery): ]] await query.message.edit_text( text=scripts.START_TXT.format(query.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), + disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(btn) ) elif query.data == "source": @@ -39,6 +41,7 @@ async def query_handler(bot: Client, query: CallbackQuery): ]] await query.message.edit_text( text=scripts.SOURCE_TXT, + disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(btn) ) elif query.data == "cancel_forward": From 63ae3e9d665e0e3371d266a083e4fbc15c815813 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:42:51 +0530 Subject: [PATCH 08/45] Fix --- plugins/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index 6ac3589..cd66c01 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -34,7 +34,7 @@ async def forward_cmd(bot, message): except: return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example:\n/forward -1001xxxxxx 93793") try: - await bot.get_chat(int(source_chat_id)) + await bot.get_chat(chat_id=int(source_chat_id)) except ChannelInvalid: return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') except (UsernameInvalid, UsernameNotModified): From 684820485c1019af5c72925f753c5b8fca81bea2 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:51:55 +0530 Subject: [PATCH 09/45] Update commands.py --- plugins/commands.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index cd66c01..b260d12 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -33,15 +33,7 @@ async def forward_cmd(bot, message): cmd_name, source_chat_id, last_msg_id = cmd.split(" ") except: return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example:\n/forward -1001xxxxxx 93793") - try: - await bot.get_chat(chat_id=int(source_chat_id)) - except ChannelInvalid: - return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') - except (UsernameInvalid, UsernameNotModified): - return await message.reply('Invalid Link specified.') - except Exception as e: - logger.exception(e) - return await message.reply(f'Errors - {e}') + try: k = await bot.get_messages(int(source_chat_id), int(last_msg_id)) except: @@ -57,7 +49,7 @@ async def forward_cmd(bot, message): ) forwarded = 0 empty = 0 - left = int(last_msg_id)-int(forwarded) + left = 0 async with lock: try: current = temp_utils.CURRENT @@ -66,6 +58,7 @@ async def forward_cmd(bot, message): if temp_utils.CANCEL: await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") break + left = int(last_msg_id)-int(forwarded) current += 1 if current % 20 == 0: btn = [[ From cbd82b1851c08e16b2f69268b851095cb706a0b8 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 17:56:26 +0530 Subject: [PATCH 10/45] Update commands.py --- plugins/commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index b260d12..3055ad7 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -36,7 +36,8 @@ async def forward_cmd(bot, message): try: k = await bot.get_messages(int(source_chat_id), int(last_msg_id)) - except: + except Exception as e: + logger.exception(e) return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') if k.empty: return await message.reply('This may be group and iam not a admin of the group.') From 3c6cc6a398510d328af66cea86a136e334f98ff3 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 18:02:18 +0530 Subject: [PATCH 11/45] Update commands.py --- plugins/commands.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 3055ad7..ad9e413 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -33,11 +33,18 @@ async def forward_cmd(bot, message): cmd_name, source_chat_id, last_msg_id = cmd.split(" ") except: return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example:\n/forward -1001xxxxxx 93793") - try: - k = await bot.get_messages(int(source_chat_id), int(last_msg_id)) + await bot.get_chat(chat_id=int(source_chat_id)) + except ChannelInvalid: + return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') + except (UsernameInvalid, UsernameNotModified): + return await message.reply('Invalid Link specified.') except Exception as e: logger.exception(e) + return await message.reply(f'Errors - {e}') + try: + k = await bot.get_messages(int(source_chat_id), int(last_msg_id)) + except: return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') if k.empty: return await message.reply('This may be group and iam not a admin of the group.') From 8fb1c9f5754be661cc7cad6d170ab1a1ddc9c87e Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 18:21:44 +0530 Subject: [PATCH 12/45] Update commands.py --- plugins/commands.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index ad9e413..b3fd811 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -33,21 +33,7 @@ async def forward_cmd(bot, message): cmd_name, source_chat_id, last_msg_id = cmd.split(" ") except: return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example:\n/forward -1001xxxxxx 93793") - try: - await bot.get_chat(chat_id=int(source_chat_id)) - except ChannelInvalid: - return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') - except (UsernameInvalid, UsernameNotModified): - return await message.reply('Invalid Link specified.') - except Exception as e: - logger.exception(e) - return await message.reply(f'Errors - {e}') - try: - k = await bot.get_messages(int(source_chat_id), int(last_msg_id)) - except: - return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') - if k.empty: - return await message.reply('This may be group and iam not a admin of the group.') + btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] From 705c6b275681d34733d4c8d81ca39d2e1a04b1b1 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 18:35:29 +0530 Subject: [PATCH 13/45] Update commands.py --- plugins/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index b3fd811..1277b45 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -48,7 +48,7 @@ async def forward_cmd(bot, message): try: current = temp_utils.CURRENT temp_utils.CANCEL = False - async for msg in bot.iter_messages(int(source_chat_id), int(last_msg_id), int(temp_utils.CURRENT)): + async for msg in bot.iter_messages(source_chat_id, last_msg_id, temp_utils.CURRENT): if temp_utils.CANCEL: await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") break From 2632cf042013a5291df170195feb5a336429aec6 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 18:43:31 +0530 Subject: [PATCH 14/45] Update commands.py --- plugins/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index 1277b45..abcf477 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -48,7 +48,7 @@ async def forward_cmd(bot, message): try: current = temp_utils.CURRENT temp_utils.CANCEL = False - async for msg in bot.iter_messages(source_chat_id, last_msg_id, temp_utils.CURRENT): + async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") break From fc8b5df528ca89f829764bab283f4f5c1c31f94b Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 19:20:08 +0530 Subject: [PATCH 15/45] Fixed Bugs I guess --- plugins/commands.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index abcf477..f6a62a3 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -21,6 +21,7 @@ async def start_message(bot, message): ]] await message.reply_text( text=scripts.START_TXT.format(message.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), + disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(btn) ) @@ -46,6 +47,13 @@ async def forward_cmd(bot, message): left = 0 async with lock: try: + btn = [[ + InlineKeyboardButton("CANCEL", callback_data="cancel_forward") + ]] + await active_msg.edit( + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}", + reply_markup=InlineKeyboardMarkup(btn) + ) current = temp_utils.CURRENT temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): @@ -54,12 +62,17 @@ async def forward_cmd(bot, message): break left = int(last_msg_id)-int(forwarded) current += 1 - if current % 20 == 0: + if current % 5 == 0: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}", + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nSleeping for 5 seconds to avoid floodwait...", + reply_markup=InlineKeyboardMarkup(btn) + ) + await asyncio.sleep(5) + await active_msg.edit( + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nResuming file forward...", reply_markup=InlineKeyboardMarkup(btn) ) if message.empty: @@ -69,7 +82,14 @@ async def forward_cmd(bot, message): await msg.copy(chat_id=int(TARGET_DB)) forwarded+=1 except FloodWait as e: - await asyncio.sleep(e.x) + btn = [[ + InlineKeyboardButton("CANCEL", callback_data="cancel_forward") + ]] + await active_msg.edit( + text=f"Got FloodWait.\n\nWaiting for {e.delay} seconds.", + reply_markup=InlineKeyboardMarkup(btn) + ) + await asyncio.sleep(e.delay) await msg.copy(chat_id=int(TARGET_DB)) forwarded+=1 continue From e14ca05549b75e4ae0131881fb967184f62a93df Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 19:22:56 +0530 Subject: [PATCH 16/45] Update commands.py --- plugins/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index f6a62a3..649e592 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -33,7 +33,7 @@ async def forward_cmd(bot, message): try: cmd_name, source_chat_id, last_msg_id = cmd.split(" ") except: - return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example:\n/forward -1001xxxxxx 93793") + return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example if channel is private:\n/forward -1001xxxxxx 93793\n(Note that the bot should be admin in the channel if private)\n\nFor Example if channel is public:\n/forward @username 63672\n(No need the bot to be admin in channel if public)") btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") From b257212fa2449b1638f2e7a4d9253e8cf8a9e6c5 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 19:50:10 +0530 Subject: [PATCH 17/45] Fix floodwait --- plugins/commands.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 649e592..3c67c48 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -62,15 +62,15 @@ async def forward_cmd(bot, message): break left = int(last_msg_id)-int(forwarded) current += 1 - if current % 5 == 0: + if current % 20 == 0: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nSleeping for 5 seconds to avoid floodwait...", + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) ) - await asyncio.sleep(5) + await asyncio.sleep(30) await active_msg.edit( text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nResuming file forward...", reply_markup=InlineKeyboardMarkup(btn) @@ -81,15 +81,16 @@ async def forward_cmd(bot, message): try: await msg.copy(chat_id=int(TARGET_DB)) forwarded+=1 + await asyncio.sleep(1) except FloodWait as e: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Got FloodWait.\n\nWaiting for {e.delay} seconds.", + text=f"Got FloodWait.\n\nWaiting for {e.value} seconds.", reply_markup=InlineKeyboardMarkup(btn) ) - await asyncio.sleep(e.delay) + await asyncio.sleep(e.value) await msg.copy(chat_id=int(TARGET_DB)) forwarded+=1 continue From 24972b0f327e1dbb9fdd11a8c421eef9257029fd Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 19:50:58 +0530 Subject: [PATCH 18/45] Update callbacks.py --- plugins/callbacks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/callbacks.py b/plugins/callbacks.py index 68e2e17..1f2c23d 100644 --- a/plugins/callbacks.py +++ b/plugins/callbacks.py @@ -10,7 +10,6 @@ @Client.on_callback_query() async def query_handler(bot: Client, query: CallbackQuery): if query.data == "close": - await query.message.reply_to_message.delete() await query.message.delete() elif query.data == "about": btn = [[ From d9e89e483b2d909c8078c8c51e3433b6490aeb14 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Mon, 8 May 2023 23:44:00 +0530 Subject: [PATCH 19/45] Added Skip Command for resuming stopped process Added Skip Command for resuming stopped process --- plugins/commands.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/commands.py b/plugins/commands.py index 3c67c48..6656d09 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -107,3 +107,17 @@ async def log_file(bot, message): await message.reply_document('Logs.txt') except Exception as e: await message.reply(str(e)) + + +@Client.on_message(filters.command('setskip') & filters.user(ADMINS)) +async def skip_msgs(bot, message): + if ' ' in message.text: + _, skip = message.text.split(" ") + try: + skip = int(skip) + except: + return await message.reply("Skip number should be an integer.") + await message.reply(f"Successfully set SKIP number as {skip}") + temp_utils.CURRENT = int(skip) + else: + await message.reply("Give me a skip number") From 17cc4419eb01a36ccaf4642d13eb38a610f3e607 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 13:29:16 +0530 Subject: [PATCH 20/45] Some Improvements Some Improvements --- plugins/callbacks.py | 17 ++++++- plugins/commands.py | 116 ++++++++++++++++++++++++++++++------------- script.py | 10 +++- 3 files changed, 106 insertions(+), 37 deletions(-) diff --git a/plugins/callbacks.py b/plugins/callbacks.py index 1f2c23d..f0fc8ab 100644 --- a/plugins/callbacks.py +++ b/plugins/callbacks.py @@ -3,6 +3,7 @@ from script import scripts from utils import temp_utils import logging +from commands import start_forward logger = logging.getLogger(__name__) logger.setLevel(logging.ERROR) @@ -26,7 +27,8 @@ async def query_handler(bot: Client, query: CallbackQuery): InlineKeyboardButton("About", callback_data="about"), InlineKeyboardButton("Souce Code", callback_data="source") ],[ - InlineKeyboardButton("Close", callback_data="close") + InlineKeyboardButton("Close", callback_data="close"), + InlineKeyboardButton("Help", callback_data="help") ]] await query.message.edit_text( text=scripts.START_TXT.format(query.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), @@ -45,3 +47,16 @@ async def query_handler(bot: Client, query: CallbackQuery): ) elif query.data == "cancel_forward": temp_utils.CANCEL = True + elif query.data == "help": + btn = [[ + InlineKeyboardButton("Go Back", callback_data="home"), + InlineKeyboardButton("Close", callback_data="close") + ]] + await query.message.edit_text( + text=scripts.HELP_TXT.format(temp_utils.BOT_NAME), + disable_web_page_preview=True, + reply_markup=InlineKeyboardMarkup(btn) + ) + elif query.data.startswith("forward"): + ident, source_chat_id, last_msg_id = query.data.split("#") + await start_forward(bot, query.from_user.id, source_chat_id, last_msg_id) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py index 6656d09..67cd277 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -1,11 +1,12 @@ from utils import temp_utils -from pyrogram import Client, filters +from pyrogram import Client, filters, enums from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified from pyrogram.errors import FloodWait from script import scripts from vars import ADMINS, TARGET_DB import asyncio +import re import logging logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) @@ -25,25 +26,86 @@ async def start_message(bot, message): reply_markup=InlineKeyboardMarkup(btn) ) -@Client.on_message(filters.command("forward") & filters.user(ADMINS)) +@Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming) async def forward_cmd(bot, message): - cmd = message.text + if message.from_user.id not in ADMINS: return # admin only + if message.text: + regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") + match = regex.match(message.text) + if not match: + return await message.reply('Invalid link') + source_chat_id = match.group(4) + last_msg_id = int(match.group(5)) + if source_chat_id.isnumeric(): + source_chat_id = int(("-100" + source_chat_id)) + elif message.forward_from_chat.type == enums.ChatType.CHANNEL: + last_msg_id = message.forward_from_message_id + source_chat_id = message.forward_from_chat.username or message.forward_from_chat.id + else: + return + try: + await bot.get_chat(source_chat_id) + except ChannelInvalid: + return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') + except (UsernameInvalid, UsernameNotModified): + return await message.reply('Invalid Link specified.') + except Exception as e: + logger.exception(e) + return await message.reply(f'Errors - {e}') + try: + k = await bot.get_messages(source_chat_id, last_msg_id) + except: + return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') + if k.empty: + return await message.reply('This may be group and iam not a admin of the group.') if lock.locked(): return await message.reply_text('Wait until previous process complete.') + button = [[ + InlineKeyboardButton("YES", callback_data=f"forward#{source_chat_id}#{last_msg_id}"), + InlineKeyboardButton("NO", callback_data="close") + ]] + await message.reply_text( + text="Do you want to start forwarding ?", + reply_markup=InlineKeyboardMarkup(button) + ) + + +@Client.on_message(filters.command('logs') & filters.user(ADMINS)) +async def log_file(bot, message): + """Send log file""" try: - cmd_name, source_chat_id, last_msg_id = cmd.split(" ") - except: - return await message.reply_text("Give me the source chat ID and last message ID of that chat along with this command !\n\nFor Example if channel is private:\n/forward -1001xxxxxx 93793\n(Note that the bot should be admin in the channel if private)\n\nFor Example if channel is public:\n/forward @username 63672\n(No need the bot to be admin in channel if public)") + await message.reply_document('Logs.txt') + except Exception as e: + await message.reply(str(e)) + + +@Client.on_message(filters.command('setskip') & filters.user(ADMINS)) +async def skip_msgs(bot, message): + if ' ' in message.text: + _, skip = message.text.split(" ") + try: + skip = int(skip) + except: + return await message.reply("Skip number should be an integer.") + await message.reply(f"Successfully set SKIP number as {skip}") + temp_utils.CURRENT = int(skip) + else: + await message.reply("Give me a skip number") + +async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] - active_msg = await message.reply_text( + active_msg = await bot.send_message( + chat_id=int(userid), text="Starting Forward Process...", reply_markup = InlineKeyboardMarkup(btn) ) forwarded = 0 empty = 0 + notmedia = 0 + unsupported = 0 left = 0 async with lock: try: @@ -51,14 +113,14 @@ async def forward_cmd(bot, message): InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}", + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", reply_markup=InlineKeyboardMarkup(btn) ) current = temp_utils.CURRENT temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: - await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") + await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") break left = int(last_msg_id)-int(forwarded) current += 1 @@ -67,17 +129,23 @@ async def forward_cmd(bot, message): InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) ) await asyncio.sleep(30) await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}\n\nResuming file forward...", + text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nResuming file forward...", reply_markup=InlineKeyboardMarkup(btn) ) - if message.empty: + if msg.empty: empty+=1 continue + elif not msg.media: + no_media += 1 + continue + elif msg.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: + unsupported += 1 + continue try: await msg.copy(chat_id=int(TARGET_DB)) forwarded+=1 @@ -98,26 +166,4 @@ async def forward_cmd(bot, message): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - await active_msg.edit(f"Successfully Completed Forward Process !\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nMessages Left: {left}") - -@Client.on_message(filters.command('logs') & filters.user(ADMINS)) -async def log_file(bot, message): - """Send log file""" - try: - await message.reply_document('Logs.txt') - except Exception as e: - await message.reply(str(e)) - - -@Client.on_message(filters.command('setskip') & filters.user(ADMINS)) -async def skip_msgs(bot, message): - if ' ' in message.text: - _, skip = message.text.split(" ") - try: - skip = int(skip) - except: - return await message.reply("Skip number should be an integer.") - await message.reply(f"Successfully set SKIP number as {skip}") - temp_utils.CURRENT = int(skip) - else: - await message.reply("Give me a skip number") + await active_msg.edit(f"Successfully Completed Forward Process !\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") \ No newline at end of file diff --git a/script.py b/script.py index 71144f7..dd4d193 100644 --- a/script.py +++ b/script.py @@ -23,4 +23,12 @@ class scripts(object): - ᴛʜɪꜱ ʙᴏᴛ ɪꜱ ᴀɴ ᴏᴘᴇɴ ꜱᴏᴜʀᴄᴇ ᴘʀᴏᴊᴇᴄᴛ. - ꜱᴏᴜʀᴄᴇ - ʜᴇʀᴇ Dᴇᴠᴇʟᴏᴘᴇʀ: -- Jᴏᴇʟ ᠰ TɢX""" \ No newline at end of file +- Jᴏᴇʟ ᠰ TɢX""" + + HELP_TXT = """ +Here are all my commands: +/start - To check if I'm alive or not +/logs - To check my logs [Admin Only] +/setskip - To skip a number of messages [Admin Only] + +This bot might be available to all in the future.""" \ No newline at end of file From 88efe8b9ddf6d8a8d41c8fd641ef9564a7c9d0e5 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 13:32:42 +0530 Subject: [PATCH 21/45] Fixes --- plugins/callbacks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/callbacks.py b/plugins/callbacks.py index f0fc8ab..cbf92ef 100644 --- a/plugins/callbacks.py +++ b/plugins/callbacks.py @@ -3,7 +3,7 @@ from script import scripts from utils import temp_utils import logging -from commands import start_forward +from .commands import start_forward logger = logging.getLogger(__name__) logger.setLevel(logging.ERROR) @@ -59,4 +59,4 @@ async def query_handler(bot: Client, query: CallbackQuery): ) elif query.data.startswith("forward"): ident, source_chat_id, last_msg_id = query.data.split("#") - await start_forward(bot, query.from_user.id, source_chat_id, last_msg_id) \ No newline at end of file + await start_forward(bot, query.from_user.id, source_chat_id, last_msg_id) From 004d3d4866a18db6f68bb72d90b3a8449424e762 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 13:43:28 +0530 Subject: [PATCH 22/45] Few imporvements --- plugins/callbacks.py | 1 + plugins/commands.py | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/plugins/callbacks.py b/plugins/callbacks.py index f0fc8ab..fdb27a8 100644 --- a/plugins/callbacks.py +++ b/plugins/callbacks.py @@ -59,4 +59,5 @@ async def query_handler(bot: Client, query: CallbackQuery): ) elif query.data.startswith("forward"): ident, source_chat_id, last_msg_id = query.data.split("#") + await query.message.delete() await start_forward(bot, query.from_user.id, source_chat_id, last_msg_id) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py index 67cd277..ec08075 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -15,11 +15,12 @@ @Client.on_message(filters.command("start")) async def start_message(bot, message): btn = [[ - InlineKeyboardButton("About", callback_data="about"), - InlineKeyboardButton("Souce Code", callback_data="source") - ],[ - InlineKeyboardButton("Close", callback_data="close") - ]] + InlineKeyboardButton("About", callback_data="about"), + InlineKeyboardButton("Souce Code", callback_data="source") + ],[ + InlineKeyboardButton("Close", callback_data="close"), + InlineKeyboardButton("Help", callback_data="help") + ]] await message.reply_text( text=scripts.START_TXT.format(message.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), disable_web_page_preview=True, @@ -61,7 +62,8 @@ async def forward_cmd(bot, message): if lock.locked(): return await message.reply_text('Wait until previous process complete.') button = [[ - InlineKeyboardButton("YES", callback_data=f"forward#{source_chat_id}#{last_msg_id}"), + InlineKeyboardButton("YES", callback_data=f"forward#{source_chat_id}#{last_msg_id}") + ],[ InlineKeyboardButton("NO", callback_data="close") ]] await message.reply_text( @@ -102,6 +104,8 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): text="Starting Forward Process...", reply_markup = InlineKeyboardMarkup(btn) ) + skipped = 0 + Total = skipped forwarded = 0 empty = 0 notmedia = 0 @@ -113,14 +117,14 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", + text=f"Forwarding on progress...\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", reply_markup=InlineKeyboardMarkup(btn) ) current = temp_utils.CURRENT temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: - await active_msg.edit(f"Successfully Cancelled!\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") + await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") break left = int(last_msg_id)-int(forwarded) current += 1 @@ -129,12 +133,12 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", + text=f"Forwarding on progress...\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) ) await asyncio.sleep(30) await active_msg.edit( - text=f"Forwarding on progress...\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nResuming file forward...", + text=f"Forwarding on progress...\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nResuming file forward...", reply_markup=InlineKeyboardMarkup(btn) ) if msg.empty: @@ -166,4 +170,4 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - await active_msg.edit(f"Successfully Completed Forward Process !\n\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") \ No newline at end of file + await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") \ No newline at end of file From abc0d76c2f3f539f029c5c86682b97381ab5a6e5 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 14:05:47 +0530 Subject: [PATCH 23/45] Fixes --- plugins/commands.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index ec08075..2292958 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -104,8 +104,8 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): text="Starting Forward Process...", reply_markup = InlineKeyboardMarkup(btn) ) - skipped = 0 - Total = skipped + skipped = int(temp_utils.CURRENT) + total = 0 forwarded = 0 empty = 0 notmedia = 0 @@ -117,28 +117,29 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", reply_markup=InlineKeyboardMarkup(btn) ) current = temp_utils.CURRENT + total = current temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: - await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") + await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") break - left = int(last_msg_id)-int(forwarded) + left = int(last_msg_id)-int(total) current += 1 if current % 20 == 0: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) ) await asyncio.sleep(30) await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nResuming file forward...", + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nResuming file forward...", reply_markup=InlineKeyboardMarkup(btn) ) if msg.empty: @@ -170,4 +171,4 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {Total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") \ No newline at end of file + await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") \ No newline at end of file From 64f07cc77aabf241804a776e1a18c914885b771d Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 14:25:07 +0530 Subject: [PATCH 24/45] Fix --- plugins/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index 2292958..231d851 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -121,13 +121,13 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): reply_markup=InlineKeyboardMarkup(btn) ) current = temp_utils.CURRENT - total = current temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") break left = int(last_msg_id)-int(total) + total = current current += 1 if current % 20 == 0: btn = [[ From 7dfc4c8089ea8927daead1836e545ee8d6537335 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 14:39:28 +0530 Subject: [PATCH 25/45] Fix error --- plugins/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 231d851..919b90d 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -146,7 +146,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): empty+=1 continue elif not msg.media: - no_media += 1 + notmedia += 1 continue elif msg.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: unsupported += 1 @@ -171,4 +171,4 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") \ No newline at end of file + await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") From 72f11580f712eae2de49169a0b211f6827400922 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Wed, 10 May 2023 18:58:37 +0530 Subject: [PATCH 26/45] Create app.json --- app.json | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app.json diff --git a/app.json b/app.json new file mode 100644 index 0000000..6b0793b --- /dev/null +++ b/app.json @@ -0,0 +1,57 @@ +{ + "name": "File-Forward-Bot", + "description": "Use this bot to forward all files from one channel to other even if its private or public.", + "stack": "container", + "keywords": [ + "telegram", + "auto-forward-bot", + "forward-bot", + "forward", + "best", + "indian", + "pyrogram", + "media", + "export", + "channel", + "file-forward", + "media-forward" + ], + "website": "https://github.com/Joelkb/File-Forward-Bot", + "repository": "https://github.com/Joelkb/File-Forward-Bot", + "env": { + "BOT_TOKEN": { + "description": "Your bot token.", + "required": true + }, + "API_ID": { + "description": "Get this value from https://my.telegram.org", + "required": true + }, + "API_HASH": { + "description": "Get this value from https://my.telegram.org", + "required": true + }, + "TARGET_DB": { + "description": "ID of channel which you want the bot to send all files to.", + "required": true + }, + "ADMINS": { + "description": "ID of Admin. Separate multiple Admins by space.", + "required": true + }, + "LOG_CHANNEL": { + "description": "Bot Logs,Give a channel id with -100xxxxxxx", + "required": true + } + }, + "addons": [], + "buildpacks": [{ + "url": "heroku/python" + }], + "formation": { + "worker": { + "quantity": 1, + "size": "eco" + } + } +} From 98e5cd4d63cc389e70be6c2aba331d816ec7f973 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 14:45:33 +0530 Subject: [PATCH 27/45] Just a test Commit --- bot.py | 2 ++ database/data_base.py | 66 +++++++++++++++++++++++++++++++++++++++++++ plugins/commands.py | 47 ++++++++++++++++++++++++++++-- requirements.txt | 3 +- vars.py | 13 +++++---- 5 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 database/data_base.py diff --git a/bot.py b/bot.py index c4e8a86..b24561b 100644 --- a/bot.py +++ b/bot.py @@ -48,6 +48,8 @@ async def start(self): await app.setup() bind_address = "0.0.0.0" await web.TCPSite(app, bind_address, PORT).start() + + async def stop(self, *args): await super().stop() diff --git a/database/data_base.py b/database/data_base.py new file mode 100644 index 0000000..c355993 --- /dev/null +++ b/database/data_base.py @@ -0,0 +1,66 @@ +from vars import DB_URI, DB_NAME, COLLECTION_NAME, TARGET_DB +from pymongo import MongoClient + +client = MongoClient(DB_URI) +db = client[DB_NAME] +collection = db[COLLECTION_NAME] + +async def add_user(userid, username, name): + user_details = { + "id": userid, + "username": username, + "name": name, + "target": TARGET_DB, + "source": None, + "last_msg_id": 0, + "on_process": False, + "skip": 0, + "is_banned": False, + "ban_reason": None, + "caption": "{file_name}" + } + await collection.insert_one(user_details) + +async def is_user_exist(userid): + user = await collection.find_one({'id': userid}) + if user: + return True + else: + return False + +async def count_users(): + total = await collection.count_documents({}) + return total + +async def ban_user(userid, reason): + await collection.update_one({'id': userid}, {'$set': {'is_banned': True, 'ban_reason': reason}}) + +async def unban_user(userid): + await collection.update_one({'id': userid}, {'$set': {'is_banned': False, 'ban_reason': None}}) + +async def get_all_users(): + return await collection.find({}) + +async def get_user(userid): + user = await collection.find_one({'id': userid}) + if user: + return user + +async def update_stats(userid, msgid, last_msg_id, sourcechat, target): + await collection.update_one( + {'id': userid}, + {'$set': {'target': target, 'source': sourcechat, 'skip': msgid, 'last_msg_id': last_msg_id, 'on_process': True}}, + upsert=True + ) + +async def update_target(userid, target): + await collection.update_one( + {'id': userid}, + {'$set': {'target': target}} + ) + +async def update_caption(userid, caption): + await collection.update_one( + {'id': userid}, + {'$set': {'caption': caption}} + ) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py index 231d851..53f0479 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -3,6 +3,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified from pyrogram.errors import FloodWait +from database.data_base import is_user_exist, add_user, update_stats, get_user, update_target, update_caption from script import scripts from vars import ADMINS, TARGET_DB import asyncio @@ -21,15 +22,44 @@ async def start_message(bot, message): InlineKeyboardButton("Close", callback_data="close"), InlineKeyboardButton("Help", callback_data="help") ]] + is_exist = await is_user_exist(message.from_user.id) + if not is_exist: + await add_user(message.from_user.id, message.from_user.username, message.from_user.first_name) await message.reply_text( text=scripts.START_TXT.format(message.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(btn) ) +@Client.on_message(filters.command('set_target') & filters.user(ADMINS)) +async def set_target_chat(bot, message): + if ' ' in message.text: + _, chatid = message.text.split(" ") + try: + chatid = int(chatid) + except: + return await message.reply("Chat ID number should be an integer.") + await update_target(message.from_user.id, chatid) + await message.reply(f"Successfully set target channel ID as {chatid}") + else: + await message.reply("Give me a chat ID") + +@Client.on_message(filters.command('set_caption') & filters.user(ADMINS)) +async def set_file_caption(bot, message): + try: + _, caption = message.text.split(" ", 1)[1] + await update_caption(message.from_user.id, caption) + await message.reply(f"Successfully set caption as {caption}") + except: + await message.reply("Give me a caption") + + @Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming) async def forward_cmd(bot, message): if message.from_user.id not in ADMINS: return # admin only + user = await is_user_exist(message.from_user.id) + if not user: + await add_user(message.from_user.id, message.from_user.username, message.from_user.first_name) if message.text: regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") match = regex.match(message.text) @@ -96,6 +126,7 @@ async def skip_msgs(bot, message): async def start_forward(bot, userid, source_chat_id, last_msg_id): + user_info = await get_user(userid=userid) btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] @@ -133,6 +164,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] + await update_stats(userid=userid, msgid=current, last_msg_id=last_msg_id, sourcechat=source_chat_id, target=user_info['target']) await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) @@ -151,8 +183,16 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): elif msg.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: unsupported += 1 continue + caption = (user_info['caption']).format( + file_name='' if msg.file_name is None else msg.file_name, + file_size='' if msg.file_size is None else msg.file_size, + file_caption='' if msg.caption is None else msg.caption + ) try: - await msg.copy(chat_id=int(TARGET_DB)) + await msg.copy( + chat_id=int(user_info['target']), + caption=caption + ) forwarded+=1 await asyncio.sleep(1) except FloodWait as e: @@ -164,7 +204,10 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): reply_markup=InlineKeyboardMarkup(btn) ) await asyncio.sleep(e.value) - await msg.copy(chat_id=int(TARGET_DB)) + await msg.copy( + chat_id=int(user_info['target']), + caption=caption + ) forwarded+=1 continue except Exception as e: diff --git a/requirements.txt b/requirements.txt index 842cd19..4d32c2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ pyrogram tgcrypto pytz aiohttp -datetime \ No newline at end of file +datetime +pymongo \ No newline at end of file diff --git a/vars.py b/vars.py index e4997cf..66687cc 100644 --- a/vars.py +++ b/vars.py @@ -11,11 +11,14 @@ def is_enabled(value, default): return default SESSION = environ.get("SESSION", "forward bot") -API_ID = int(environ.get("API_ID", "")) -API_HASH = environ.get("API_HASH", "") -BOT_TOKEN = environ.get("BOT_TOKEN", "") -LOG_CHANNEL = int(environ.get("LOG_CHANNEL", "")) +API_ID = int(environ["API_ID"]) +API_HASH = environ["API_HASH"] +BOT_TOKEN = environ["BOT_TOKEN"] +LOG_CHANNEL = int(environ.get("LOG_CHANNEL", 0)) PORT = int(environ.get("PORT", "8080")) ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()] -TARGET_DB = int(environ.get("TARGET_DB", "")) +TARGET_DB = int(environ.get("TARGET_DB", 0)) +DB_URI = environ.get("DB_URL", "") +DB_NAME = environ.get("DB_NAME", "Cluster0") +COLLECTION_NAME = environ.get("COLLECTION_NAME", "User_Details") UPSTREAM_REPO = environ.get("UPSTREAM_REPO", "https://github.com/Joelkb/File-Forward-Bot") \ No newline at end of file From a364e6910d6f0ae01c40bfc476659fe8a393a9f5 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 14:56:52 +0530 Subject: [PATCH 28/45] Fix mistake --- vars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars.py b/vars.py index 66687cc..fb170a4 100644 --- a/vars.py +++ b/vars.py @@ -18,7 +18,7 @@ def is_enabled(value, default): PORT = int(environ.get("PORT", "8080")) ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()] TARGET_DB = int(environ.get("TARGET_DB", 0)) -DB_URI = environ.get("DB_URL", "") +DB_URI = environ.get("DB_URI", "") DB_NAME = environ.get("DB_NAME", "Cluster0") COLLECTION_NAME = environ.get("COLLECTION_NAME", "User_Details") -UPSTREAM_REPO = environ.get("UPSTREAM_REPO", "https://github.com/Joelkb/File-Forward-Bot") \ No newline at end of file +UPSTREAM_REPO = environ.get("UPSTREAM_REPO", "https://github.com/Joelkb/File-Forward-Bot") From cb4ad8378b73623588a9646cd74298af7414ac9e Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 15:14:16 +0530 Subject: [PATCH 29/45] Debugging --- plugins/commands.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 6529a9a..95f967f 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -22,7 +22,10 @@ async def start_message(bot, message): InlineKeyboardButton("Close", callback_data="close"), InlineKeyboardButton("Help", callback_data="help") ]] - is_exist = await is_user_exist(message.from_user.id) + try: + is_exist = await is_user_exist(message.from_user.id) + except Exception as e: + logger.exception(e) if not is_exist: await add_user(message.from_user.id, message.from_user.username, message.from_user.first_name) await message.reply_text( @@ -34,13 +37,16 @@ async def start_message(bot, message): @Client.on_message(filters.command('set_target') & filters.user(ADMINS)) async def set_target_chat(bot, message): if ' ' in message.text: - _, chatid = message.text.split(" ") try: - chatid = int(chatid) - except: - return await message.reply("Chat ID number should be an integer.") - await update_target(message.from_user.id, chatid) - await message.reply(f"Successfully set target channel ID as {chatid}") + _, chatid = message.text.split(" ") + try: + chatid = int(chatid) + except: + return await message.reply("Chat ID number should be an integer.") + await update_target(message.from_user.id, chatid) + await message.reply(f"Successfully set target channel ID as {chatid}") + except Exception as e: + logger.exception(e) else: await message.reply("Give me a chat ID") @@ -50,7 +56,8 @@ async def set_file_caption(bot, message): _, caption = message.text.split(" ", 1)[1] await update_caption(message.from_user.id, caption) await message.reply(f"Successfully set caption as {caption}") - except: + except Exception as e: + logger.exception(e) await message.reply("Give me a caption") From 3868790fff98a2367583fed5a4a54cd76bde1b95 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 15:24:24 +0530 Subject: [PATCH 30/45] Fix error --- database/data_base.py | 8 ++++---- plugins/commands.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/database/data_base.py b/database/data_base.py index c355993..f8e626a 100644 --- a/database/data_base.py +++ b/database/data_base.py @@ -21,8 +21,8 @@ async def add_user(userid, username, name): } await collection.insert_one(user_details) -async def is_user_exist(userid): - user = await collection.find_one({'id': userid}) +def is_user_exist(userid): + user = collection.find_one({'id': userid}) if user: return True else: @@ -53,8 +53,8 @@ async def update_stats(userid, msgid, last_msg_id, sourcechat, target): upsert=True ) -async def update_target(userid, target): - await collection.update_one( +def update_target(userid, target): + collection.update_one( {'id': userid}, {'$set': {'target': target}} ) diff --git a/plugins/commands.py b/plugins/commands.py index 95f967f..2ec2dd1 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -38,7 +38,7 @@ async def start_message(bot, message): async def set_target_chat(bot, message): if ' ' in message.text: try: - _, chatid = message.text.split(" ") + chatid = message.text.split(" ", 1)[1] try: chatid = int(chatid) except: @@ -53,7 +53,7 @@ async def set_target_chat(bot, message): @Client.on_message(filters.command('set_caption') & filters.user(ADMINS)) async def set_file_caption(bot, message): try: - _, caption = message.text.split(" ", 1)[1] + caption = message.text.split(" ", 1)[1] await update_caption(message.from_user.id, caption) await message.reply(f"Successfully set caption as {caption}") except Exception as e: From e5ecbefbd799cfafac93af63645ab146805e88c0 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 16:25:10 +0530 Subject: [PATCH 31/45] Fix --- database/data_base.py | 15 ++++++--------- plugins/commands.py | 5 ++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/database/data_base.py b/database/data_base.py index f8e626a..86112d9 100644 --- a/database/data_base.py +++ b/database/data_base.py @@ -21,12 +21,9 @@ async def add_user(userid, username, name): } await collection.insert_one(user_details) -def is_user_exist(userid): - user = collection.find_one({'id': userid}) - if user: - return True - else: - return False +async def is_user_exist(userid): + user = await collection.find_one({'id': userid}) + return bool(user) async def count_users(): total = await collection.count_documents({}) @@ -39,7 +36,7 @@ async def unban_user(userid): await collection.update_one({'id': userid}, {'$set': {'is_banned': False, 'ban_reason': None}}) async def get_all_users(): - return await collection.find({}) + return collection.find({}) async def get_user(userid): user = await collection.find_one({'id': userid}) @@ -53,8 +50,8 @@ async def update_stats(userid, msgid, last_msg_id, sourcechat, target): upsert=True ) -def update_target(userid, target): - collection.update_one( +async def update_target(userid, target): + await collection.update_one( {'id': userid}, {'$set': {'target': target}} ) diff --git a/plugins/commands.py b/plugins/commands.py index 2ec2dd1..001419f 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -64,7 +64,10 @@ async def set_file_caption(bot, message): @Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming) async def forward_cmd(bot, message): if message.from_user.id not in ADMINS: return # admin only - user = await is_user_exist(message.from_user.id) + try: + user = await is_user_exist(message.from_user.id) + except Exception as e: + logger.exception(e) if not user: await add_user(message.from_user.id, message.from_user.username, message.from_user.first_name) if message.text: From 07ec41a610df8a23b715072279e72d8beb187051 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 16:42:18 +0530 Subject: [PATCH 32/45] Fix --- database/data_base.py | 26 +++++++++++++------------- plugins/commands.py | 11 ++++++----- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/database/data_base.py b/database/data_base.py index 86112d9..b0fa558 100644 --- a/database/data_base.py +++ b/database/data_base.py @@ -21,19 +21,19 @@ async def add_user(userid, username, name): } await collection.insert_one(user_details) -async def is_user_exist(userid): - user = await collection.find_one({'id': userid}) +def is_user_exist(userid): + user = collection.find_one({'id': userid}) return bool(user) async def count_users(): total = await collection.count_documents({}) return total -async def ban_user(userid, reason): - await collection.update_one({'id': userid}, {'$set': {'is_banned': True, 'ban_reason': reason}}) +def ban_user(userid, reason): + collection.update_one({'id': userid}, {'$set': {'is_banned': True, 'ban_reason': reason}}) -async def unban_user(userid): - await collection.update_one({'id': userid}, {'$set': {'is_banned': False, 'ban_reason': None}}) +def unban_user(userid): + collection.update_one({'id': userid}, {'$set': {'is_banned': False, 'ban_reason': None}}) async def get_all_users(): return collection.find({}) @@ -43,21 +43,21 @@ async def get_user(userid): if user: return user -async def update_stats(userid, msgid, last_msg_id, sourcechat, target): - await collection.update_one( +def update_stats(userid, msgid, last_msg_id, sourcechat, target, on_process): + collection.update_one( {'id': userid}, - {'$set': {'target': target, 'source': sourcechat, 'skip': msgid, 'last_msg_id': last_msg_id, 'on_process': True}}, + {'$set': {'target': target, 'source': sourcechat, 'skip': msgid, 'last_msg_id': last_msg_id, 'on_process': on_process}}, upsert=True ) -async def update_target(userid, target): - await collection.update_one( +def update_target(userid, target): + collection.update_one( {'id': userid}, {'$set': {'target': target}} ) -async def update_caption(userid, caption): - await collection.update_one( +def update_caption(userid, caption): + collection.update_one( {'id': userid}, {'$set': {'caption': caption}} ) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py index 001419f..b91ea04 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -23,7 +23,7 @@ async def start_message(bot, message): InlineKeyboardButton("Help", callback_data="help") ]] try: - is_exist = await is_user_exist(message.from_user.id) + is_exist = is_user_exist(message.from_user.id) except Exception as e: logger.exception(e) if not is_exist: @@ -43,7 +43,7 @@ async def set_target_chat(bot, message): chatid = int(chatid) except: return await message.reply("Chat ID number should be an integer.") - await update_target(message.from_user.id, chatid) + update_target(message.from_user.id, chatid) await message.reply(f"Successfully set target channel ID as {chatid}") except Exception as e: logger.exception(e) @@ -54,7 +54,7 @@ async def set_target_chat(bot, message): async def set_file_caption(bot, message): try: caption = message.text.split(" ", 1)[1] - await update_caption(message.from_user.id, caption) + update_caption(message.from_user.id, caption) await message.reply(f"Successfully set caption as {caption}") except Exception as e: logger.exception(e) @@ -65,7 +65,7 @@ async def set_file_caption(bot, message): async def forward_cmd(bot, message): if message.from_user.id not in ADMINS: return # admin only try: - user = await is_user_exist(message.from_user.id) + user = is_user_exist(message.from_user.id) except Exception as e: logger.exception(e) if not user: @@ -174,7 +174,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] - await update_stats(userid=userid, msgid=current, last_msg_id=last_msg_id, sourcechat=source_chat_id, target=user_info['target']) + update_stats(userid=userid, msgid=current, last_msg_id=last_msg_id, sourcechat=source_chat_id, target=user_info['target'], on_process=True) await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) @@ -224,4 +224,5 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): logger.exception(e) await active_msg.edit(f'Error: {e}') else: + update_stats(userid=userid, msgid=current, last_msg_id=last_msg_id, sourcechat=source_chat_id, target=user_info['target'], on_process=False) await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") From 2337d534d4b22d59286076ec553f7ee04a8ea3db Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 16:51:18 +0530 Subject: [PATCH 33/45] Debug --- plugins/commands.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index b91ea04..98e20de 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -136,7 +136,10 @@ async def skip_msgs(bot, message): async def start_forward(bot, userid, source_chat_id, last_msg_id): - user_info = await get_user(userid=userid) + try: + user_info = await get_user(userid=userid) + except Exception as e: + logger.exception(e) btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] From 503effd569412fec86b33a8c5f3e33f945c3975e Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 16:59:14 +0530 Subject: [PATCH 34/45] Debug --- database/data_base.py | 16 ++++++++-------- plugins/commands.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/database/data_base.py b/database/data_base.py index b0fa558..4551da0 100644 --- a/database/data_base.py +++ b/database/data_base.py @@ -7,7 +7,7 @@ async def add_user(userid, username, name): user_details = { - "id": userid, + "id": int(userid), "username": username, "name": name, "target": TARGET_DB, @@ -22,7 +22,7 @@ async def add_user(userid, username, name): await collection.insert_one(user_details) def is_user_exist(userid): - user = collection.find_one({'id': userid}) + user = collection.find_one({'id': int(userid)}) return bool(user) async def count_users(): @@ -30,34 +30,34 @@ async def count_users(): return total def ban_user(userid, reason): - collection.update_one({'id': userid}, {'$set': {'is_banned': True, 'ban_reason': reason}}) + collection.update_one({'id': int(userid)}, {'$set': {'is_banned': True, 'ban_reason': reason}}) def unban_user(userid): - collection.update_one({'id': userid}, {'$set': {'is_banned': False, 'ban_reason': None}}) + collection.update_one({'id': int(userid)}, {'$set': {'is_banned': False, 'ban_reason': None}}) async def get_all_users(): return collection.find({}) async def get_user(userid): - user = await collection.find_one({'id': userid}) + user = await collection.find_one({'id': int(userid)}) if user: return user def update_stats(userid, msgid, last_msg_id, sourcechat, target, on_process): collection.update_one( - {'id': userid}, + {'id': int(userid)}, {'$set': {'target': target, 'source': sourcechat, 'skip': msgid, 'last_msg_id': last_msg_id, 'on_process': on_process}}, upsert=True ) def update_target(userid, target): collection.update_one( - {'id': userid}, + {'id': int(userid)}, {'$set': {'target': target}} ) def update_caption(userid, caption): collection.update_one( - {'id': userid}, + {'id': int(userid)}, {'$set': {'caption': caption}} ) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py index 98e20de..2e243b8 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -137,7 +137,7 @@ async def skip_msgs(bot, message): async def start_forward(bot, userid, source_chat_id, last_msg_id): try: - user_info = await get_user(userid=userid) + user_info = await get_user(userid=int(userid)) except Exception as e: logger.exception(e) btn = [[ From 5b00b0ac517f34a334b4c789e1964e1af8203004 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 17:12:15 +0530 Subject: [PATCH 35/45] Debug --- database/data_base.py | 3 +-- plugins/commands.py | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/database/data_base.py b/database/data_base.py index 4551da0..f7616d5 100644 --- a/database/data_base.py +++ b/database/data_base.py @@ -40,8 +40,7 @@ async def get_all_users(): async def get_user(userid): user = await collection.find_one({'id': int(userid)}) - if user: - return user + return user def update_stats(userid, msgid, last_msg_id, sourcechat, target, on_process): collection.update_one( diff --git a/plugins/commands.py b/plugins/commands.py index 2e243b8..ea03d22 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -140,6 +140,10 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): user_info = await get_user(userid=int(userid)) except Exception as e: logger.exception(e) + if user_info is None: + logger.exception("user_info is None") + else: + logger.exception(user_info) btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] From a2bfd1c6b59637d92904ba6756879344df24f4d6 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 17:17:38 +0530 Subject: [PATCH 36/45] Fix --- database/data_base.py | 4 ++-- plugins/commands.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database/data_base.py b/database/data_base.py index f7616d5..42e8262 100644 --- a/database/data_base.py +++ b/database/data_base.py @@ -38,8 +38,8 @@ def unban_user(userid): async def get_all_users(): return collection.find({}) -async def get_user(userid): - user = await collection.find_one({'id': int(userid)}) +def get_user(userid): + user = collection.find_one({'id': int(userid)}) return user def update_stats(userid, msgid, last_msg_id, sourcechat, target, on_process): diff --git a/plugins/commands.py b/plugins/commands.py index ea03d22..7703d2a 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -137,7 +137,7 @@ async def skip_msgs(bot, message): async def start_forward(bot, userid, source_chat_id, last_msg_id): try: - user_info = await get_user(userid=int(userid)) + user_info = get_user(userid=int(userid)) except Exception as e: logger.exception(e) if user_info is None: From ed1372ff9b1b51c2252eddddf691a62bae1ad69d Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Thu, 11 May 2023 17:27:14 +0530 Subject: [PATCH 37/45] Undo --- bot.py | 2 -- database/data_base.py | 62 ------------------------------------------- plugins/commands.py | 60 ++--------------------------------------- requirements.txt | 3 +-- vars.py | 3 --- 5 files changed, 3 insertions(+), 127 deletions(-) delete mode 100644 database/data_base.py diff --git a/bot.py b/bot.py index b24561b..cef3ced 100644 --- a/bot.py +++ b/bot.py @@ -49,8 +49,6 @@ async def start(self): bind_address = "0.0.0.0" await web.TCPSite(app, bind_address, PORT).start() - - async def stop(self, *args): await super().stop() logging.info("Bot stopped. Bye.") diff --git a/database/data_base.py b/database/data_base.py deleted file mode 100644 index 42e8262..0000000 --- a/database/data_base.py +++ /dev/null @@ -1,62 +0,0 @@ -from vars import DB_URI, DB_NAME, COLLECTION_NAME, TARGET_DB -from pymongo import MongoClient - -client = MongoClient(DB_URI) -db = client[DB_NAME] -collection = db[COLLECTION_NAME] - -async def add_user(userid, username, name): - user_details = { - "id": int(userid), - "username": username, - "name": name, - "target": TARGET_DB, - "source": None, - "last_msg_id": 0, - "on_process": False, - "skip": 0, - "is_banned": False, - "ban_reason": None, - "caption": "{file_name}" - } - await collection.insert_one(user_details) - -def is_user_exist(userid): - user = collection.find_one({'id': int(userid)}) - return bool(user) - -async def count_users(): - total = await collection.count_documents({}) - return total - -def ban_user(userid, reason): - collection.update_one({'id': int(userid)}, {'$set': {'is_banned': True, 'ban_reason': reason}}) - -def unban_user(userid): - collection.update_one({'id': int(userid)}, {'$set': {'is_banned': False, 'ban_reason': None}}) - -async def get_all_users(): - return collection.find({}) - -def get_user(userid): - user = collection.find_one({'id': int(userid)}) - return user - -def update_stats(userid, msgid, last_msg_id, sourcechat, target, on_process): - collection.update_one( - {'id': int(userid)}, - {'$set': {'target': target, 'source': sourcechat, 'skip': msgid, 'last_msg_id': last_msg_id, 'on_process': on_process}}, - upsert=True - ) - -def update_target(userid, target): - collection.update_one( - {'id': int(userid)}, - {'$set': {'target': target}} - ) - -def update_caption(userid, caption): - collection.update_one( - {'id': int(userid)}, - {'$set': {'caption': caption}} - ) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py index 7703d2a..6618126 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -3,7 +3,6 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified from pyrogram.errors import FloodWait -from database.data_base import is_user_exist, add_user, update_stats, get_user, update_target, update_caption from script import scripts from vars import ADMINS, TARGET_DB import asyncio @@ -22,54 +21,16 @@ async def start_message(bot, message): InlineKeyboardButton("Close", callback_data="close"), InlineKeyboardButton("Help", callback_data="help") ]] - try: - is_exist = is_user_exist(message.from_user.id) - except Exception as e: - logger.exception(e) - if not is_exist: - await add_user(message.from_user.id, message.from_user.username, message.from_user.first_name) await message.reply_text( text=scripts.START_TXT.format(message.from_user.mention, temp_utils.USER_NAME, temp_utils.BOT_NAME), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(btn) ) -@Client.on_message(filters.command('set_target') & filters.user(ADMINS)) -async def set_target_chat(bot, message): - if ' ' in message.text: - try: - chatid = message.text.split(" ", 1)[1] - try: - chatid = int(chatid) - except: - return await message.reply("Chat ID number should be an integer.") - update_target(message.from_user.id, chatid) - await message.reply(f"Successfully set target channel ID as {chatid}") - except Exception as e: - logger.exception(e) - else: - await message.reply("Give me a chat ID") - -@Client.on_message(filters.command('set_caption') & filters.user(ADMINS)) -async def set_file_caption(bot, message): - try: - caption = message.text.split(" ", 1)[1] - update_caption(message.from_user.id, caption) - await message.reply(f"Successfully set caption as {caption}") - except Exception as e: - logger.exception(e) - await message.reply("Give me a caption") - @Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming) async def forward_cmd(bot, message): if message.from_user.id not in ADMINS: return # admin only - try: - user = is_user_exist(message.from_user.id) - except Exception as e: - logger.exception(e) - if not user: - await add_user(message.from_user.id, message.from_user.username, message.from_user.first_name) if message.text: regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") match = regex.match(message.text) @@ -136,14 +97,6 @@ async def skip_msgs(bot, message): async def start_forward(bot, userid, source_chat_id, last_msg_id): - try: - user_info = get_user(userid=int(userid)) - except Exception as e: - logger.exception(e) - if user_info is None: - logger.exception("user_info is None") - else: - logger.exception(user_info) btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] @@ -181,7 +134,6 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] - update_stats(userid=userid, msgid=current, last_msg_id=last_msg_id, sourcechat=source_chat_id, target=user_info['target'], on_process=True) await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", reply_markup=InlineKeyboardMarkup(btn) @@ -200,15 +152,9 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): elif msg.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: unsupported += 1 continue - caption = (user_info['caption']).format( - file_name='' if msg.file_name is None else msg.file_name, - file_size='' if msg.file_size is None else msg.file_size, - file_caption='' if msg.caption is None else msg.caption - ) try: await msg.copy( - chat_id=int(user_info['target']), - caption=caption + chat_id=int(TARGET_DB) ) forwarded+=1 await asyncio.sleep(1) @@ -222,8 +168,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): ) await asyncio.sleep(e.value) await msg.copy( - chat_id=int(user_info['target']), - caption=caption + chat_id=int(TARGET_DB) ) forwarded+=1 continue @@ -231,5 +176,4 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - update_stats(userid=userid, msgid=current, last_msg_id=last_msg_id, sourcechat=source_chat_id, target=user_info['target'], on_process=False) await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") diff --git a/requirements.txt b/requirements.txt index 4d32c2c..842cd19 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,4 @@ pyrogram tgcrypto pytz aiohttp -datetime -pymongo \ No newline at end of file +datetime \ No newline at end of file diff --git a/vars.py b/vars.py index fb170a4..8b9c02f 100644 --- a/vars.py +++ b/vars.py @@ -18,7 +18,4 @@ def is_enabled(value, default): PORT = int(environ.get("PORT", "8080")) ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()] TARGET_DB = int(environ.get("TARGET_DB", 0)) -DB_URI = environ.get("DB_URI", "") -DB_NAME = environ.get("DB_NAME", "Cluster0") -COLLECTION_NAME = environ.get("COLLECTION_NAME", "User_Details") UPSTREAM_REPO = environ.get("UPSTREAM_REPO", "https://github.com/Joelkb/File-Forward-Bot") From f2a5598ad17252ca3423264c0c089edca5aa08f2 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 3 Jun 2023 19:36:33 +0530 Subject: [PATCH 38/45] Some Fixes --- plugins/commands.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 6618126..b1407bb 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -157,13 +157,12 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): chat_id=int(TARGET_DB) ) forwarded+=1 - await asyncio.sleep(1) except FloodWait as e: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Got FloodWait.\n\nWaiting for {e.value} seconds.", + text=f"Got FloodWait.\n\nWaiting for {e.value} seconds.", reply_markup=InlineKeyboardMarkup(btn) ) await asyncio.sleep(e.value) @@ -174,6 +173,6 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): continue except Exception as e: logger.exception(e) - await active_msg.edit(f'Error: {e}') + await active_msg.edit(f'Error: {e}') else: await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") From 2ab30123c0d8b901af1b1e652d29c2694de370aa Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 3 Jun 2023 19:43:13 +0530 Subject: [PATCH 39/45] Fixes went wrong --- plugins/commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/commands.py b/plugins/commands.py index b1407bb..1204aa2 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -157,6 +157,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): chat_id=int(TARGET_DB) ) forwarded+=1 + await asyncio.sleep(0.5) except FloodWait as e: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") From a858f06396e55c4aec02e09b84514ff6d8b88ca6 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 3 Jun 2023 20:11:19 +0530 Subject: [PATCH 40/45] Just a Try --- plugins/commands.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 1204aa2..07a614f 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -135,12 +135,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nSleeping for 30 seconds to avoid floodwait...", - reply_markup=InlineKeyboardMarkup(btn) - ) - await asyncio.sleep(30) - await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nResuming file forward...", + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", reply_markup=InlineKeyboardMarkup(btn) ) if msg.empty: @@ -157,7 +152,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): chat_id=int(TARGET_DB) ) forwarded+=1 - await asyncio.sleep(0.5) + await asyncio.sleep(1) except FloodWait as e: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") From 3d58927efa4557748db6046a85be6cc41e4e6d9f Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 3 Jun 2023 20:25:49 +0530 Subject: [PATCH 41/45] Fix --- plugins/commands.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 07a614f..ec58a84 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -112,20 +112,22 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): notmedia = 0 unsupported = 0 left = 0 + status = 'Idle' async with lock: try: btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] + status = 'Forwarding...' await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", reply_markup=InlineKeyboardMarkup(btn) ) current = temp_utils.CURRENT temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: - await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") + await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}") break left = int(last_msg_id)-int(total) total = current @@ -134,10 +136,17 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] + status = 'Sleeping for 5 seconds.' await active_msg.edit( - text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}", + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", reply_markup=InlineKeyboardMarkup(btn) ) + await asyncio.sleep(5) + status = 'Forwarding...' + await active_msg.edit( + text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", + reply_markup=InlineKeyboardMarkup(btn) + ) if msg.empty: empty+=1 continue @@ -171,4 +180,5 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): logger.exception(e) await active_msg.edit(f'Error: {e}') else: - await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}") + status = 'Completed.' + await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}") From 281f5ff29da56618b4986dad50562e2910199ca0 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 3 Jun 2023 20:32:21 +0530 Subject: [PATCH 42/45] Fixes and improvements --- plugins/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index ec58a84..c62e580 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -136,12 +136,12 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] - status = 'Sleeping for 5 seconds.' + status = 'Sleeping for 20 seconds.' await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", reply_markup=InlineKeyboardMarkup(btn) ) - await asyncio.sleep(5) + await asyncio.sleep(20) status = 'Forwarding...' await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", From ea4a346b0a744cfb328a6171ae02d7bb1997dc9e Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 3 Jun 2023 20:42:31 +0530 Subject: [PATCH 43/45] Update commands.py --- plugins/commands.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index c62e580..0db1161 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -127,6 +127,7 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): temp_utils.CANCEL = False async for msg in bot.iter_messages(source_chat_id, int(last_msg_id), int(temp_utils.CURRENT)): if temp_utils.CANCEL: + status = 'Cancelled !' await active_msg.edit(f"Successfully Cancelled!\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}") break left = int(last_msg_id)-int(total) @@ -136,12 +137,12 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): btn = [[ InlineKeyboardButton("CANCEL", callback_data="cancel_forward") ]] - status = 'Sleeping for 20 seconds.' + status = 'Sleeping for 30 seconds.' await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", reply_markup=InlineKeyboardMarkup(btn) ) - await asyncio.sleep(20) + await asyncio.sleep(30) status = 'Forwarding...' await active_msg.edit( text=f"Forwarding on progress...\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}", @@ -176,9 +177,9 @@ async def start_forward(bot, userid, source_chat_id, last_msg_id): ) forwarded+=1 continue + status = 'Completed !' except Exception as e: logger.exception(e) await active_msg.edit(f'Error: {e}') else: - status = 'Completed.' await active_msg.edit(f"Successfully Completed Forward Process !\n\nTotal: {total}\nSkipped: {skipped}\nForwarded: {forwarded}\nEmpty Message: {empty}\nNot Media: {notmedia}\nUnsupported Media: {unsupported}\nMessages Left: {left}\n\nStatus: {status}") From 1f5bb5ab24f8d5409d8c088633982cab5361b9f9 Mon Sep 17 00:00:00 2001 From: Joel Kurian Biju <92435259+Joelkb@users.noreply.github.com> Date: Sat, 6 Jan 2024 19:40:32 +0530 Subject: [PATCH 44/45] Changes --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7916c1a..7dc7b02 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # File-Forward-Bot +#Not Yet Completed !
Deploy To Render
From 04dba82ab5d1069c83bf3c686ac0be6baba5ef82 Mon Sep 17 00:00:00 2001 From: Muhammedhashirm009 <87589712+Muhammedhashirm009@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:57:43 +0530 Subject: [PATCH 45/45] Update Dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 160516a..37a66e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,5 +8,4 @@ RUN cd / RUN pip3 install -U pip && pip3 install -U -r requirements.txt RUN mkdir /ForwardBot WORKDIR /ForwardBot -COPY start.sh /start.sh -CMD ["/bin/bash", "/start.sh"] \ No newline at end of file +RUN python3 bot.py