浏览代码

Upload files by shell

misakano7545 3 年之前
当前提交
d569abef61

+ 674 - 0
LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  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
+them 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 prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  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.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  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.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     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
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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 3 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, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program 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, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU 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.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 159 - 0
README.md

@@ -0,0 +1,159 @@
+English | [简体中文](README_sc.md)
+# eu_ex
+
+eu_ex means EUserv_extend. A Python script which can help you renew your free EUserv IPv6 VPS.
+
+This Script can check the VPS amount in your account automatically and renew the VPS if it can be renewed.
+
+## How to Use
+
+1. Install Python3 and dependences, the following command is used in debian/ubuntu for example,
+
+   ```bash
+   #Install Python3
+   apt install python3 python3-pip -y
+   #Intstall dependences
+   pip install requests beautifulsoup4
+   ```
+
+2. It is not recommended to replace the `USERNAME` & `PASSWORD` parameters with yours in `main.py` Line 37-38 directly. Pass them in from environment variables.
+
+   Your can add multiple accounts with single space separated.
+
+3. Your can add multiple mailparser.io parsed data download URL id with single space separated. The download URL id is in `https://files.mailparser.io/d/<download_url_id>`.
+
+4. Pass the **Actions secrets** into the environment variable of your GitHub Action runtime environment. For example, the following environment variables are required.
+
+   ```
+   env:
+       USERNAME: ${{ secrets.USERNAME }}
+       PASSWORD: ${{ secrets.PASSWORD }}
+       # https://mailparser.io   
+       MAILPARSER_DOWNLOAD_URL_ID: ${{ secrets.MAILPARSER_DOWNLOAD_URL_ID }}
+   ```
+
+## Mail forwarding and mailparser settings
+### Mail forwarding
+
+Take gmail as an example, forward emails to [mailparser](https://mailparser.io). It is possible for non-gmail mailboxes to receive emails from euserv, provided that they can be received. Currently outlook/hotmail does not receive it.
+
+- ![gmail_filter_keys](./images/gmail_filter_keys.png)
+
+- ![gmail_filter_setting](./images/gmail_filter_setting.png)
+
+- ![gmail_forward_setting](./images/gmail_forward_setting.png)
+
+### Mailparser settings
+
+- Create new inbox firstly.
+- Create data parsing rules.
+  - mailparser_data_parsing_rules
+   ![mailparser_data_parsing_rules](./images/mailparser_data_parsing_rules.png)
+  - mailparser_data_parsing_rules_pin
+  ![mailparser_data_parsing_rules_pin](./images/mailparser_data_parsing_rules_pin.png)
+  - mailparser_data_parsing_rules_subject
+  ![mailparser_data_parsing_rules_subject](./images/mailparser_data_parsing_rules_subject.png)
+  - mailparser_data_parsing_rules_sender
+  ![mailparser_data_parsing_rules_sender](./images/mailparser_data_parsing_rules_sender.png)
+  - mailparser_data_parsing_rules_receiver
+  ![mailparser_data_parsing_rules_receiver](./images/mailparser_data_parsing_rules_receiver.png)
+- Create parsed data download url
+  - mailparser_parsed_data_downloads
+  ![mailparser_parsed_data_downloads](./images/mailparser_parsed_data_downloads.png)
+- mailparser_parsed_data_downloads_setting
+  ![mailparser_parsed_data_downloads_setting](./images/mailparser_parsed_data_downloads_setting.png)
+- Settings
+  - mailparser_inbox_setting_1
+  ![mailparser_inbox_setting_1](./images/mailparser_inbox_setting_1.png)
+  - mailparser_inbox_setting_2
+  ![mailparser_inbox_setting_2](./images/mailparser_inbox_setting_2.png)
+
+## Final result
+The effect is as shown,
+
+![mailparser_inbox_setting_2](./images/the_final_effect.png)
+
+## TODO
+
+- [x] ~~Validate the `receiver` field parsed by mailparser to reduce malicious email interference.~~ Won't do due to mailparser *Inbox Settings - Email Reception*.
+- [ ] Open pre-trained models to solve the problem of CAPTCHA recognition locally.
+- [ ] Log internationalization and localization.
+
+## Acknowledgement
+
+- Thanks EUserv provides us free IPv6 VPS for learning.
+- Thanks CokeMine & its repository contributors provides us the original *EUserv_extend* script .The internet never forgets, but people do.
+
+## Q&A
+
+1. **Q**: It can be non-gmail mailbox?
+
+   **A**: Can be a non-gmail mailbox,the prerequisite is to receive emails from euserv. Currently outlook/hotmail does not receive it.
+
+2. **Q**: Can n mailboxes use the same mailparser or do I need to apply for n mailparsers to correspond with one?
+
+   **A**: The mailparser free account can set up to 10 inboxes, and these 10 inboxes can correspond to 10 euserv accounts, and there are 10 mailparser parsed data download URLs(ids). So, it depends on whether you have n>10, or n<10. n<10, one mailparsed account is enough, and then the parsed data download URL ids correspond to the registered email accounts of euserv.
+
+3. **Q**: How eu_ex script works?
+
+   **A**: EUserv set the first threshold from the end of September 2021, that is, the login verification code (successful verification status maintained for 24 hours), so from now on, we use the API provided by TrueCaptcha (there is a free amount every day) to identify. Not long after, about the beginning of November 2021, EUserv set a second threshold, which is the email PIN verification when renewing, and here the solution is about two kinds: a. Login to the mailbox to get the email containing EUserv PIN. b. Convert the email into HTTP REST API to get it automatically. Option b is adopted here. It seems that only [Mailparser](https://mailparser.io) and [Zapier Emails Parser](https://parser.zapier.com/) are available in option b for free quota. Option b is clearly better than option a.
+
+## References
+
+### EUserv "PIN for the Confirmation of a Security Check" original mail
+
+```
+From:	     EUserv Support <[email protected]>
+To:	         [email protected]
+Subject:	 EUserv - PIN for the Confirmation of a Security Check
+Content-Type: text/plain; charset = utf-8
+Dear XYZ,
+
+you have just requested a PIN for confirmation of a security check at EUserv. If you have not requested the PIN then ignore this email.
+
+PIN:
+123456
+
+PLEASE NOTE: If you already have requested a new PIN for the same process this PIN is invalid. Also this PIN is only valid within the session in which it has been requested. This means the PIN is invalid if you for example change the browser or if you logout and perform a new login.
+
+
+Sincerely,
+Your customer support EUserv
+
+--
+Web ................: http://www.euserv.com
+Login control panel.: https://support.euserv.com
+FAQ ................: http://faq.euserv.com
+Help & Guides.......: http://wiki.euserv.com
+Community / Forum...: http://forum.euserv.com
+Mailing-Liste ......: http://www.euserv.com/en/?show_contact=mailinglist
+Twitter ............: http://twitter.com/euservhosting
+Facebook ...........: http://www.facebook.com/euservhosting
+--
+
+EUserv Internet
+is a division of
+ISPpro Internet KG
+
+Postal address:
+ISPpro Internet KG
+Division EUserv Internet
+P.O. Box 2224
+07622 Hermsdorf
+GERMANY
+
+Support-Phone: +49 (0) 3641 3101011 (English speaking)
+
+Administration:
+ISPpro Internet KG
+Neue Str. 4
+D-07639 Bad Klosterlausnitz
+GERMANY
+
+Management...............: Dirk Seidel
+Register.................: AG Jena, HRA 202638
+VAT Number...............: 162/156/36600
+Tax office ..............: Jena
+International VAT Number.: DE813856317
+```
+

+ 159 - 0
README_sc.md

@@ -0,0 +1,159 @@
+[English](./README.md) | 简体中文
+# eu_ex
+
+eu_ex 是 EUserv_extend 的简写。一个 Python 脚本,可以帮你续期免费 EUserv IPv6 VPS。
+
+这个脚本可以自动检查你账户中的 VPS 数量,如果可以续期,就为 VPS 续期。
+
+## 如何使用
+
+1. 安装 Python3 和必要的依赖,以下命令在 debian/ubuntu 为例,
+
+   ```bash
+   #Install Python3
+   apt install python3 python3-pip -y
+   #Intstall dependences
+   pip install requests beautifulsoup4
+   ```
+
+2. 不建议在 `main.py` 文件第 37-38 行直接用你的真实值去替换`USERNAME`和`PASSWORD`。可以使用环境变量传入。
+
+   你可以添加多个账户,并以一个空格分隔。
+
+3. 你可以添加多个 mailparser.io 解析数据的下载 URL ID,并以一个空格分隔。下载的 URL ID 在`https://files.mailparser.io/d/<download_url_id>`。
+
+4. 将 **Actions secrets** 传入你的 GitHub Action 运行环境的环境变量。例如,以下环境变量是必需的。
+
+   ```
+   env:
+       USERNAME: ${{ secrets.USERNAME }}
+       PASSWORD: ${{ secrets.PASSWORD }}
+       # https://mailparser.io   
+       MAILPARSER_DOWNLOAD_URL_ID: ${{ secrets.MAILPARSER_DOWNLOAD_URL_ID }}
+   ```
+
+## 邮件转发和 mailparser 设置
+### 邮件转发
+
+以 gmail 为例, 转发邮件至 [mailparser](https://mailparser.io)。可以是非 gmail 邮箱,前提是可以收到 euserv 的邮件。目前 outlook/hotmail 是收不到的。
+
+- ![gmail_filter_keys](./images/gmail_filter_keys.png)
+
+- ![gmail_filter_setting](./images/gmail_filter_setting.png)
+
+- ![gmail_forward_setting](./images/gmail_forward_setting.png)
+
+### Mailparser 设置
+
+- 首先创建新的收件箱。
+- 创建数据解析规则。
+  - 数据解析规则,pin 为必需,其他可选。
+   ![mailparser_data_parsing_rules](./images/mailparser_data_parsing_rules.png)
+  - pin 的解析规则
+  ![mailparser_data_parsing_rules_pin](./images/mailparser_data_parsing_rules_pin.png)
+  - subject 的解析规则
+  ![mailparser_data_parsing_rules_subject](./images/mailparser_data_parsing_rules_subject.png)
+  - sender 的解析规则
+  ![mailparser_data_parsing_rules_sender](./images/mailparser_data_parsing_rules_sender.png)
+  - receiver 的解析规则
+  ![mailparser_data_parsing_rules_receiver](./images/mailparser_data_parsing_rules_receiver.png)
+- 创建解析数据下载 URL
+  - 解析数据下载 URL
+  ![mailparser_parsed_data_downloads](./images/mailparser_parsed_data_downloads.png)
+- 解析数据下载设置
+  ![mailparser_parsed_data_downloads_setting](./images/mailparser_parsed_data_downloads_setting.png)
+- mailparser 收件箱设置(可选,为减少收到 spam 邮件的风险,最好设置)
+  - mailparser 收件箱设置 1
+  ![mailparser_inbox_setting_1](./images/mailparser_inbox_setting_1.png)
+  - mailparser 收件箱设置 2
+  ![mailparser_inbox_setting_2](./images/mailparser_inbox_setting_2.png)
+
+## 最终效果
+效果如图,
+
+![mailparser_inbox_setting_2](./images/the_final_effect.png)
+
+## 待办事项
+
+- [x] ~~验证mailparser解析的`receiver'字段,以减少恶意邮件的干扰。~~ 由于 mailparser *Inbox Settings - Email Reception*,所以不做了。
+- [ ] 开放预训练的模型,在本地,不调用第三方接口就解决验证码识别的问题。
+- [ ] 日志国际化和本地化。
+
+## 鸣谢
+
+- 感谢 EUserv 提供免费的 IPv6 VPS 供我们学习。
+- 感谢 CokeMine 和其仓库贡献者为我们提供的最初 *EUserv_extend* 脚本。互联网永远不会忘记,但人们会。
+
+## Q&A
+
+1. **Q**: 可以非 gmail 邮箱吗?
+
+   **A**: 可以是非 gmail 邮箱,前提是可以收到 euserv 的邮件。目前 outlook/hotmail 是收不到的。
+
+2. **Q**: n 个邮箱能在用同一个 mailparser 还是需要申请 n 个 mailparser 与之一 一对应吗?
+
+   **A**: mailparser free 账号最多可以设置 10 个收件箱,这 10 个收件箱就可以对应 10 个 euserv 账号,也就有了 10 个  mailparser parsed data download URL(id)。所以,这得看你 n>10, 还是 n<10  了。n<10, 一个 mailparsed 账号即可,然后 parsed data download URL id 一 一对应  euserv 的注册邮箱账号。
+
+3. **Q**: 续期脚本是如何工作的?
+
+   **A**: EUserv 从 2021 年 9 月底开始,设置了第一道门槛,那就是登录出现验证码(成功验证状态维持 24 小时),所以目前就用 TrueCaptcha 提供的 API(每天都有免费额度) 进行识别。没过多久,大概是 2021 年11月初,EUserv 又设置了第二道门槛,就是续期时的邮件 PIN 码验证,这里解决办法就大概两种:a. 登录邮箱获取含 EUserv PIN 的邮件。b. 将邮件转化为 HTTP REST API,自动获取。这里采取的是方案 b。方案 b 中可选的存在免费额度的,好像目前仅有 [Mailparser](https://mailparser.io) 和 [Zapier Emails Parser](https://parser.zapier.com/)。方案 b 明显要优于方案 a。
+
+## 参考信息
+
+### EUserv "PIN for the Confirmation of a Security Check" 原始邮件
+
+```
+From:	     EUserv Support <[email protected]>
+To:	         [email protected]
+Subject:	 EUserv - PIN for the Confirmation of a Security Check
+Content-Type: text/plain; charset = utf-8
+Dear XYZ,
+
+you have just requested a PIN for confirmation of a security check at EUserv. If you have not requested the PIN then ignore this email.
+
+PIN:
+123456
+
+PLEASE NOTE: If you already have requested a new PIN for the same process this PIN is invalid. Also this PIN is only valid within the session in which it has been requested. This means the PIN is invalid if you for example change the browser or if you logout and perform a new login.
+
+
+Sincerely,
+Your customer support EUserv
+
+--
+Web ................: http://www.euserv.com
+Login control panel.: https://support.euserv.com
+FAQ ................: http://faq.euserv.com
+Help & Guides.......: http://wiki.euserv.com
+Community / Forum...: http://forum.euserv.com
+Mailing-Liste ......: http://www.euserv.com/en/?show_contact=mailinglist
+Twitter ............: http://twitter.com/euservhosting
+Facebook ...........: http://www.facebook.com/euservhosting
+--
+
+EUserv Internet
+is a division of
+ISPpro Internet KG
+
+Postal address:
+ISPpro Internet KG
+Division EUserv Internet
+P.O. Box 2224
+07622 Hermsdorf
+GERMANY
+
+Support-Phone: +49 (0) 3641 3101011 (English speaking)
+
+Administration:
+ISPpro Internet KG
+Neue Str. 4
+D-07639 Bad Klosterlausnitz
+GERMANY
+
+Management...............: Dirk Seidel
+Register.................: AG Jena, HRA 202638
+VAT Number...............: 162/156/36600
+Tax office ..............: Jena
+International VAT Number.: DE813856317
+```
+

二进制
images/gmail_filter_keys.png


二进制
images/gmail_filter_setting.png


二进制
images/gmail_forward_setting.png


二进制
images/mailparser_data_parsing_rules.png


二进制
images/mailparser_data_parsing_rules_pin.png


二进制
images/mailparser_data_parsing_rules_receiver.png


二进制
images/mailparser_data_parsing_rules_sender.png


二进制
images/mailparser_data_parsing_rules_subject.png


二进制
images/mailparser_inbox_setting_1.png


二进制
images/mailparser_inbox_setting_2.png


二进制
images/mailparser_parsed_data_downloads.png


二进制
images/mailparser_parsed_data_downloads_setting.png


二进制
images/the_final_effect.png


+ 548 - 0
main.py

@@ -0,0 +1,548 @@
+#!/usr/bin/env python3
+
+#
+# SPDX-FileCopyrightText: (c) 2020-2021 CokeMine & Its repository contributors
+# SPDX-FileCopyrightText: (c) 2021 A beam of light
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+
+"""
+euserv auto-renew script
+
+ChangeLog
+
+v2021.09.30
+- Captcha automatic recognition using TrueCaptcha API
+- Email notification
+- Add login failure retry mechanism
+- reformat log info
+
+v2021.11.06
+- Receive renew PIN(6-digits) using mailparser parsed data download url
+  workflow: auto-forward your EUserv PIN email to your mailparser inbox 
+  -> parsing PIN via mailparser -> get PIN from mailparser
+- Update kc2_security_password_get_token request
+
+v2021.11.26
+- Adjust TrueCaptcha constraint parameters for high availability.
+  Plus, the CAPTCHA of EUserv is currently case-insensitive, so the above adjustment works.
+
+"""
+
+import os
+import re
+import json
+import time
+import base64
+
+from email.mime.application import MIMEApplication
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+from smtplib import SMTP_SSL, SMTPDataError
+
+import requests
+from bs4 import BeautifulSoup
+
+# 多个账户请使用空格隔开
+USERNAME = os.environ["USERNAME"]  # 用户名或邮箱
+PASSWORD = os.environ["PASSWORD"]  # 密码
+
+# default value is TrueCaptcha demo credential,
+# you can use your own credential via set environment variables:
+# TRUECAPTCHA_USERID and TRUECAPTCHA_APIKEY
+# demo: https://apitruecaptcha.org/demo
+# demo2: https://apitruecaptcha.org/demo2
+# demo apikey also has a limit of 100 times per day
+# {
+# 'error': '101.0 above free usage limit 100 per day and no balance',
+# 'requestId': '7690c065-70e0-4757-839b-5fd8381e65c7'
+# }
+TRUECAPTCHA_USERID = os.environ.get("TRUECAPTCHA_USERID", "arun56")
+TRUECAPTCHA_APIKEY = os.environ.get("TRUECAPTCHA_APIKEY", "wMjXmBIcHcdYqO2RrsVN")
+
+# Extract key data from your emails, automatically. https://mailparser.io 
+# 30 Emails/Month, 10 inboxes and unlimited downloads for free.
+# 多个mailparser下载链接id请使用空格隔开, 顺序与 EUserv 账号/邮箱一一对应
+MAILPARSER_DOWNLOAD_URL_ID = os.environ["MAILPARSER_DOWNLOAD_URL_ID"]
+# mailparser.io parsed data download base url
+MAILPARSER_DOWNLOAD_BASE_URL = "https://files.mailparser.io/d/"
+
+# Telegram Bot Push https://core.telegram.org/bots/api#authorizing-your-bot
+TG_BOT_TOKEN = ""  # 通过 @BotFather 申请获得,示例:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw
+TG_USER_ID = ""  # 用户、群组或频道 ID,示例:129xxx206
+TG_API_HOST = "https://api.telegram.org"  # 自建 API 反代地址,供网络环境无法访问时使用,网络正常则保持默认
+
+# Email notification
+RECEIVER_EMAIL = os.environ.get("RECEIVER_EMAIL", "")
+YD_EMAIL = os.environ.get("YD_EMAIL", "")
+YD_APP_PWD = os.environ.get("YD_APP_PWD", "")  # yandex mail 使用第三方 APP 授权码
+
+# Server 酱(ServerChan) https://sct.ftqq.com
+# 免费额度: 每天最多发送 5 条, 卡片仅显示标题, 每天 API 最大请求 1000 次, 每分钟最多发送 5 条.
+SERVER_CHAN_SENDKEY = os.environ.get("SERVER_CHAN_SENDKEY", "")  # Server 酱的 SENDKEY,无需推送可忽略
+
+# Magic internet access
+PROXIES = {"http": "http://127.0.0.1:10808", "https": "http://127.0.0.1:10808"}
+
+# Maximum number of login retry
+LOGIN_MAX_RETRY_COUNT = 5
+
+# Waiting time of receiving PIN, units are seconds.
+WAITING_TIME_OF_PIN = 15
+
+# options: True or False
+CHECK_CAPTCHA_SOLVER_USAGE = True
+
+user_agent = (
+    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
+    "Chrome/95.0.4638.69 Safari/537.36"
+)
+
+desp = ""  # 空值
+
+
+def log(info: str):
+    print(info)
+    global desp
+    desp = desp + info + "\n\n"
+
+
+def login_retry(*args, **kwargs):
+    def wrapper(func):
+        def inner(username, password):
+            ret, ret_session = func(username, password)
+            max_retry = kwargs.get("max_retry")
+            # default retry 3 times
+            if not max_retry:
+                max_retry = 3
+            number = 0
+            if ret == "-1":
+                while number < max_retry:
+                    number += 1
+                    if number > 1:
+                        ordinal = lambda n: "{}{}".format(n,"tsnrhtdd"[(n/10%10!=1)*(n%10<4)*n%10::4])
+                        log(f"[EUserv] Login tried the {ordinal(number)} time.")
+                    sess_id, session = func(username, password)
+                    if sess_id != "-1":
+                        return sess_id, session
+                    else:
+                        if number == max_retry:
+                            return sess_id, session
+            else:
+                return ret, ret_session
+
+        return inner
+
+    return wrapper
+
+
+def captcha_solver(captcha_image_url: str, session: requests.session) -> dict:
+    """
+    TrueCaptcha API doc: https://apitruecaptcha.org/api
+    Free to use 100 requests per day.
+    -- response::
+    {
+        "result": "", ==> Or "result": 0
+        "conf": 0.85, 
+        "usage": 0, 
+        "requestId": "ed0006e5-69f0-4617-b698-97dc054f9022", 
+        "version": "dev2"
+    }
+    """
+    response = session.get(captcha_image_url)
+    encoded_string = base64.b64encode(response.content)
+    url = "https://api.apitruecaptcha.org/one/gettext"
+
+    # Since "case": "mixed", "mode": "human" 
+    # can sometimes cause internal errors in the truecaptcha server. 
+    # So a more relaxed constraint(lower/upper & default) is used here.
+    # Plus, the CAPTCHA of EUserv is currently case-insensitive, so the below adjustment works.
+    data = {
+        "userid": TRUECAPTCHA_USERID,
+        "apikey": TRUECAPTCHA_APIKEY,
+        # case sensitivity of text (upper | lower| mixed)
+        "case": "lower",
+        # use human or AI (human | default)
+        "mode": "default",
+        "data": str(encoded_string)[2:-1],
+    }
+    r = requests.post(url=url, json=data)
+    j = json.loads(r.text)
+    return j
+
+
+def handle_captcha_solved_result(solved: dict) -> str:
+    """Since CAPTCHA sometimes appears as a very simple binary arithmetic expression.
+    But since recognition sometimes doesn't show the result of the calculation directly,
+    that's what this function is for.
+    """
+    if "result" in solved:
+        solved_result = solved["result"]
+        if isinstance(solved_result, str):
+            if "RESULT  IS" in solved_result:
+                log("[Captcha Solver] You are using the demo apikey.")
+                print("There is no guarantee that demo apikey will work in the future!")
+                # because using demo apikey
+                text = re.findall(r"RESULT  IS . (.*) .", solved_result)[0]
+            else:
+                # using your own apikey
+                log("[Captcha Solver] You are using your own apikey.")
+                text = solved_result
+            operators = ["X", "x", "+", "-"]
+            if any(x in text for x in operators):
+                for operator in operators:
+                    operator_pos = text.find(operator)
+                    if operator == "x" or operator == "X":
+                        operator = "*"
+                    if operator_pos != -1:
+                        left_part = text[:operator_pos]
+                        right_part = text[operator_pos + 1 :]
+                        if left_part.isdigit() and right_part.isdigit():
+                            return eval(
+                                "{left} {operator} {right}".format(
+                                    left=left_part, operator=operator, right=right_part
+                                )
+                            )
+                        else:
+                            # Because these symbols("X", "x", "+", "-") do not appear at the same time,
+                            # it just contains an arithmetic symbol.
+                            return text
+            else:
+                return text
+        else:
+            print(f"[Captcha Solver] Returned JSON: {solved}")
+            log("[Captcha Solver] Service Exception!")
+            raise ValueError("[Captcha Solver] Service Exception!")
+    else:
+        print(f"[Captcha Solver] Returned JSON: {solved}")
+        log("[Captcha Solver] Failed to find parsed results!")
+        raise KeyError("[Captcha Solver] Failed to find parsed results!")
+
+
+def get_captcha_solver_usage() -> dict:
+    url = "https://api.apitruecaptcha.org/one/getusage"
+
+    params = {
+        "username": TRUECAPTCHA_USERID,
+        "apikey": TRUECAPTCHA_APIKEY,
+    }
+    r = requests.get(url=url, params=params)
+    j = json.loads(r.text)
+    return j
+
+
+def get_pin_from_mailparser(url_id: str) -> str:
+    """
+    response format:
+    [
+      {
+        "id": "83b95f50f6202fb03950afbe00975eab",
+        "received_at": "2021-11-06 02:30:07",  ==> up to mailparser account timezone setting, here is UTC 0000.
+        "processed_at": "2021-11-06 02:30:07",
+        "pin": "123456"
+      }
+    ]
+    """
+    response = requests.get(
+        f"{MAILPARSER_DOWNLOAD_BASE_URL}{url_id}",
+        # Mailparser parsed data download using Basic Authentication.
+        # auth=("<your mailparser username>", "<your mailparser password>")
+    )
+    pin = response.json()[0]["pin"]
+    return pin
+
+
+@login_retry(max_retry=LOGIN_MAX_RETRY_COUNT)
+def login(username: str, password: str) -> (str, requests.session):
+    headers = {"user-agent": user_agent, "origin": "https://www.euserv.com"}
+    url = "https://support.euserv.com/index.iphp"
+    captcha_image_url = "https://support.euserv.com/securimage_show.php"
+    session = requests.Session()
+
+    sess = session.get(url, headers=headers)
+    sess_id = re.findall("PHPSESSID=(\\w{10,100});", str(sess.headers))[0]
+    # visit png
+    logo_png_url = "https://support.euserv.com/pic/logo_small.png"
+    session.get(logo_png_url, headers=headers)
+
+    login_data = {
+        "email": username,
+        "password": password,
+        "form_selected_language": "en",
+        "Submit": "Login",
+        "subaction": "login",
+        "sess_id": sess_id,
+    }
+    f = session.post(url, headers=headers, data=login_data)
+    f.raise_for_status()
+
+    if (
+        f.text.find("Hello") == -1
+        and f.text.find("Confirm or change your customer data here") == -1
+    ):
+        if (
+            f.text.find(
+                "To finish the login process please solve the following captcha."
+            )
+            == -1
+        ):
+            return "-1", session
+        else:
+            log("[Captcha Solver] 进行验证码识别...")
+            solved_result = captcha_solver(captcha_image_url, session)
+            try:
+                captcha_code = handle_captcha_solved_result(solved_result)
+                log("[Captcha Solver] 识别的验证码是: {}".format(captcha_code))
+
+                if CHECK_CAPTCHA_SOLVER_USAGE:
+                    usage = get_captcha_solver_usage()
+                    log(
+                        "[Captcha Solver] current date {0} api usage count: {1}".format(
+                            usage[0]["date"], usage[0]["count"]
+                        )
+                    )
+
+                f2 = session.post(
+                    url,
+                    headers=headers,
+                    data={
+                        "subaction": "login",
+                        "sess_id": sess_id,
+                        "captcha_code": captcha_code,
+                    },
+                )
+                if (
+                    f2.text.find(
+                        "To finish the login process please solve the following captcha."
+                    )
+                    == -1
+                ):
+                    log("[Captcha Solver] 验证通过")
+                    return sess_id, session
+                else:
+                    log("[Captcha Solver] 验证失败")
+                    return "-1", session
+            except (KeyError, ValueError):
+                return "-1", session
+    else:
+        return sess_id, session
+
+
+def get_servers(sess_id: str, session: requests.session) -> {}:
+    d = {}
+    url = "https://support.euserv.com/index.iphp?sess_id=" + sess_id
+    headers = {"user-agent": user_agent, "origin": "https://www.euserv.com"}
+    f = session.get(url=url, headers=headers)
+    f.raise_for_status()
+    soup = BeautifulSoup(f.text, "html.parser")
+    for tr in soup.select(
+        "#kc2_order_customer_orders_tab_content_1 .kc2_order_table.kc2_content_table tr"
+    ):
+        server_id = tr.select(".td-z1-sp1-kc")
+        if not len(server_id) == 1:
+            continue
+        flag = (
+            True
+            if tr.select(".td-z1-sp2-kc .kc2_order_action_container")[0]
+            .get_text()
+            .find("Contract extension possible from")
+            == -1
+            else False
+        )
+        d[server_id[0].get_text()] = flag
+    return d
+
+
+def renew(
+    sess_id: str, session: requests.session, password: str, order_id: str, mailparser_dl_url_id: str
+) -> bool:
+    url = "https://support.euserv.com/index.iphp"
+    headers = {
+        "user-agent": user_agent,
+        "Host": "support.euserv.com",
+        "origin": "https://support.euserv.com",
+        "Referer": "https://support.euserv.com/index.iphp",
+    }
+    data = {
+        "Submit": "Extend contract",
+        "sess_id": sess_id,
+        "ord_no": order_id,
+        "subaction": "choose_order",
+        "choose_order_subaction": "show_contract_details",
+    }
+    session.post(url, headers=headers, data=data)
+
+    # pop up 'Security Check' window, it will trigger 'send PIN' automatically.
+    session.post(
+        url,
+        headers=headers,
+        data={
+            "sess_id": sess_id,
+            "subaction": "show_kc2_security_password_dialog",
+            "prefix": "kc2_customer_contract_details_extend_contract_",
+            "type": "1",
+        },
+    )
+
+    # # trigger 'Send new PIN to your Email-Address' (optional),
+    # new_pin = session.post(url, headers=headers, data={
+    #     "sess_id": sess_id,
+    #     "subaction": "kc2_security_password_send_pin",
+    #     "ident": f"kc2_customer_contract_details_extend_contract_{order_id}"
+    # })
+    # if not json.loads(new_pin.text)["rc"] == "100":
+    #     print("new PIN Not Sended")
+    #     return False
+
+    # sleep WAITING_TIME_OF_PIN seconds waiting for mailparser email parsed PIN
+    time.sleep(WAITING_TIME_OF_PIN)
+    pin = get_pin_from_mailparser(mailparser_dl_url_id)
+    log(f"[MailParser] PIN: {pin}")
+
+    # using PIN instead of password to get token
+    data = {
+        "auth": pin,
+        "sess_id": sess_id,
+        "subaction": "kc2_security_password_get_token",
+        "prefix": "kc2_customer_contract_details_extend_contract_",
+        "type": 1,
+        "ident": f"kc2_customer_contract_details_extend_contract_{order_id}",
+    }
+    f = session.post(url, headers=headers, data=data)
+    f.raise_for_status()
+    if not json.loads(f.text)["rs"] == "success":
+        return False
+    token = json.loads(f.text)["token"]["value"]
+    data = {
+        "sess_id": sess_id,
+        "ord_id": order_id,
+        "subaction": "kc2_customer_contract_details_extend_contract_term",
+        "token": token,
+    }
+    session.post(url, headers=headers, data=data)
+    time.sleep(5)
+    return True
+
+
+def check(sess_id: str, session: requests.session):
+    print("Checking.......")
+    d = get_servers(sess_id, session)
+    flag = True
+    for key, val in d.items():
+        if val:
+            flag = False
+            log("[EUserv] ServerID: %s Renew Failed!" % key)
+
+    if flag:
+        log("[EUserv] ALL Work Done! Enjoy~")
+
+
+# Telegram Bot Push https://core.telegram.org/bots/api#authorizing-your-bot
+def telegram():
+    data = (("chat_id", TG_USER_ID), ("text", "EUserv续费日志\n\n" + desp))
+    response = requests.post(
+        TG_API_HOST + "/bot" + TG_BOT_TOKEN + "/sendMessage", data=data
+    )
+    if response.status_code != 200:
+        print("Telegram Bot 推送失败")
+    else:
+        print("Telegram Bot 推送成功")
+
+
+# Yandex mail notification
+def send_mail_by_yandex(
+    to_email, from_email, subject, text, files, sender_email, sender_password
+):
+    msg = MIMEMultipart()
+    msg["Subject"] = subject
+    msg["From"] = from_email
+    msg["To"] = to_email
+    msg.attach(MIMEText(text, _charset="utf-8"))
+    if files is not None:
+        for file in files:
+            file_name, file_content = file
+            # print(file_name)
+            part = MIMEApplication(file_content)
+            part.add_header(
+                "Content-Disposition", "attachment", filename=("gb18030", "", file_name)
+            )
+            msg.attach(part)
+    s = SMTP_SSL("smtp.yandex.ru", 465)
+    s.login(sender_email, sender_password)
+    try:
+        s.sendmail(msg["From"], msg["To"], msg.as_string())
+    except SMTPDataError as e:
+        raise e
+    finally:
+        s.close()
+
+
+# eMail push
+def email():
+    msg = "EUserv 续费日志\n\n" + desp
+    try:
+        send_mail_by_yandex(
+            RECEIVER_EMAIL, YD_EMAIL, "EUserv 续费日志", msg, None, YD_EMAIL, YD_APP_PWD
+        )
+        print("eMail 推送成功")
+    except requests.exceptions.RequestException as e:
+        print(str(e))
+        print("eMail 推送失败")
+    except SMTPDataError as e1:
+        print(str(e1))
+        print("eMail 推送失败")
+
+
+# Server酱 https://sct.ftqq.com
+def server_chan():
+    data = {
+        "title": "EUserv 续费日志",
+        "desp": desp
+    }
+    response = requests.post(f"https://sctapi.ftqq.com/{SERVER_CHAN_SENDKEY}.send", data=data)
+    if response.status_code != 200:
+        print('Server 酱推送失败')
+    else:
+        print('Server 酱推送成功')
+
+
+if __name__ == "__main__":
+    if not USERNAME or not PASSWORD:
+        log("[EUserv] 你没有添加任何账户")
+        exit(1)
+    user_list = USERNAME.strip().split()
+    passwd_list = PASSWORD.strip().split()
+    mailparser_dl_url_id_list = MAILPARSER_DOWNLOAD_URL_ID.strip().split()
+    if len(user_list) != len(passwd_list):
+        log("[EUserv] The number of usernames and passwords do not match!")
+        exit(1)
+    if len(mailparser_dl_url_id_list) != len(user_list):
+        log("[Mailparser] The number of mailparser_dl_url_ids and usernames do not match!")
+        exit(1)
+    for i in range(len(user_list)):
+        print("*" * 30)
+        log("[EUserv] 正在续费第 %d 个账号" % (i + 1))
+        sessid, s = login(user_list[i], passwd_list[i])
+        if sessid == "-1":
+            log("[EUserv] 第 %d 个账号登陆失败,请检查登录信息" % (i + 1))
+            continue
+        SERVERS = get_servers(sessid, s)
+        log("[EUserv] 检测到第 {} 个账号有 {} 台 VPS,正在尝试续期".format(i + 1, len(SERVERS)))
+        for k, v in SERVERS.items():
+            if v:
+                if not renew(sessid, s, passwd_list[i], k, mailparser_dl_url_id_list[i]):
+                    log("[EUserv] ServerID: %s Renew Error!" % k)
+                else:
+                    log("[EUserv] ServerID: %s has been successfully renewed!" % k)
+            else:
+                log("[EUserv] ServerID: %s does not need to be renewed" % k)
+        time.sleep(15)
+        check(sessid, s)
+        time.sleep(5)
+
+    TG_BOT_TOKEN and TG_USER_ID and TG_API_HOST and telegram()
+    RECEIVER_EMAIL and YD_EMAIL and YD_APP_PWD and email()
+    SERVER_CHAN_SENDKEY and server_chan()
+
+    print("*" * 30)

+ 4 - 0
serverless_function/README.md

@@ -0,0 +1,4 @@
+## Variant for serverless function 
+
+The entry is `main_handler`, and these two dependencies `requests` and `beautifulsoup4` need to be packaged (Compress into .zip file) together with the source code `main.py`, then deploy.
+

+ 553 - 0
serverless_function/main.py

@@ -0,0 +1,553 @@
+#!/usr/bin/env python3
+
+#
+# SPDX-FileCopyrightText: (c) 2020-2021 CokeMine & Its repository contributors
+# SPDX-FileCopyrightText: (c) 2021 A beam of light
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+
+"""
+euserv auto-renew script
+
+ChangeLog
+
+v2021.09.30
+- Captcha automatic recognition using TrueCaptcha API
+- Email notification
+- Add login failure retry mechanism
+- reformat log info
+
+v2021.11.06
+- Receive renew PIN(6-digits) using mailparser parsed data download url
+  workflow: auto-forward your EUserv PIN email to your mailparser inbox 
+  -> parsing PIN via mailparser -> get PIN from mailparser
+- Update kc2_security_password_get_token request
+
+v2021.11.26
+- Adjust TrueCaptcha constraint parameters for high availability.
+  Plus, the CAPTCHA of EUserv is currently case-insensitive, so the above adjustment works.
+
+"""
+
+import os
+import re
+import json
+import time
+import base64
+
+from email.mime.application import MIMEApplication
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+from smtplib import SMTP_SSL, SMTPDataError
+
+import requests
+from bs4 import BeautifulSoup
+
+# 多个账户请使用空格隔开
+USERNAME = os.environ["USERNAME"]  # 用户名或邮箱
+PASSWORD = os.environ["PASSWORD"]  # 密码
+
+# default value is TrueCaptcha demo credential,
+# you can use your own credential via set environment variables:
+# TRUECAPTCHA_USERID and TRUECAPTCHA_APIKEY
+# demo: https://apitruecaptcha.org/demo
+# demo2: https://apitruecaptcha.org/demo2
+# demo apikey also has a limit of 100 times per day
+# {
+# 'error': '101.0 above free usage limit 100 per day and no balance',
+# 'requestId': '7690c065-70e0-4757-839b-5fd8381e65c7'
+# }
+TRUECAPTCHA_USERID = os.environ.get("TRUECAPTCHA_USERID", "arun56")
+TRUECAPTCHA_APIKEY = os.environ.get("TRUECAPTCHA_APIKEY", "wMjXmBIcHcdYqO2RrsVN")
+
+# Extract key data from your emails, automatically. https://mailparser.io 
+# 30 Emails/Month, 10 inboxes and unlimited downloads for free.
+# 多个mailparser下载链接id请使用空格隔开, 顺序与 EUserv 账号/邮箱一一对应
+MAILPARSER_DOWNLOAD_URL_ID = os.environ["MAILPARSER_DOWNLOAD_URL_ID"]
+# mailparser.io parsed data download base url
+MAILPARSER_DOWNLOAD_BASE_URL = "https://files.mailparser.io/d/"
+
+# Telegram Bot Push https://core.telegram.org/bots/api#authorizing-your-bot
+TG_BOT_TOKEN = ""  # 通过 @BotFather 申请获得,示例:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw
+TG_USER_ID = ""  # 用户、群组或频道 ID,示例:129xxx206
+TG_API_HOST = "https://api.telegram.org"  # 自建 API 反代地址,供网络环境无法访问时使用,网络正常则保持默认
+
+# Email notification
+RECEIVER_EMAIL = os.environ.get("RECEIVER_EMAIL", "")
+YD_EMAIL = os.environ.get("YD_EMAIL", "")
+YD_APP_PWD = os.environ.get("YD_APP_PWD", "")  # yandex mail 使用第三方 APP 授权码
+
+# Server 酱(ServerChan) https://sct.ftqq.com
+# 免费额度: 每天最多发送 5 条, 卡片仅显示标题, 每天 API 最大请求 1000 次, 每分钟最多发送 5 条.
+SERVER_CHAN_SENDKEY = os.environ.get("SERVER_CHAN_SENDKEY", "")  # Server 酱的 SENDKEY,无需推送可忽略
+
+# Magic internet access
+PROXIES = {"http": "http://127.0.0.1:10808", "https": "http://127.0.0.1:10808"}
+
+# Maximum number of login retry
+LOGIN_MAX_RETRY_COUNT = 5
+
+# Waiting time of receiving PIN, units are seconds.
+WAITING_TIME_OF_PIN = 15
+
+# options: True or False
+CHECK_CAPTCHA_SOLVER_USAGE = True
+
+user_agent = (
+    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
+    "Chrome/95.0.4638.69 Safari/537.36"
+)
+
+desp = ""  # 空值
+
+
+def log(info: str):
+    print(info)
+    global desp
+    desp = desp + info + "\n\n"
+
+
+def login_retry(*args, **kwargs):
+    def wrapper(func):
+        def inner(username, password):
+            ret, ret_session = func(username, password)
+            max_retry = kwargs.get("max_retry")
+            # default retry 3 times
+            if not max_retry:
+                max_retry = 3
+            number = 0
+            if ret == "-1":
+                while number < max_retry:
+                    number += 1
+                    if number > 1:
+                        ordinal = lambda n: "{}{}".format(n,"tsnrhtdd"[(n/10%10!=1)*(n%10<4)*n%10::4])
+                        log(f"[EUserv] Login tried the {ordinal(number)} time.")
+                    sess_id, session = func(username, password)
+                    if sess_id != "-1":
+                        return sess_id, session
+                    else:
+                        if number == max_retry:
+                            return sess_id, session
+            else:
+                return ret, ret_session
+
+        return inner
+
+    return wrapper
+
+
+def captcha_solver(captcha_image_url: str, session: requests.session) -> dict:
+    """
+    TrueCaptcha API doc: https://apitruecaptcha.org/api
+    Free to use 100 requests per day.
+    -- response::
+    {
+        "result": "", ==> Or "result": 0
+        "conf": 0.85, 
+        "usage": 0, 
+        "requestId": "ed0006e5-69f0-4617-b698-97dc054f9022", 
+        "version": "dev2"
+    }
+    """
+    response = session.get(captcha_image_url)
+    encoded_string = base64.b64encode(response.content)
+    url = "https://api.apitruecaptcha.org/one/gettext"
+
+    # Since "case": "mixed", "mode": "human" 
+    # can sometimes cause internal errors in the truecaptcha server. 
+    # So a more relaxed constraint(lower/upper & default) is used here.
+    # Plus, the CAPTCHA of EUserv is currently case-insensitive, so the below adjustment works.
+    data = {
+        "userid": TRUECAPTCHA_USERID,
+        "apikey": TRUECAPTCHA_APIKEY,
+        # case sensitivity of text (upper | lower| mixed)
+        "case": "lower",
+        # use human or AI (human | default)
+        "mode": "default",
+        "data": str(encoded_string)[2:-1],
+    }
+    r = requests.post(url=url, json=data)
+    j = json.loads(r.text)
+    return j
+
+
+def handle_captcha_solved_result(solved: dict) -> str:
+    """Since CAPTCHA sometimes appears as a very simple binary arithmetic expression.
+    But since recognition sometimes doesn't show the result of the calculation directly,
+    that's what this function is for.
+    """
+    if "result" in solved:
+        solved_result = solved["result"]
+        if isinstance(solved_result, str):
+            if "RESULT  IS" in solved_result:
+                log("[Captcha Solver] You are using the demo apikey.")
+                print("There is no guarantee that demo apikey will work in the future!")
+                # because using demo apikey
+                text = re.findall(r"RESULT  IS . (.*) .", solved_result)[0]
+            else:
+                # using your own apikey
+                log("[Captcha Solver] You are using your own apikey.")
+                text = solved_result
+            operators = ["X", "x", "+", "-"]
+            if any(x in text for x in operators):
+                for operator in operators:
+                    operator_pos = text.find(operator)
+                    if operator == "x" or operator == "X":
+                        operator = "*"
+                    if operator_pos != -1:
+                        left_part = text[:operator_pos]
+                        right_part = text[operator_pos + 1 :]
+                        if left_part.isdigit() and right_part.isdigit():
+                            return eval(
+                                "{left} {operator} {right}".format(
+                                    left=left_part, operator=operator, right=right_part
+                                )
+                            )
+                        else:
+                            # Because these symbols("X", "x", "+", "-") do not appear at the same time,
+                            # it just contains an arithmetic symbol.
+                            return text
+            else:
+                return text
+        else:
+            print(f"[Captcha Solver] Returned JSON: {solved}")
+            log("[Captcha Solver] Service Exception!")
+            raise ValueError("[Captcha Solver] Service Exception!")
+    else:
+        print(f"[Captcha Solver] Returned JSON: {solved}")
+        log("[Captcha Solver] Failed to find parsed results!")
+        raise KeyError("[Captcha Solver] Failed to find parsed results!")
+
+
+def get_captcha_solver_usage() -> dict:
+    url = "https://api.apitruecaptcha.org/one/getusage"
+
+    params = {
+        "username": TRUECAPTCHA_USERID,
+        "apikey": TRUECAPTCHA_APIKEY,
+    }
+    r = requests.get(url=url, params=params)
+    j = json.loads(r.text)
+    return j
+
+
+def get_pin_from_mailparser(url_id: str) -> str:
+    """
+    response format:
+    [
+      {
+        "id": "83b95f50f6202fb03950afbe00975eab",
+        "received_at": "2021-11-06 02:30:07",  ==> up to mailparser account timezone setting, here is UTC 0000.
+        "processed_at": "2021-11-06 02:30:07",
+        "pin": "123456"
+      }
+    ]
+    """
+    response = requests.get(
+        f"{MAILPARSER_DOWNLOAD_BASE_URL}{url_id}",
+        # Mailparser parsed data download using Basic Authentication.
+        # auth=("<your mailparser username>", "<your mailparser password>")
+    )
+    pin = response.json()[0]["pin"]
+    return pin
+
+
+@login_retry(max_retry=LOGIN_MAX_RETRY_COUNT)
+def login(username: str, password: str) -> (str, requests.session):
+    headers = {"user-agent": user_agent, "origin": "https://www.euserv.com"}
+    url = "https://support.euserv.com/index.iphp"
+    captcha_image_url = "https://support.euserv.com/securimage_show.php"
+    session = requests.Session()
+
+    sess = session.get(url, headers=headers)
+    sess_id = re.findall("PHPSESSID=(\\w{10,100});", str(sess.headers))[0]
+    # visit png
+    logo_png_url = "https://support.euserv.com/pic/logo_small.png"
+    session.get(logo_png_url, headers=headers)
+
+    login_data = {
+        "email": username,
+        "password": password,
+        "form_selected_language": "en",
+        "Submit": "Login",
+        "subaction": "login",
+        "sess_id": sess_id,
+    }
+    f = session.post(url, headers=headers, data=login_data)
+    f.raise_for_status()
+
+    if (
+        f.text.find("Hello") == -1
+        and f.text.find("Confirm or change your customer data here") == -1
+    ):
+        if (
+            f.text.find(
+                "To finish the login process please solve the following captcha."
+            )
+            == -1
+        ):
+            return "-1", session
+        else:
+            log("[Captcha Solver] 进行验证码识别...")
+            solved_result = captcha_solver(captcha_image_url, session)
+            try:
+                captcha_code = handle_captcha_solved_result(solved_result)
+                log("[Captcha Solver] 识别的验证码是: {}".format(captcha_code))
+
+                if CHECK_CAPTCHA_SOLVER_USAGE:
+                    usage = get_captcha_solver_usage()
+                    log(
+                        "[Captcha Solver] current date {0} api usage count: {1}".format(
+                            usage[0]["date"], usage[0]["count"]
+                        )
+                    )
+
+                f2 = session.post(
+                    url,
+                    headers=headers,
+                    data={
+                        "subaction": "login",
+                        "sess_id": sess_id,
+                        "captcha_code": captcha_code,
+                    },
+                )
+                if (
+                    f2.text.find(
+                        "To finish the login process please solve the following captcha."
+                    )
+                    == -1
+                ):
+                    log("[Captcha Solver] 验证通过")
+                    return sess_id, session
+                else:
+                    log("[Captcha Solver] 验证失败")
+                    return "-1", session
+            except (KeyError, ValueError):
+                return "-1", session
+    else:
+        return sess_id, session
+
+
+def get_servers(sess_id: str, session: requests.session) -> {}:
+    d = {}
+    url = "https://support.euserv.com/index.iphp?sess_id=" + sess_id
+    headers = {"user-agent": user_agent, "origin": "https://www.euserv.com"}
+    f = session.get(url=url, headers=headers)
+    f.raise_for_status()
+    soup = BeautifulSoup(f.text, "html.parser")
+    for tr in soup.select(
+        "#kc2_order_customer_orders_tab_content_1 .kc2_order_table.kc2_content_table tr"
+    ):
+        server_id = tr.select(".td-z1-sp1-kc")
+        if not len(server_id) == 1:
+            continue
+        flag = (
+            True
+            if tr.select(".td-z1-sp2-kc .kc2_order_action_container")[0]
+            .get_text()
+            .find("Contract extension possible from")
+            == -1
+            else False
+        )
+        d[server_id[0].get_text()] = flag
+    return d
+
+
+def renew(
+    sess_id: str, session: requests.session, password: str, order_id: str, mailparser_dl_url_id: str
+) -> bool:
+    url = "https://support.euserv.com/index.iphp"
+    headers = {
+        "user-agent": user_agent,
+        "Host": "support.euserv.com",
+        "origin": "https://support.euserv.com",
+        "Referer": "https://support.euserv.com/index.iphp",
+    }
+    data = {
+        "Submit": "Extend contract",
+        "sess_id": sess_id,
+        "ord_no": order_id,
+        "subaction": "choose_order",
+        "choose_order_subaction": "show_contract_details",
+    }
+    session.post(url, headers=headers, data=data)
+
+    # pop up 'Security Check' window, it will trigger 'send PIN' automatically.
+    session.post(
+        url,
+        headers=headers,
+        data={
+            "sess_id": sess_id,
+            "subaction": "show_kc2_security_password_dialog",
+            "prefix": "kc2_customer_contract_details_extend_contract_",
+            "type": "1",
+        },
+    )
+
+    # # trigger 'Send new PIN to your Email-Address' (optional),
+    # new_pin = session.post(url, headers=headers, data={
+    #     "sess_id": sess_id,
+    #     "subaction": "kc2_security_password_send_pin",
+    #     "ident": f"kc2_customer_contract_details_extend_contract_{order_id}"
+    # })
+    # if not json.loads(new_pin.text)["rc"] == "100":
+    #     print("new PIN Not Sended")
+    #     return False
+
+    # sleep WAITING_TIME_OF_PIN seconds waiting for mailparser email parsed PIN
+    time.sleep(WAITING_TIME_OF_PIN)
+    pin = get_pin_from_mailparser(mailparser_dl_url_id)
+    log(f"[MailParser] PIN: {pin}")
+
+    # using PIN instead of password to get token
+    data = {
+        "auth": pin,
+        "sess_id": sess_id,
+        "subaction": "kc2_security_password_get_token",
+        "prefix": "kc2_customer_contract_details_extend_contract_",
+        "type": 1,
+        "ident": f"kc2_customer_contract_details_extend_contract_{order_id}",
+    }
+    f = session.post(url, headers=headers, data=data)
+    f.raise_for_status()
+    if not json.loads(f.text)["rs"] == "success":
+        return False
+    token = json.loads(f.text)["token"]["value"]
+    data = {
+        "sess_id": sess_id,
+        "ord_id": order_id,
+        "subaction": "kc2_customer_contract_details_extend_contract_term",
+        "token": token,
+    }
+    session.post(url, headers=headers, data=data)
+    time.sleep(5)
+    return True
+
+
+def check(sess_id: str, session: requests.session):
+    print("Checking.......")
+    d = get_servers(sess_id, session)
+    flag = True
+    for key, val in d.items():
+        if val:
+            flag = False
+            log("[EUserv] ServerID: %s Renew Failed!" % key)
+
+    if flag:
+        log("[EUserv] ALL Work Done! Enjoy~")
+
+
+# Telegram Bot Push https://core.telegram.org/bots/api#authorizing-your-bot
+def telegram():
+    data = (("chat_id", TG_USER_ID), ("text", "EUserv续费日志\n\n" + desp))
+    response = requests.post(
+        TG_API_HOST + "/bot" + TG_BOT_TOKEN + "/sendMessage", data=data
+    )
+    if response.status_code != 200:
+        print("Telegram Bot 推送失败")
+    else:
+        print("Telegram Bot 推送成功")
+
+
+# Yandex mail notification
+def send_mail_by_yandex(
+    to_email, from_email, subject, text, files, sender_email, sender_password
+):
+    msg = MIMEMultipart()
+    msg["Subject"] = subject
+    msg["From"] = from_email
+    msg["To"] = to_email
+    msg.attach(MIMEText(text, _charset="utf-8"))
+    if files is not None:
+        for file in files:
+            file_name, file_content = file
+            # print(file_name)
+            part = MIMEApplication(file_content)
+            part.add_header(
+                "Content-Disposition", "attachment", filename=("gb18030", "", file_name)
+            )
+            msg.attach(part)
+    s = SMTP_SSL("smtp.yandex.ru", 465)
+    s.login(sender_email, sender_password)
+    try:
+        s.sendmail(msg["From"], msg["To"], msg.as_string())
+    except SMTPDataError as e:
+        raise e
+    finally:
+        s.close()
+
+
+# eMail push
+def email():
+    msg = "EUserv 续费日志\n\n" + desp
+    try:
+        send_mail_by_yandex(
+            RECEIVER_EMAIL, YD_EMAIL, "EUserv 续费日志", msg, None, YD_EMAIL, YD_APP_PWD
+        )
+        print("eMail 推送成功")
+    except requests.exceptions.RequestException as e:
+        print(str(e))
+        print("eMail 推送失败")
+    except SMTPDataError as e1:
+        print(str(e1))
+        print("eMail 推送失败")
+
+
+# Server酱 https://sct.ftqq.com
+def server_chan():
+    data = {
+        "title": "EUserv 续费日志",
+        "desp": desp
+    }
+    response = requests.post(f"https://sctapi.ftqq.com/{SERVER_CHAN_SENDKEY}.send", data=data)
+    if response.status_code != 200:
+        print('Server 酱推送失败')
+    else:
+        print('Server 酱推送成功')
+
+
+def main_handler(event, context):
+    if not USERNAME or not PASSWORD:
+        log("[EUserv] 你没有添加任何账户")
+        exit(1)
+    user_list = USERNAME.strip().split()
+    passwd_list = PASSWORD.strip().split()
+    mailparser_dl_url_id_list = MAILPARSER_DOWNLOAD_URL_ID.strip().split()
+    if len(user_list) != len(passwd_list):
+        log("[EUserv] The number of usernames and passwords do not match!")
+        exit(1)
+    if len(mailparser_dl_url_id_list) != len(user_list):
+        log("[Mailparser] The number of mailparser_dl_url_ids and usernames do not match!")
+        exit(1)
+    for i in range(len(user_list)):
+        print("*" * 30)
+        log("[EUserv] 正在续费第 %d 个账号" % (i + 1))
+        sessid, s = login(user_list[i], passwd_list[i])
+        if sessid == "-1":
+            log("[EUserv] 第 %d 个账号登陆失败,请检查登录信息" % (i + 1))
+            continue
+        SERVERS = get_servers(sessid, s)
+        log("[EUserv] 检测到第 {} 个账号有 {} 台 VPS,正在尝试续期".format(i + 1, len(SERVERS)))
+        for k, v in SERVERS.items():
+            if v:
+                if not renew(sessid, s, passwd_list[i], k, mailparser_dl_url_id_list[i]):
+                    log("[EUserv] ServerID: %s Renew Error!" % k)
+                else:
+                    log("[EUserv] ServerID: %s has been successfully renewed!" % k)
+            else:
+                log("[EUserv] ServerID: %s does not need to be renewed" % k)
+        time.sleep(15)
+        check(sessid, s)
+        time.sleep(5)
+
+    TG_BOT_TOKEN and TG_USER_ID and TG_API_HOST and telegram()
+    RECEIVER_EMAIL and YD_EMAIL and YD_APP_PWD and email()
+    SERVER_CHAN_SENDKEY and server_chan()
+
+    print("*" * 30)
+
+
+# only for debug
+# if __name__ == '__main__':
+#     main_handler(None, None)