[
  {
    "path": ".github/workflows/codeql-analysis.yml",
    "content": "# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# You may wish to alter this file to override the set of languages analyzed,\n# or to provide custom queries or build logic.\n#\n# ******** NOTE ********\n# We have attempted to detect the languages in your repository. Please check\n# the `language` matrix defined below to confirm you have the correct set of\n# supported CodeQL languages.\n#\nname: \"CodeQL\"\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [ main ]\n  schedule:\n    - cron: '25 2 * * 0'\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n    permissions:\n      actions: read\n      contents: read\n      security-events: write\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [ 'python' ]\n        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]\n        # Learn more about CodeQL language support at https://git.io/codeql-language-support\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v2\n\n    # Initializes the CodeQL tools for scanning.\n    - name: Initialize CodeQL\n      uses: github/codeql-action/init@v1\n      with:\n        languages: ${{ matrix.language }}\n        # If you wish to specify custom queries, you can do so here or in a config file.\n        # By default, queries listed here will override any specified in a config file.\n        # Prefix the list here with \"+\" to use these queries and those in the config file.\n        # queries: ./path/to/local/query, your-org/your-repo/queries@main\n\n    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n    # If this step fails, then you should remove it and run the build manually (see below)\n    - name: Autobuild\n      uses: github/codeql-action/autobuild@v1\n\n    # ℹ️ Command-line programs to run using the OS shell.\n    # 📚 https://git.io/JvXDl\n\n    # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines\n    #    and modify them (or add more) to build your code if your project\n    #    uses a compiled language\n\n    #- run: |\n    #   make bootstrap\n    #   make release\n\n    - name: Perform CodeQL Analysis\n      uses: github/codeql-action/analyze@v1\n"
  },
  {
    "path": ".gitignore",
    "content": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\nwheels/\npip-wheel-metadata/\nshare/python-wheels/\n*.egg-info/\n.installed.cfg\n*.egg\nMANIFEST\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.nox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*.cover\n*.py,cover\n.hypothesis/\n.pytest_cache/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\nlocal_settings.py\ndb.sqlite3\ndb.sqlite3-journal\n\n# Flask stuff:\ninstance/\n.webassets-cache\n\n# Scrapy stuff:\n.scrapy\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n# Jupyter Notebook\n.ipynb_checkpoints\n\n# IPython\nprofile_default/\nipython_config.py\n\n# pyenv\n.python-version\n\n# pipenv\n#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.\n#   However, in case of collaboration, if having platform-specific dependencies or dependencies\n#   having no cross-platform support, pipenv may install dependencies that don't work, or not\n#   install all needed dependencies.\n#Pipfile.lock\n\n# PEP 582; used by e.g. github.com/David-OConnor/pyflow\n__pypackages__/\n\n# Celery stuff\ncelerybeat-schedule\ncelerybeat.pid\n\n# SageMath parsed files\n*.sage.py\n\n# Environments\n.env\n.venv\nenv/\nvenv/\nENV/\nenv.bak/\nvenv.bak/\n\n# Spyder project settings\n.spyderproject\n.spyproject\n\n# Rope project settings\n.ropeproject\n\n# mkdocs documentation\n/site\n\n# mypy\n.mypy_cache/\n.dmypy.json\ndmypy.json\n\n# Pyre type checker\n.pyre/\n\n# Other\n.DS_Store\nmain.html\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "Linux.sh",
    "content": "#!/bin/sh\ncd \"$(dirname \"$0\")\"\npython main.py"
  },
  {
    "path": "README.md",
    "content": "<h1 align=\"center\">\nSmart Sniper\n</h1>\n<p align=\"center\">\n\t<a href=\"https://github.com/snipesmarter/smart-sniper\">\n\t<img\n\t\talt=\"GitHub Stars\"\n\t\tsrc=\"https://img.shields.io/github/stars/snipesmarter/smart-sniper?color=%2370a1d2&label=Stars%20%E2%AD%90\"></a>\n    <a href=\"https://discord.gg/2MeaJvrS2p\"><img src=\"https://img.shields.io/discord/840342619329658921?color=%2370a1d2&label=Discord&logo=discord&logoColor=white\"></a>\n</p>\n<span>Created and maintained by Coolkidmacho#0001</span>\n\n<h5><b>Donations are appreciated for testing and further development, they also help me out.</b></h5>\n\n## The most adaptive minecraft username sniper in the industry \n\nSmartSniper is a high tech adaptive sniper. This sniper's autosniping and automatic delay tuning assists in helping you obtain the best username possible!\n\n\n### Join the Discord for live updates, polls, and support: https://discord.gg/KweaD6G97f\n\n## Features\n\n- Autosniping 3 Letters\n- Auto Delay Tuning\n- Gift Card Sniping\n- Intuitive CUI\n- Normal Sniping\n- Automatic Microsoft Authorization\n- Automatic NameMC Claiming\n- Webhook on Success\n\n\n\n> The overseeing design goal for SmartSniper\n> is to make the experience for all users\n> to be as interactive and hands free as possible.\n\nWe hope to make the sniping experience so automated that once you let it run, it will snipe a name without any interaction.\n\n\n# Table of Contents\n\n - [Installation](#installation)\n - [Usage](#usage)\n   * [Starting the program](#starting-the-program)\n   * [Choosing account type](#choosing-account-type)\n     + [MS or GC](#ms-ms-or-gc-g)\n     + [Mojang](#mojang-m)\n   * [Choosing a mode](#choosing-a-mode)\n     + [Autosniping](#autosniping)\n     + [Manual](#manual)\n   * [How to get a bearer token](#how-to-get-a-bearer-token)\n     + [Manually](#manually)\n     + [Getting your bearer token with V](#getting-your-bearer-token-with-v)\n - [NameMC Auto Claimer](#namemc-auto-claimer)\n   * [Setup and Usage](#setup-and-usage)\n - [Development](#development)\n - [License](#license)\n - [Credits](#credits)\n\n\n# Installation\n\nSmartSniper requires [Python v3.8](https://www.python.org/downloads/release/python-3811/) or higher to run.\nIt also helps to install [Git](https://git-scm.com/download/win) for installation of SmartSniper.\n\nInstall the dependencies and start the program.\n\n```sh\ngit clone https://github.com/snipesmarter/smart-sniper.git\ncd smart-sniper\npip install -r requirements.txt\n```\nIf this doesn't work at all, do this for every line in requirements.txt:\n```sh\npip install <name>\n(replace <name> with the name of the import)\n```\n\nYou can replace the first step with just downloading the zipped file of this and extracting. You will, however, need to open CMD/*sh to the folder afterwards.\n\n# Usage\n\n## Starting the program\n\nOpen CMD/*sh in the folder and run this command:\n```sh\npython main.py\n```\n\n## Choosing account type\n\n```sh\nWhat account type?\nEnter g for giftcard snipes\nEnter m for mojang snipes\nEnter ms for microsoft snipes:\n(Choose your option)\n```\n\n### Microsoft (ms) or Giftcard (g)\n```sh\nMicrosoft Account/Giftcard Selected, using Microsoft Sniper\nTo use Microsoft email and password enter e\nTo use Token enter t: (choose your option)\n```\ne - normal authentication with email and password\nt - [Bearer Token](#how-to-get-a-bearer-token)\n```sh\ne\nMicrosoft Email: (your microsoft email)\nPassword: (your microsoft password)\n```\n```sh\nt\nWhat is your bearer token: (your token)\n```\n\n### Mojang (m) [OUTDATED](https://help.minecraft.net/hc/en-us/articles/360050865492-Minecraft-Java-Edition-Account-Migration-FAQ)\n```sh\nAccount Email: (enter your mojang email here)\nPassword:   (enter your password here)\n200\n{clientToken: , accessToken: }\n200\n```\nIf you have security questions applied, you have to answer them\n\n## Choosing a mode\nHere, you will choose autosniper or manual sniping.\n\n### Autosniping\n```sh\nWhat sniper mode? Enter `a` for autosniper and `n` for single name sniping: a\nstarting\nWhat delay:  (enter 0 if you dont know what to do here)\n{'name': 'l1c', 'dropdate': 1620408382}\ndelay tuned\ndelay is now: 0\ndroptime: 1620408382\n```\nNow you are set to autosnipe with your giftcard.\n\n### Manual\n\n```sh\nWhat sniper mode? Enter `a` for autosniper and `n` for single name sniping: n\nwhat name do you want to snipe:  (enter the name you want to snipe)\nwhat delay do you want:  (try 250 at the start)\ndroptime: 1620607024 (this will vary on the name)\nResponse received @ 2021-05-09 17:37:04.086939 with the status 429\nResponse received @ 2021-05-09 17:37:04.105448 with the status 403\nResponse received @ 2021-05-09 17:37:04.123321 with the status 200\n265 inputted delay\n0:00:00.123813\n['00', '123813']\nchangeint 23\ndelay: 265  tuned_delay  288\n```\n\n## How to get a bearer token\n\n### Manually\nTo get your bearer token manually:\n - Sign in to your Minecraft account at minecraft.net\n - open the chrome / firefox dev tools (ctrl + shift + i) or right click and click inspect\n - Go to the \"console\" tab\n - paste the following code into the console:\n```js\nconsole.log(document.cookie.match(/bearer_token=([^;]+)/)?.[1] ?? 'There is no bearer token in your cookies, make sure you are on minecraft.net and that you are logged into your account.')\n```\nCopy the output, this is your bearer token.\n\n[Source][bearer-info]\n\n### Getting your bearer token with V\n\n```\nwarning, if you have generated a token in the past 12 hours dont do it again your token is saved to the token txt file!, click enter to continue...\nNOTE: IF YOU HAVE NOT INSTALLED THE AUTHENTICATION SERVER GO HERE  ( https://github.com/coolkidmacho/McMsAuth ), THIS WILL NOT WORK WITHOUT IT, click enter to continue\nMicrosoft email: (email)\nMicrosoft password: (password)\n\n(your token)\n```\n\n# NameMC Auto Claimer\n\n## Setup and Usage\nIf you plan to use NameMC auto-claimer, you must be using Mojang accounts. This process works on Windows and Linux.\n\nYour first task is to unzip the file called `namemc` after doing that, follow these instructions to the T (run in CMD/*sh):\n\n```sh\ncd namemc\npython setup.py install\n```\nThis is a very important step. After completing this, edit your config.json file to have NameMC autoclaim set to `True`.\n\nThanks to Cypheriel#3837 for the original code, this could not be done without him. Check him out here: [GitHub](https://github.com/Cypheriel) \n\n# Resources\n\n\nSmart Sniper utilizes public APIs and software made by me [coolkidmacho] and others.\n\n - Kqzz's API\n   - Used to determine drop times.\n   - [https://github.com/Kqzz/MC-API](https://github.com/Kqzz/MC-API)\n - PyCraft\n   - Used to help auto-claim NameMC profiles.\n   - [https://github.com/ammaraskar/pyCraft](https://github.com/ammaraskar/pyCraft)\n - Zodiac API\n   - alternative droptime api\n   - https://github.com/0yq\n - NameMC\n   - used for search-based and 3char sniping\n   - https://namemc.com\n\n# Useful Programs\n\nThe programs listed here are helpful, but not required.\n\n - Dimension 4\n   - Used to sync time with world time servers (NTP).\n   - [http://www.thinkman.com/dimension4/download.htm](http://www.thinkman.com/dimension4/download.htm)\n\n# Development\n\nWant to contribute? Great!\n\nContribute to our GitHub at [https://github.com/snipesmarter/smart-sniper/](https://github.com/snipesmarter/smart-sniper/).\n\nHere are some suggested contributions:\n - Work on issues!\n   - Fix bugs, determine invalid or valid, get info.\n - Vanity edits!\n   - Things like tidying the README, cleaning code, etc.\n\nNote that you don't have to do one something from this list, it's just some ideas.\n\n# License\n\nSmartSniper is licensed under the GNU General Public License v3.0.\n\nYou may:\n - Commercially use this software.\n   - Make sure to disclose source upon request if done.\n - Modify and redistribute.\n   - Disclose modifications and keep the license the same.\n - Patent and private use.\n\nHead to /LICENSE for full license information.\n\n# Credits\n\nThanks to [coolkidmacho] for:\n - maintaining this repo\n - lots of code\n\nThanks to [Kqzz] for:\n - helping a lot with this project\n - code snippets from [MCsniperPY](https://github.com/MCsniperPY) for Mojang authentication\n\nThanks to [Cypheriel](https://github.com/Cypheriel) for:\n - NameMC automatic claim script\n\nThanks to [MohanadHosny] for:\n - Microsoft authentication code (specifically `msauth.py`).\n   - found at https://github.com/MohanadHosny/Microsoft-Minecraft-Auth\n\nThanks to [chrommie] and [kenny] for:\n - `main.py` updates\n   - prompt tidying\n\nThanks to [chrommie] for:\n - `main.py` updates\n   - type declarations\n  \nThanks to [peet] for:\n  - NameMc scraping script\n  - `main.py` tidying\n\nThanks to [surprise] for:\n  - updated bearer grabber script\n  - `main.py` tidying\n\nThanks to [coolkidmacho], [overestimate], [TanujKS], and [Kqzz] for:\n - this README and it's contents\n\nThanks to [MatrixCodeDE] for:\n - `main.py` updates\n   - cross platform optimisation\n   - Name Checking for auto 3 char\n   - optional scraper usage\n - `scraper.py` updates\n   - droptime including\n\nThanks to issue submitters, issue commenters, stargazers, and anyone missed here for:\n - making this project grow\n - helping to find and fix bugs\n\n   [coolkidmacho]: <https://github.com/coolkidmacho>\n   [Kqzz]: <https://github.com/Kqzz>\n   [MohanadHosny]: <https://github.com/MohanadHosny>\n   [chrommie]: <https://github.com/chrommie>\n   [peet]: <https://github.com/wwhtrbbtt>\n   [surprise]: <https://github.com/surprise>\n   [overestimate]: <https://github.com/overestimate>\n   [TanujKS]: <https://github.com/TanujKS>\n   [kenny]: <https://github.com/cyberseckenny>\n   [MCsniperPY]: <https://mcsniperpy.com/>\n   [bearer-info]: <https://kqzz.github.io/mc-bearer-token/>\n   [MatrixCodeDE]: <https://github.com/MatrixCodeDE>\n\nKeywords\nMinecraft Api, Minecraft Username, Python, Requests, Smart Sniper\n"
  },
  {
    "path": "Windows.bat",
    "content": "cd /D \"%~dp0\"\npython main.py"
  },
  {
    "path": "account.txt",
    "content": "--Microsoft/GC--\nEmail: \nPassword: \n\n--Mojang--\nEmail: \nPassword: \n\n--Manual--\nBearer: "
  },
  {
    "path": "config.json",
    "content": "{\n  \"namemc\": \"False\",\n  \"msauth\": \"True\",\n  \"scraper\": \"False\",\n  \"webhook\": \"\",\n  \"searches\": 100\n}"
  },
  {
    "path": "macOS.command",
    "content": "#!/bin/sh\ncd \"$(dirname \"$0\")\"\npython3 main.py"
  },
  {
    "path": "main.py",
    "content": "import argparse\nimport asyncio\nimport json\nimport os\nimport time\nimport urllib.request\nimport pwinput\nimport traceback\nfrom datetime import datetime, timezone\n\nimport aiohttp\nimport requests\nfrom colorama import Fore, Style, init\n\nfrom msauth import PreAuthResponse, login\nimport scraper\n\nif os.name == \"nt\":\n    init(convert=True, autoreset=True)\nelse:\n    init(convert=False, autoreset=True)\n\ncl = False\nif cl:\n    os.system(\"cls\" if os.name == \"nt\" else \"clear\")\nlogo = rf\"\"\"{Fore.GREEN}\n  __  __ __  __  ___ _____    __  __  _ _ ___ ___ ___\n/' _/|  V  |/  \\| _ \\_   _| /' _/|  \\| | | _,\\ __| _ \\\n`._`.| \\_/ | /\\ | v / | |   `._`.| | ' | | v_/ _|| v /\n|___/|_| |_|_||_|_|_\\ |_|   |___/|_|\\__|_|_| |___|_|_\\\n\"\"\"\nprint(logo)\nprint(Fore.LIGHTCYAN_EX + Style.BRIGHT + \"Created by Coolkidmacho#0001\" + Fore.RESET)\nprint(Fore.LIGHTCYAN_EX + \"With the wonderful assistance of \"+ Style.BRIGHT + \"Kqzz#0606\" + Style.NORMAL + \" and \" + Style.BRIGHT + \"MatrixGraphicz#7585\" + Fore.RESET)\nprint(f\"{Fore.MAGENTA}Make sure to join https://discord.gg/KweaD6G97f\\n\")\nprint(\n    f\"{Style.BRIGHT}{Fore.YELLOW}If you want to boost or donate message Coolkidmacho#0001 on discord\"\n)\n# print(f\"{Style.DIM}This file is fully editable and changable, but all changes must be open source, changing the logo or the credits are against the request of the owner.\")\nend = []\norgdel = 0\nglobal delay\ndelay = 0\nglobal changeversion\nchangeversion = \"\"\nglobal tuned_delay\ntuned_delay = None\nglobal success\nsuccess = False\nreqnum = 3\nglobal mcsauth\nmcsauth = \"\"\nglobal scraperset\nscraperset = \"\"\nglobal webhook\nautoskin = True\naccount = []\nglobal ms_email\nms_email = \"\"\nglobal ms_pw\nms_pw = \"\"\nglobal m_email\nm_email = \"\"\nglobal m_pw\nm_pw = \"\"\nglobal manual_bearer\nmanual_bearer = \"\"\nglobal logger\nlogger = []\n\ncodes = {\n    \"mainset\": [\n        {\n            \"ms\": \"Microsoft\",\n            \"m\": \"Mojang\",\n            \"g\": \"Giftcard\"\n        }\n    ],\n    \"style\": [\n        {\n            \"a\": \"Autosniper\",\n            \"n\": \"Single Snipe\",\n            \"s\": \"Show next\"\n        }\n    ]\n}\n\nraw_account = open(\"account.txt\", \"r\")\naccount = raw_account.readlines()\nraw_account.close()\n\nline = 0\nfor x in account:\n    account[line] = account[line].replace(\"\\n\", \"\")\n    account[line] = account[line].replace(\"Email:\", \"\")\n    account[line] = account[line].replace(\"Password:\", \"\")\n    account[line] = account[line].replace(\"Bearer:\", \"\")\n    account[line] = account[line].replace(\" \", \"\")\n    line = line + 1\n\nms_email = account[1]\nms_pw = account[2]\nm_email = account[5]\nm_pw = account[6]\nmanual_bearer = account[9]\n\n\ndef inp(text):\n    print(f\"{Fore.YELLOW}{text}\", end=\"\")\n    ret = input(\"\")\n    return ret\n\n\ndef update():\n    c = requests.get(\n        \"https://raw.githubusercontent.com/snipesmarter/smart-sniper/main/config.json\"\n    )\n    file = open(\"config.json\", \"w\")\n    file.write(json.dumps(c.json(), indent=2))\n    file.close()\n    urllib.request.urlretrieve(\n        \"https://raw.githubusercontent.com/snipesmarter/smart-sniper/main/skin.png\",\n        \"skin.png\",\n    )\n\n\n# update()\n\n\ndef get_config_data():\n    with open(\"config.json\") as e:\n        menu = json.loads(e.read())\n        # print(menu)\n        global namemc\n        namemc = menu[\"namemc\"]\n        global msauth\n        msauth = menu[\"msauth\"]\n        global scraperset\n        scraperset = menu[\"scraper\"]\n        global webhook\n        webhook = menu[\"webhook\"]\n        if webhook == \"\":\n            webhook = None\n        global searches\n        searches = menu[\"searches\"]\n        if scraperset == \"False\":\n            scraperset = False\n        elif scraperset == \"True\":\n            scraperset = True\n\n\n\n\ndef autonamemc(email, password):\n    return\n    cwd = os.getcwd()\n    os.chdir(f\"{cwd}\\\\namemc\")\n    # os.system(\"python setup.py install\")\n    os.system(f\"python start.py -u {email} -p {password}\")\n\n\ndef changeskin(bearer):\n    # print(bearer, \"this\")\n    headers = {\"Authorization\": \"Bearer \" + bearer}\n    files = {\n        \"variant\": (None, \"classic\"),\n        \"file\": (\"skin.png\", open(\"skin.png\", \"rb\")),\n    }\n    response = requests.post(\n        \"https://api.minecraftservices.com/minecraft/profile/skins\",\n        headers=headers,\n        files=files,\n    )\n    time.sleep(1)\n    if response.status_code == 200 or response.status_code == 204:\n        print(f\"{Fore.GREEN}Successfully changed skin!\")\n    else:\n        print(f\"{Fore.RED}Failed to change skin.\")\n\n\ndef store(droptime: int, offset: int) -> None:  # Dodgy timing script!\n    print(offset, \": Delay Used\")\n    stamp = end[-1]\n    datetime_time = datetime.fromtimestamp(droptime)\n    finaldel = str(stamp - datetime_time).split(\":\")[2].split(\".\")\n\n    print(finaldel)\n    if int(finaldel[0]) != 0:\n        changeversion = \"inc\"\n        tuned_delay = delay\n\n        print(\n            f\"\"\"{Fore.LIGHTRED_EX}Cannot tune your delay, please sync your time\\n\n            using http://www.thinkman.com/dimension4/download.htm\n            \\nprogram will continue, if it fails again please restart after \\n\n            installing dimension4 and also set the delay to 0 for that{Fore.RESET}, also you can get this issue if you set your delay to 0\"\"\"\n        )\n\n    else:\n        change = finaldel[1]\n        change3 = f\"{change[0]}{change[1]}{change[2]}\"\n        if int(change[0]) == 0:\n            changeversion = \"dec\"\n            changeint = 100 - int(f\"{change[1]}{change[2]}\")\n            print(\"Change Delay:\", changeint)\n        else:\n            changeversion = \"inc\"\n            changeint = int(change3) - 100\n            print(\"Change Delay:\", changeint)\n\n        if changeversion == \"dec\":\n            tuned_delay = int(offset) - int(changeint)\n        if changeversion == \"inc\":\n            tuned_delay = int(offset) + int(changeint)\n        print(\n            f\"{Fore.CYAN}Delay:{Fore.RESET} {offset}  {Fore.LIGHTGREEN_EX}Tuned Delay:{Fore.RESET}  {tuned_delay}\"\n        )\n\n\ndef custom(email, password, token, name):\n    if success == True:\n        try:\n            if webhook != None:\n                snipedtime = datetime.now(timezone.utc).strftime(\n                    \"%Y-%m-%dT%H:%M:%S.%f%Z\"\n                )\n\n                webhookjson = {\n                    \"content\": \"\",\n                    \"embeds\": [\n                        {\n                            \"title\": f\"You sniped {name}\",\n                            \"description\": f\"Congratulations on your new snipe!\\nYou sniped {name.upper()}! \\nYou sniped {name} at exactly {snipedtime}\",\n                            \"color\": 5814783,\n                            \"footer\": {\"text\": \"Sniper Made by Coolkidmacho#0001\"},\n                        }\n                    ],\n                    \"username\": \"Smart Sniper\",\n                    \"avatar_url\": \"https://cdn.discordapp.com/icons/840342619329658921/a_d3e87d7774f9c82b684c3a667e9cf23e.webp?size=128\",\n                }\n                requests.post(webhook, json=webhookjson)\n        except:\n            print(f\"{Fore.RED}Failed to send webhook!\")\n        try:\n            changeskin(token)\n        except:\n            print(f\"{Fore.RED}Failed to send change skin!\")\n        print(\n            \"{Fore.GREEN}Congrats!\\n{Fore.LIGHTGREEN_EX}You successfully sniped {Fore.GREEN}{name}{Fore.LIGHTGREEN_EX} at {Fore.GREEN}{snipedtime}{Fore.LIGHTGREEN_EX}!\"\n        )\n        if namemc == \"True\":\n            autonamemc(email, password)\n        exit()\n\nthreeapi = None\nstarapi = None\nccapi = None\n\n\nasync def check_connections():\n    global scraperset\n    print()\n    print(f\"\\r{Fore.YELLOW}Testing connections: [________] 0%\", end=\"\\r\")\n\n    try:  # Internet\n        requests.get(\"https://google.com\", timeout=5)\n        print(f\"\\r{Fore.YELLOW}Testing connections: [██______] 25%\", end=\"\\r\")\n    except:\n        print(f\"\\r{Fore.RED}Testing connections: [________] 0% \")\n        print()\n        print(f\"{Fore.RED}Make sure your computer is connected to the internet!\")\n        exit()\n    try: # 3C API\n        global threeapi\n        threeapi = False\n        req = requests.get(\"http://minecraftservicess.com/\", headers = {\"Content-type\": \"application/json\", \"User-Agent\": \"Sniper\"}, timeout=5)\n        if req.status_code == 404:\n            raise Exception\n        threeapi = True\n    except:\n        pass\n    finally:\n        print(f\"\\r{Fore.YELLOW}Testing connections: [████____] 50%\", end=\"\\r\")\n    try:  # Star.shopping API\n        global starapi\n        starapi = False\n        req = requests.get(\"http://api.star.shopping/droptime/abc\", headers = {\"Content-type\": \"application/json\", \"User-Agent\": \"Sniper\"}, timeout=5)\n        if req.status_code == 503:\n            raise Exception\n        starapi = True\n    except:\n        pass\n    finally:\n        print(f\"\\r{Fore.YELLOW}Testing connections: [██████__] 75%\", end=\"\\r\")\n    try:  # Droptime.cc API\n        global ccapi\n        ccapi = False\n        req = requests.get(\"http://api.droptime.cc/droptime/abc\", timeout=5)\n        if req.status_code != 200:\n            raise Exception\n        ccapi = True\n    except:\n        pass\n    finally:\n        print(f\"\\r{Fore.YELLOW}Testing connections: [████████] 100%\")\n        print()\n        print(f\"{Fore.YELLOW}3Char API: {threeapi} | Star API: {starapi} | CC API: {ccapi}\")\n        print()\n        if threeapi == False and starapi == False and ccapi == False and scraperset == False:\n            print(f\"{Fore.LIGHTRED_EX}Can't reach any droptime API!\")\n            if scraper.check_scraper() == True:\n                scraperset = True\n                print(f\"{Fore.LIGHTYELLOW_EX}Forcing scraper...\")\n            else:\n                print(f\"{Fore.RED}Can't use scraper in your country!\")\n                print(f\"{Fore.RED}Quitting...\")\n                exit()\n        elif threeapi == False and scraperset == False:\n            if scraper.check_scraper() == True:\n                scraperset = True\n            else:\n                print(f\"{Fore.LIGHTRED_EX}Autosniping and searchbased sniping are currently unavailable!\")\n            \n            print()\n        if scraperset == True:\n            if scraper.check_scraper() == True:\n                print(f\"{Fore.GREEN}Successfully activated scraper\")\n            else:\n                scraperset = False\n                print(f\"{Fore.RED}Warning! It seems that the scraper doesn't work in your region!\")\n                print(f\"{Fore.RED}Deactivating scraper...\")\n                if threeapi == False and starapi == False and ccapi == False:\n                    print(f\"{Fore.RED}The sniper has no way to get the droptime!\")\n                    print(f\"{Fore.YELLOW}If you know a public API that gets the droptime of names\\nyou can report this to a support channel:\\nhttps://discord.gg/KweaD6G97f\")\n                    print(f\"{Fore.RED}Shutting down sniper\")\n                    exit()\n        print()\n        \n\n\nasync def send_request(s: aiohttp.ClientSession, bearer: str, name: str) -> None:\n    headers = {\"Content-type\": \"application/json\", \"Authorization\": \"Bearer \" + bearer}\n\n    json = {\"profileName\": name}\n\n    async with s.post(\n        \"https://api.minecraftservices.com/minecraft/profile\",\n        json=json,\n        headers=headers,\n    ) as r:\n        print(\n            f\"{Fore.LIGHTRED_EX if r.status != 200 else Fore.LIGHTGREEN_EX}Response received @ {datetime.now()}{Fore.RESET} {Fore.LIGHTRED_EX if r.status != 200 else Fore.LIGHTGREEN_EX} with the status {r.status}{Fore.RESET}\"\n        )\n        end.append(datetime.now())\n        if r.status == 200:\n            print(f\"{Fore.GREEN}C\")\n            global success\n            success = True\n\n\nasync def get_droptime(username: str, session: aiohttp.ClientSession) -> int:\n    try:\n        r = requests.get(f\"https://api.star.shopping/droptime/{username}\", headers = {\"Content-type\": \"application/json\", \"User-Agent\": \"Sniper\"})\n        r_json = r.json()\n        droptime = int(float(r_json[\"unix\"]))\n        return droptime\n    except:\n        try:\n            r2 = requests.get(f\"https://buxflip.com/data/droptime/{username}\", headers = {\"Content-type\": \"application/json\", \"User-Agent\": \"Sniper\"})\n            r_json = r2.json()[\"data\"]\n            droptime = int(float(r_json[\"droptime\"]))\n            return droptime\n        except:\n            try:\n                r3 = requests.get(f\"http://api.droptime.cc/droptime/{username}\")\n                r_json = r3.json()\n                droptime = int(float(r_json[\"unix\"]))\n                return droptime\n            except:\n                try:\n                    if scraperset == False:\n                        raise Exception\n                    res = scraper.getNameInfo(username)\n                    return res[\"droptime\"]\n                except:\n                    prevOwner = inp(\n                        f\"What is the current username of the account that owned {username} before this?:   \"\n                    )\n                    try:\n                        droptime = scraper.prevOwnerDroptime(prevOwner)\n                    except:\n                        droptime = None\n                    if droptime != None:\n                        return droptime\n                    else:\n                        print(f\"{Fore.LIGHTRED_EX}Droptime for name not found, make sure you entered the details into the field correctly!{Fore.RESET}\")\n                        exit()\n\n\nasync def get_scaper_drop(username: str) -> int:\n    nameinfo = scraper.getNameInfo(username)\n    drop = nameinfo[\"droptime\"]\n    return drop\n\n\nasync def get_profile_information(bearer: str, attr: str) -> str:\n    async with aiohttp.ClientSession() as s:\n        headers = {\n            \"Content-type\": \"application/json\",\n            \"Authorization\": \"Bearer \" + bearer,\n        }\n        async with s.get(\n            f\"https://api.minecraftservices.com/minecraft/profile\",\n            headers=headers,\n        ) as r:\n            try:\n                p_infos = await r.json()\n                return p_infos[attr]\n            except:\n                print(f\"{Fore.RED}Failed to login!\")\n\n\ndef get_next_names(amount: int) -> None:\n    search = 0\n    char = 0\n    sel = inp(\n        f\"{Fore.YELLOW}For search based sniping select {Fore.GREEN}s{Fore.RESET}\\n{Fore.YELLOW}For Auto 3char Enter {Fore.GREEN}3{Fore.RESET}: \"\n    )\n    if sel == \"s\":\n        search = inp(\"How many searches do you want?: \")\n        search = int(search)\n    elif sel == \"3\":\n        char = 3\n    else:\n        print(f\"{Fore.RED}Wrong input, skipping\")\n        return\n    if scraperset:\n        try:\n            names = scraper.getNameDrops(search, char)\n        except Exception as e:\n            print(e)\n            print(f\"{Fore.RED}Failed to use scraper! Report this to a support channel!\")\n            return\n    else:\n        if char == 3:\n            try:\n                raw = requests.get(\"http://minecraftservicess.com/\", headers = {\"Content-type\": \"application/json\", \"User-Agent\": \"Sniper\"}).json()[\"data\"]\n                halfdrops = sorted(raw.items(), key=lambda x:x[1])\n                drops = dict([(k,v) for k,v in halfdrops])\n                dl = list(drops)\n                rn = [[0 for x in range(2)] for y in dl]\n                count = 0\n                for x in dl:\n                    rn[count][0] = x\n                    rn[count][1] = drops[x]/1000\n                    count+=1\n                names = scraper.jsonBuilder(rn)\n            except:\n                print(f\"{Fore.LIGHTRED_EX}API is down...\")\n                return\n        else:\n            try:\n                names = requests.get(f\"http://api.coolkidmacho.com/up/{search}\").json()\n            except:\n                print(f\"{Fore.LIGHTRED_EX}API is down...\")\n                return\n    namecount = 0\n    for nameseg in names:\n        if namecount <= amount:\n            name = nameseg[\"name\"]\n            droptime = int(float(nameseg[\"droptime\"]))\n            droptime = datetime.fromtimestamp(droptime)\n            print(f\"{Fore.LIGHTGREEN_EX}{name}{Fore.LIGHTCYAN_EX} at {droptime}\")\n            namecount = namecount + 1\n        else:\n            return\n\n\n#   Mojang setup and snipe\n\n\nasync def send_mojang_request(\n    s: aiohttp.ClientSession, bearer: str, name: str, num: int\n) -> None:\n    headers = {\"Content-type\": \"application/json\", \"Authorization\": \"Bearer \" + bearer}\n    starttime = time.time()\n    async with s.put(\n        f\"https://api.minecraftservices.com/minecraft/profile/name/{name}\",\n        headers=headers,\n    ) as r:\n        global success\n        success = False\n        endtime = time.time()\n        difftime = float(endtime) - float(starttime)\n        if r.status == 200:\n            print(\n                f\"{Fore.LIGHTCYAN_EX}Response {num} received @ {datetime.now()} with the status {Fore.GREEN}{r.status}\"\n            )\n            success = True\n        else:\n            print(\n                f\"{Fore.LIGHTCYAN_EX}Response {num} received @ {datetime.now()} with the status {Fore.RED}{r.status}\"\n            )\n        print(\n            f\"{num} sent: {datetime.fromtimestamp(starttime)} recieved: {datetime.fromtimestamp(endtime)} difference: {difftime}s\"\n        )\n        end.append(datetime.now())\n\n\nasync def get_mojang_token(email: str, password: str) -> str:\n    # Login code is partially from mcsniperpy thx!\n    questions = []\n\n    async with aiohttp.ClientSession() as session:\n        authenticate_json = {\"username\": email, \"password\": password}\n        headers = {\n            \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0\",\n            \"Content-Type\": \"application/json\",\n        }\n        async with session.post(\n            \"https://authserver.mojang.com/authenticate\",\n            json=authenticate_json,\n            headers=headers,\n        ) as r:\n            # print(r.status)\n            if r.status == 200:\n                resp_json = await r.json()\n                # print(resp_json)\n                auth = {\"Authorization\": \"Bearer: \" + resp_json[\"accessToken\"]}\n                access_token = resp_json[\"accessToken\"]\n                # print(f\"{Fore.LIGHTGREEN_EX}Auth: {auth}\\n\\nAccess Token: {access_token}\")\n            else:\n                print(f\"{Fore.LIGHTRED_EX}INVALID CREDENTIALS{Fore.RESET}\")\n\n        async with session.get(\n            \"https://api.mojang.com/user/security/challenges\", headers=auth\n        ) as r:\n            answers = []\n            if r.status < 300:\n                resp_json = await r.json()\n                if resp_json == []:\n                    async with session.get(\n                        \"https://api.minecraftservices.com/minecraft/profile/namechange\",\n                        headers={\"Authorization\": \"Bearer \" + access_token},\n                    ) as nameChangeResponse:\n                        ncjson = await nameChangeResponse.json()\n                        print(ncjson)\n                        try:\n                            if ncjson[\"nameChangeAllowed\"] is False:\n                                print(\n                                    \"Your Account is not\" \" eligible for a name change!\"\n                                )\n                                exit()\n                            else:\n                                print(\n                                    f\"{Fore.LIGHTGREEN_EX}Logged into your account successfully!{Fore.RESET}\"\n                                )\n                        except Exception:\n                            print(\"logged in correctly\")\n                else:\n                    try:\n                        for x in range(3):\n                            ans = inp({resp_json[x][\"question\"][\"question\"]})\n                            answers.append(\n                                {\"id\": resp_json[x][\"answer\"][\"id\"], \"answer\": ans}\n                            )\n                    except IndexError:\n                        print(\n                            f\"{Fore.LIGHTRED_EX}Please provide answers to the security questions{Fore.RESET}\"\n                        )\n                        return\n                    async with session.post(\n                        \"https://api.mojang.com/user/security/location\",\n                        json=answers,\n                        headers=auth,\n                    ) as r:\n                        if r.status < 300:\n                            print(f\"{Fore.LIGHTGREEN_EX}Logged in{Fore.RESET}\")\n                        else:\n                            print(\n                                f\"{Fore.LIGHTRED_EX}Security Questions answers were incorrect, restart the program!{Fore.RESET}\"\n                            )\n    return access_token\n\n\nasync def mojang_snipe(target: str, offset: int, bearer_token: str, drop: int) -> None:\n    async with aiohttp.ClientSession() as session:\n        if scraperset:\n            if drop == None:\n                droptime = await get_scaper_drop(target)\n                if droptime == None:\n                    droptime = await get_droptime(target, session)\n                    if droptime == None:\n                        print(f\"{Fore.RED}This name isn't dropping!\")\n                        return\n            else:\n                droptime = drop\n        else:\n            if drop == None:\n                droptime = await get_droptime(target, session)\n            else:\n                droptime = drop\n        offset = int(offset)\n        snipe_time = droptime - (offset / 1000)\n        conv_droptime = datetime.fromtimestamp(droptime).strftime(\n            \"%H:%M:%S on %Y-%m-%d\"\n        )\n        print(f\"{Fore.MAGENTA}sniping {target} at {conv_droptime}\")\n        while time.time() < snipe_time - 10:\n            await asyncio.sleep(0.001)\n        if (\n            requests.get(\n                \"https://api.mojang.com/users/profiles/minecraft/\" + target\n            ).status_code\n            == 204\n        ):\n            while time.time() < snipe_time - 0.001:\n                await asyncio.sleep(0.001)\n            coroutines = [\n                send_mojang_request(session, bearer_token, target, x) for x in range(2)\n            ]\n            await asyncio.gather(*coroutines)\n            store(droptime, offset)\n        else:\n            print(f\"{Fore.RED}{target} is no longer dropping. Skipping...\")\n        if success == True:\n            custom(email, password, token, name)\n\n\nasync def autosniper(token: str) -> None:\n    print(f\"{Fore.LIGHTGREEN_EX}Starting...{Fore.RESET}\")\n    searches = 0\n    chars = 0\n    sel = inp(\n        f\"{Fore.YELLOW}For search based sniping select {Fore.GREEN}s{Fore.RESET}\\n{Fore.YELLOW}For Auto 3char Enter {Fore.GREEN}3{Fore.RESET}: \"\n    )\n    logger.append(sel)\n    if sel == \"s\":\n        searches = inp(\"How many searches do you want?: \")\n        searches = int(searches)\n        logger.append(searches)\n    elif sel == \"3\":\n        chars = 3\n    while True:\n        if scraperset:\n            names = scraper.getNameDrops(searches, chars)\n        else:\n            if chars == 0:\n                print(f\"{Fore.RED}No search based API available\")\n                ask = inp(\"Do you want to autosnipe 3chars? Y/N: \")\n                if ask.lower() == \"y\":\n                    chars = 3\n                else:\n                    print(f\"{Fore.RED}Quitting\")\n                    exit()\n            if chars == 0:\n                try:\n                    names = requests.get(f\"https://api.coolkidmacho.com/up/{searches}\").json()\n                except:\n                    print(f\"{Fore.LIGHTRED_EX}API is down, can't use this feature...\")\n                    print(\n                        f\"{Fore.LIGHTRED_EX}You can activate it in config.json by setting\\n\"\n                        f'{Fore.LIGHTRED_EX}\"scraper\": \"True\"'\n                        )\n                    exit()\n            else:\n                try:\n                    raw = requests.get(\"http://minecraftservicess.com/\", headers = {\"Content-type\": \"application/json\", \"User-Agent\": \"Sniper\"}).json()[\"data\"]\n                    halfdrops = sorted(raw.items(), key=lambda x:x[1])\n                    drops = dict([(k,v) for k,v in halfdrops])\n                    dl = list(drops)\n                    rn = [[0 for x in range(2)] for y in dl]\n                    count = 0\n                    for x in dl:\n                        rn[count][0] = x\n                        rn[count][1] = drops[x]/1000\n                        count+=1\n                    names = scraper.jsonBuilder(rn)\n                except:\n                    print(f\"{Fore.LIGHTRED_EX}API is down, can't use this feature...\")\n                    print(\n                        f\"{Fore.LIGHTRED_EX}You can activate it in config.json by setting\\n\"\n                        f'{Fore.LIGHTRED_EX}\"scraper\": \"True\"'\n                        )\n                    exit()\n        #print(names)\n        delay = inp(f\"Delay for snipe:  \")\n        print(tuned_delay, \"tuned delay value\")\n        logger.append(None)\n        logger.append(delay)\n        for nameseg in names:\n            name = nameseg[\"name\"]\n            logger[-2] = name\n            if scraperset:\n                droptime = nameseg[\"droptime\"]\n                namecheck = requests.get(f\"https://api.ashcon.app/mojang/v2/user/{name}\")\n                if namecheck.status_code == 404:\n                    if tuned_delay is None:\n                        print(f\"{Fore.CYAN}Defaulting...{Fore.RESET}\")\n                        pass\n                    else:\n                        delay = tuned_delay\n                        print(f\"{Fore.CYAN}Delay Tuned{Fore.RESET}\")\n                    print(\"delay is now \", delay)\n                    logger[-1] = delay\n                    await mojang_snipe(name, delay, token, droptime)\n            else:\n                try:\n                    droptime = nameseg[\"droptime\"]\n                except:\n                    droptime = None\n                namecheck = requests.get(f\"https://api.ashcon.app/mojang/v2/user/{name}\")\n                if namecheck.status_code == 404:\n                    if tuned_delay is None:\n                        print(f\"{Fore.CYAN}Defaulting...{Fore.RESET}\")\n                        pass\n                    else:\n                        delay = tuned_delay\n                        print(f\"{Fore.CYAN}Delay Tuned{Fore.RESET}\")\n                    print(\"delay is now \", delay)\n                    logger[-1] = delay\n                    await mojang_snipe(name, delay, token, droptime)\n    \n\n\nasync def gather_mojang_info() -> None:\n    email = inp(f\"Account Email:  \")\n    password = pwinput.pwinput(prompt=f\"{Fore.YELLOW}Password: \", mask=\"\")\n    token = await get_mojang_token(email, password)\n    style = inp(\n            f\"{Fore.YELLOW}What sniper mode?\\n\"\n            f\"{Fore.YELLOW}Enter {Fore.GREEN}a{Fore.YELLOW} for autosniper{Fore.RESET}\\n\"\n            f\"{Fore.YELLOW}Enter {Fore.GREEN}n{Fore.YELLOW} for single name sniping {Fore.RESET}\\n\"\n            f\"{Fore.YELLOW}Enter {Fore.GREEN}s{Fore.YELLOW} to show next 3chars: {Fore.RESET}\"\n        )\n    logger.append(style)\n    if style == \"a\":\n        await autosniper(token)\n    elif style == \"n\" or \"s\":\n        if style == \"s\":\n            get_next_names(10)\n        name = inp(f\"Name to snipe:  \")\n        delay = inp(f\"Delay for snipe:  \")\n        logger.append(name)\n        logger.append(delay)\n        tuned_delay = delay\n        await mojang_snipe(name, delay, token, None)\n\nasync def iterate_through_names(session: aiohttp.ClientSession) -> None:\n    while True:\n        async with session.get(\"https://api.3user.xyz/list\") as r:\n            r_json = await r.json()\n            if r.status < 300:\n                for name in r_json:\n                    yield name[\"name\"]\n                await asyncio.sleep(1)\n            else:\n                print(f\"Failed to get names, retrying... | {r.status}\")\n                await asyncio.sleep(10)\n\ndef namechange_eligibility(token):\n    headers = {\n            \"Content-type\": \"application/json\",\n            \"Authorization\": \"Bearer \" + token,\n        }\n    resp = requests.get(\"https://api.minecraftservices.com/minecraft/profile/namechange\", headers=headers)\n    if resp.status_code == 200:\n        resp = resp.json()\n        if resp[\"nameChangeAllowed\"] == False:\n            print(f\"{Fore.RED}You cant change your name yet!\")\n            print(f\"{Fore.RED}Choose another account to snipe!\")\n            exit()\n    else:\n        print(f\"{Fore.RED}Cannot auth you account!\")\n        exit()\n    \n\n\nasync def start() -> None:\n    global scraperset\n    get_config_data()\n    await check_connections()\n    mainset = inp(\n        f\"\\n{Fore.LIGHTBLUE_EX}What account type? \\n\"\n        f\"{Fore.LIGHTBLUE_EX}Enter {Fore.GREEN}g{Fore.RESET}{Fore.LIGHTBLUE_EX} for giftcard snipes \\n\"\n        f\"{Fore.LIGHTBLUE_EX}Enter {Fore.GREEN}m{Fore.RESET} {Fore.LIGHTBLUE_EX}for mojang snipes \\n\"\n        f\"{Fore.LIGHTBLUE_EX}Enter {Fore.GREEN}ms{Fore.RESET} {Fore.LIGHTBLUE_EX}for microsoft snipes: \"\n    )\n    logger.append(mainset)\n    if mainset == \"m\":\n\n        reqnum = 3\n        print(\n            f\"{Fore.LIGHTGREEN_EX}Mojang Account Selected, using Mojang Sniper{Fore.RESET}\"\n        )\n        await gather_mojang_info()\n        return\n    elif mainset == \"ms\" or mainset == \"g\":\n        if mainset == \"ms\":\n            print(f\"{Fore.LIGHTGREEN_EX}Microsoft Account Selected, using Microsoft Sniper{Fore.RESET}\")\n        else:\n            print(f\"{Fore.LIGHTGREEN_EX}Giftcard Selected, using Microsoft Sniper{Fore.RESET}\")\n            \n        autype = inp(\n            f\"To use microsoft email and password auth enter {Fore.GREEN}e{Fore.RESET}\\n{Fore.YELLOW}To use Token enter {Fore.GREEN}t{Fore.RESET}:  \"\n        )\n        if autype.lower() == \"e\":\n            try:\n                if ms_email == \"\" or ms_pw == \"\":\n                    email = inp(f\"Microsoft email: \")\n                    password = pwinput.pwinput(prompt=f\"{Fore.YELLOW}Password: \", mask=\"\")\n                else:\n                    email = ms_email\n                    password = ms_pw\n                resp = login(email, password)\n                \n                token = resp[\"access_token\"]\n                try:\n                    login_name = await get_profile_information(token, \"name\")\n                    print(\n                        f\"{Fore.GREEN}Logged into {Fore.LIGHTCYAN_EX}{Style.BRIGHT}{login_name}\"\n                    )\n                except:\n                    print(f\"{Fore.GREEN}No previous name\")\n            except:\n                print(f\"{Fore.RED}Failed MsAuth for you, use token.\")\n                if manual_bearer == \"\":\n                    token = inp(f\"What is your bearer token:  \")\n                else:\n                    token = manual_bearer\n                try:\n                    login_name = await get_profile_information(token, \"name\")\n                    print(\n                        f\"{Fore.GREEN}Logged into {Fore.LIGHTCYAN_EX}{Style.BRIGHT}{login_name}\"\n                    )\n                except:\n                    print(f\"{Fore.GREEN}No previous name\")\n        elif autype.lower() == \"t\":\n            if manual_bearer == \"\":\n                token = inp(f\"What is your bearer token:  \")\n            else:\n                token = manual_bearer\n            try:\n                login_name = await get_profile_information(token, \"name\")\n                print(\n                    f\"{Fore.GREEN}Logged into {Fore.LIGHTCYAN_EX}{Style.BRIGHT}{login_name}\"\n                )\n            except:\n                print(f\"{Fore.GREEN}No previous name\")\n        else:\n            print(f\"{Fore.RED}You did not select a valid option.\")\n            exit()\n        namechange_eligibility(token)\n        style = inp(\n            f\"{Fore.YELLOW}What sniper mode?\\n\"\n            f\"{Fore.YELLOW}Enter {Fore.GREEN}a{Fore.YELLOW} for autosniper{Fore.RESET}\\n\"\n            f\"{Fore.YELLOW}Enter {Fore.GREEN}n{Fore.YELLOW} for single name sniping {Fore.RESET}\\n\"\n            f\"{Fore.YELLOW}Enter {Fore.GREEN}s{Fore.YELLOW} to show next 3chars: {Fore.RESET}\"\n        )\n        logger.append(style)\n        if style == \"a\":\n            await autosniper(token)\n            return\n        elif style == \"n\" or style == \"s\":\n            if style == \"s\":\n                get_next_names(10)\n            name = inp(f\"Name to snipe:  \")\n            global delay\n            delay = inp(f\"Delay for snipe:  \")\n            global tuned_delay\n            tuned_delay = delay\n            logger.append(None)\n            logger.append(name)\n            logger.append(delay)\n            await (mojang_snipe(name, delay, token, None))\n        else:\n            print(f\"{Fore.RED}Please select a valid option\")\n            inp(f\"Press enter to exit\")\n            exit()\n    else:\n        print(f\"{Fore.RED}You did not enter a proper value. Ending.\")\n        exit()\n\n\nparser = argparse.ArgumentParser()\n\nparser.add_argument(\"-t\", \"--Type\", help=\"Name\")\nparser.add_argument(\"-n\", \"--Name\", help=\"Name\")\nparser.add_argument(\"-d\", \"--Delay\", help=\"Delay\")\nparser.add_argument(\"-e\", \"--Email\", help=\"Email\")\nparser.add_argument(\"-p\", \"--Password\", help=\"Password\")\n\nargs = parser.parse_args()\n# print(vars(args))\nboot = vars(args)\nif boot[\"Type\"] != None:\n    mainset = boot[\"Type\"].replace(\" \", \"\")\n    email = boot[\"Email\"].replace(\" \", \"\")\n    password = boot[\"Password\"].replace(\" \", \"\")\n    delay = boot[\"Delay\"].replace(\" \", \"\")\n    name = boot[\"Name\"].replace(\" \", \"\")\n    if mainset == \"m\":\n        loop = asyncio.get_event_loop()\n        token = loop.run_until_complete(get_mojang_token(email, password))\n    elif mainset == \"ms\" or mainset == \"g\":\n        resp = login(email, password)\n        token = resp[\"access_token\"]\n    asyncio.run(mojang_snipe(name, delay, token, None))\n    \ntry:\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(start())\nexcept Exception as exc:\n    logs = []\n    logs.append(f\"Account: {codes['mainset'][0][logger[0]]}\")\n    logs.append(f\"Type: {codes['style'][0][logger[1]]}\")\n    logs.append(f\"Style: {logger[2]}\")\n    logs.append(f\"Name: {logger[3]}\")\n    logs.append(f\"Delay: {logger[4]}\")\n    logs.append(f\"Scraper: {str(scraperset)}\")\n    logs.append(f\"Check: {str(scraper.check_scraper())}\")\n    print(f\"\\n\\n\\n{Fore.RED}Error! Report a screenshot of the following section in a support channel on Discord!\\n\")\n    print(f\"{Fore.RED}{logs}\\n\")\n    print(f\"{Fore.RED}{traceback.format_exc()}\")\n    print()\n    exit()\n    "
  },
  {
    "path": "msauth.py",
    "content": "from re import search\r\nfrom typing import NamedTuple, Union\r\n\r\nimport requests\r\nfrom requests import Response\r\nfrom requests import Session\r\n\r\nAUTHORIZE = \"https://login.live.com/oauth20_authorize.srf?client_id=000000004C12AE6F&redirect_uri=https://login.live.com/oauth20_desktop.srf&scope=service::user.auth.xboxlive.com::MBI_SSL&display=touch&response_type=token&locale=en\"\r\nXBL = \"https://user.auth.xboxlive.com/user/authenticate\"\r\nXSTS = \"https://xsts.auth.xboxlive.com/xsts/authorize\"\r\n\r\nuserAgent = \"Mozilla/5.0 (XboxReplay; XboxLiveAuth/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36\"\r\n\r\nlogin_with_xbox = \"https://api.minecraftservices.com/authentication/login_with_xbox\"\r\nownership = \"https://api.minecraftservices.com/entitlements/mcstore\"\r\nprofile = \"https://api.minecraftservices.com/minecraft/profile\"\r\n\r\n\r\nclass PreAuthResponse(NamedTuple):\r\n    response: Response\r\n    url_post: str\r\n    ppft: str\r\n\r\n\r\nclass UserLoginResponse(NamedTuple):\r\n    refresh_token: str\r\n    access_token: str\r\n    expires_in: int\r\n    loggedin: bool = False\r\n\r\n\r\nclass XBLAuthenticateResponse(NamedTuple):\r\n    user_hash: str\r\n    token: str\r\n\r\n\r\nclass XSTSAuthenticateResponse(NamedTuple):\r\n    user_hash: str\r\n    token: str\r\n\r\n\r\nclass UserProfile(NamedTuple):\r\n    username: Union[str, None]\r\n    uuid: Union[str, None]\r\n\r\n\r\nclass Microsoft:\r\n    def __init__(self, client: Session = None) -> None:\r\n        self.client = client if client is not None else Session()\r\n\r\n    def xbl_authenticate(self, login_resp: UserLoginResponse) -> XBLAuthenticateResponse:\r\n        headers = {\r\n            \"User-Agent\": userAgent,\r\n            \"Accept\": \"application/json\",\r\n            \"x-xbl-contract-version\": \"0\"\r\n        }\r\n\r\n        payload = {\r\n            \"RelyingParty\": \"http://auth.xboxlive.com\",\r\n            \"TokenType\": \"JWT\",\r\n            \"Properties\": {\r\n                \"AuthMethod\": \"RPS\",\r\n                \"SiteName\": \"user.auth.xboxlive.com\",\r\n                \"RpsTicket\": login_resp.access_token,\r\n            }\r\n        }\r\n\r\n        resp = self.client.post(XBL, json=payload, headers=headers)\r\n\r\n        if resp.status_code != 200:\r\n            raise Exception(\"XBL Authentication failed\")\r\n\r\n        data = resp.json()\r\n\r\n        return XBLAuthenticateResponse(\r\n            token=data[\"Token\"],\r\n            user_hash=data[\"DisplayClaims\"][\"xui\"][0][\"uhs\"]\r\n        )\r\n\r\n    def xsts_authenticate(self, xbl_resp: XBLAuthenticateResponse) -> XSTSAuthenticateResponse:\r\n        headers = {\r\n            \"User-Agent\": userAgent,\r\n            \"Accept\": \"application/json\",\r\n            \"x-xbl-contract-version\": \"1\"\r\n        }\r\n\r\n        payload = {\r\n            \"RelyingParty\": \"rp://api.minecraftservices.com/\",\r\n            \"TokenType\": \"JWT\",\r\n            \"Properties\": {\r\n                \"SandboxId\": \"RETAIL\",\r\n                \"UserTokens\": [\r\n                    xbl_resp.token\r\n                ]\r\n            }\r\n        }\r\n\r\n        resp = self.client.post(XSTS, json=payload, headers=headers)\r\n\r\n        if resp.status_code != 200:\r\n            if resp.status_code == 401:\r\n                json = resp.json()\r\n                if json[\"XErr\"] == \"2148916233\":\r\n                    raise Exception(\"This account doesn't have an Xbox account\")\r\n                elif json[\"XErr\"] == \"2148916238\":\r\n                    raise Exception(\"The account is a child (under 18)\")\r\n                else:\r\n                    raise Exception(f\"Unknown XSTS error code: {json['XErr']}\")\r\n            else:\r\n                raise Exception(\"XSTS Authentication failed\")\r\n\r\n        data = resp.json()\r\n\r\n        return XSTSAuthenticateResponse(\r\n            token=data[\"Token\"],\r\n            user_hash=data[\"DisplayClaims\"][\"xui\"][0][\"uhs\"]\r\n        )\r\n\r\n    def login_with_xbox(self, token: str, user_hash: str) -> str:\r\n        headers = {\r\n            \"Accept\": \"application/json\",\r\n            \"User-Agent\": userAgent\r\n        }\r\n\r\n        payload = {\"identityToken\": f\"XBL3.0 x={user_hash};{token}\"}\r\n\r\n        resp = self.client.post(login_with_xbox, json=payload, headers=headers)\r\n\r\n        if \"access_token\" not in resp.text:\r\n            raise Exception(\"LoginWithXbox Authentication failed\")\r\n\r\n        return resp.json()[\"access_token\"]\r\n\r\n    def user_hash_game(self, access_token: str) -> bool:\r\n        headers = {\r\n            \"Accept\": \"application/json\",\r\n            \"User-Agent\": userAgent,\r\n            \"Authorization\": f\"Bearer {access_token}\"\r\n        }\r\n\r\n        resp = self.client.get(ownership, headers=headers)\r\n\r\n        return len(resp.json()[\"items\"]) > 0\r\n\r\n    def get_user_profile(self, access_token: str) -> UserProfile:\r\n        headers = {\r\n            \"Accept\": \"application/json\",\r\n            \"User-Agent\": userAgent,\r\n            \"Authorization\": f\"Bearer {access_token}\"\r\n        }\r\n\r\n        resp = self.client.get(profile, headers=headers).json()\r\n\r\n        return UserProfile(\r\n            username=resp.get(\"name\"),\r\n            uuid=resp.get(\"id\")\r\n        )\r\n\r\n\r\nclass XboxLive:\r\n    def __init__(self, client: requests.Session = None) -> None:\r\n        self.client = client if client is not None else requests.Session()\r\n\r\n    def pre_auth(self) -> PreAuthResponse:\r\n        resp = self.client.get(AUTHORIZE, headers={\"User-Agent\": userAgent}, allow_redirects=True)\r\n\r\n        ppft = search(r\"value=\\\"(.*?)\\\"\", search(r\"sFTTag:'(.*?)'\", resp.text).group(1)).group(1)\r\n        urlPost = search(r\"urlPost:'(.+?(?=\\'))\", resp.text).group(1)\r\n\r\n        if urlPost is None or ppft is None:\r\n            raise Exception(\"Failed to extract PPFT or urlPost\")\r\n\r\n        return PreAuthResponse(\r\n            response=resp,\r\n            ppft=ppft,\r\n            url_post=urlPost\r\n        )\r\n\r\n    def user_login(self, email: str, password: str, preauth: PreAuthResponse) -> UserLoginResponse:\r\n        postData = f\"login={self.encode(email)}&loginfmt={self.encode(email)}&passwd={self.encode(password)}&PPFT={preauth.ppft}\"\r\n        headers = {\r\n            \"Content-Type\": \"application/x-www-form-urlencoded\",\r\n            \"User-Agent\": userAgent\r\n        }\r\n\r\n        resp = self.client.post(url=preauth.url_post, data=postData, cookies=preauth.response.cookies, headers=headers,\r\n                                allow_redirects=True)\r\n\r\n        if \"access_token\" not in resp.url and resp.url == preauth.url_post:\r\n            if \"Sign in to\" in resp.text:\r\n                raise Exception(\"Invalid credentials.\")\r\n            elif \"Help us protect your account\" in resp.text:\r\n                raise Exception(\"2FA is enabled but not supported yet!\")\r\n            else:\r\n                raise Exception(f\"Something went wrong. Status Code: {resp.status_code}\")\r\n\r\n        data = resp.url.split(\"#\")[1].split(\"&\")\r\n\r\n        return UserLoginResponse(\r\n            refresh_token=data[4].split(\"=\")[1],\r\n            access_token=data[0].split(\"=\")[1],\r\n            expires_in=int(data[2].split(\"=\")[1]),\r\n            loggedin=True\r\n        )\r\n\r\n    def encode(self, data: str) -> str:\r\n        return requests.utils.quote(data)\r\n\r\n\r\ndef login(email: str, password: str) -> Union[dict, str]:\r\n    client = Session()\r\n\r\n    xbx = XboxLive(client)\r\n    mic = Microsoft(client)\r\n\r\n    login = xbx.user_login(email, password, xbx.pre_auth())\r\n\r\n    xbl = mic.xbl_authenticate(login)\r\n    xsts = mic.xsts_authenticate(xbl)\r\n\r\n    access_token = mic.login_with_xbox(xsts.token, xsts.user_hash)\r\n    hasGame = mic.user_hash_game(access_token)\r\n\r\n    if hasGame:\r\n        profile = mic.get_user_profile(access_token)\r\n        data = {\r\n            \"access_token\": access_token,\r\n            \"username\": profile.username,\r\n            \"uuid\": profile.uuid\r\n        }\r\n\r\n        return data\r\n    else:\r\n        return \"Not a premium account\"\r\n\r\n# credits to https://github.com/MohanadHosny/Microsoft-Minecraft-Auth for the original code, this is all thanks to him!\r\n"
  },
  {
    "path": "requirements.txt",
    "content": "aiohttp\nrequests\ncolorama\ntyping\nh2\npwinput\nbs4\npython-dateutil\n"
  },
  {
    "path": "scraper.py",
    "content": "from lib2to3.pgen2 import driver\r\nimport socket\r\nimport ssl\r\nimport certifi\r\nimport os\r\nimport json\r\nimport requests\r\n\r\nimport h2.connection\r\nimport h2.settings\r\nimport h2.events\r\n\r\nfrom colorama import Fore, Style, init\r\n\r\nif os.name == \"nt\":\r\n    init(convert=True, autoreset=True)\r\nelse:\r\n    init(convert=False, autoreset=True)\r\n\r\n# Scraping module\r\nfrom bs4 import BeautifulSoup\r\nfrom datetime import datetime as ddt\r\nimport dateutil.parser\r\n\r\nDEBUG = False\r\nSERVER_NAME = \"namemc.com\"\r\nSERVER_PORT = 443\r\n\r\n\r\ndef get_ssl_connection(name: str, port: int = 443) -> ssl.SSLSocket:\r\n    # generic socket and ssl configuration\r\n    socket.setdefaulttimeout(15)\r\n    ctx = ssl.create_default_context(cafile=certifi.where())\r\n    ctx.set_alpn_protocols([\"h2\"])\r\n\r\n    # open a socket to the server and initiate TLS/SSL\r\n    s = socket.create_connection((SERVER_NAME, SERVER_PORT))\r\n    s = ctx.wrap_socket(s, server_hostname=SERVER_NAME)\r\n    return s\r\n\r\n\r\ndef send_http2_preamble(sock: ssl.SSLSocket):\r\n    sock.send(b\"PRI * HTTP/2.0\\r\\n\\r\\nSM\\r\\n\\r\\n\")\r\n\r\n\r\ndef update_settings(conn: h2.connection.H2Connection, sock: ssl.SSLSocket) -> None:\r\n    conn.update_settings(\r\n        {\r\n            h2.settings.SettingCodes.MAX_CONCURRENT_STREAMS: 65536,\r\n            h2.settings.SettingCodes.INITIAL_WINDOW_SIZE: 65535,\r\n        }\r\n    )\r\n\r\n    sock.sendall(conn.data_to_send())\r\n\r\n\r\ndef send_prio_frames(conn: h2.connection.H2Connection, sock: ssl.SSLSocket) -> None:\r\n    conn.prioritize(3, 201, 0, False)\r\n    conn.prioritize(5, 101, 0, False)\r\n    conn.prioritize(7, 1, 0, False)\r\n    conn.prioritize(9, 7, 0, False)\r\n    conn.prioritize(11, 1, 3, False)\r\n\r\n    sock.sendall(conn.data_to_send())\r\n\r\n\r\ndef send_headers(conn: h2.connection.H2Connection, sock: ssl.SSLSocket, path) -> None:\r\n    headers = [\r\n        (\":method\", \"GET\"),\r\n        (\":path\", f\"/{path}\"),\r\n        (\":scheme\", \"https\"),\r\n        (\":authority\", SERVER_NAME),\r\n        (\"accept\", \"*/*\"),\r\n        (\"user-agent\", \"ThisIsntImportant\"),\r\n    ]\r\n    conn.send_headers(1, headers, end_stream=True)\r\n    sock.sendall(conn.data_to_send())\r\n\r\n\r\ndef receive_data(conn: h2.connection.H2Connection, sock: ssl.SSLSocket) -> str:\r\n    body = b\"\"\r\n    response_stream_ended = False\r\n    while not response_stream_ended:\r\n        # read raw data from the socket\r\n        data = sock.recv(65536 * 1024)\r\n        if not data:\r\n            break\r\n\r\n        # feed raw data into h2, and process resulting events\r\n        events = c.receive_data(data)\r\n        for event in events:\r\n            if DEBUG:\r\n                print(event)\r\n            if isinstance(event, h2.events.DataReceived):\r\n                # update flow control so the server doesn't starve us\r\n                conn.acknowledge_received_data(\r\n                    event.flow_controlled_length, event.stream_id\r\n                )\r\n                # more response body data received\r\n                body += event.data\r\n            if isinstance(event, h2.events.StreamEnded):\r\n                # response body completed, let's exit the loop\r\n                response_stream_ended = True\r\n                break\r\n        # send any pending data to the server\r\n        sock.sendall(conn.data_to_send())\r\n    return body.decode()\r\n\r\n\r\ndef get_data(path):\r\n    global s\r\n    s = get_ssl_connection(SERVER_NAME, SERVER_PORT)\r\n    global c\r\n    c = h2.connection.H2Connection()\r\n\r\n    # send data to look like a valid client\r\n    send_http2_preamble(s)\r\n    update_settings(c, s)\r\n    send_prio_frames(c, s)\r\n    send_headers(c, s, path)\r\n\r\n    # receive data from the server\r\n    body = receive_data(c, s)\r\n    # print(body)\r\n\r\n    # close the h2 connection\r\n    c.close_connection()\r\n    s.sendall(c.data_to_send())\r\n\r\n    # close the socket\r\n    s.close()\r\n    return body\r\n\r\n\r\ndef getNameInfo(username):\r\n    #print(username, \"data received\")\r\n    # general data\r\n    data = get_data(f\"search?q={str(username)}\")\r\n    with open(\"main.html\", \"w\", encoding=\"utf-8\") as f:\r\n        f.write(data)\r\n    soup = BeautifulSoup(data, \"html.parser\")\r\n    # drop time\r\n    try:\r\n        dropTime = soup.find(id=\"availability-time\")\r\n        dropp = dropTime[\"datetime\"]\r\n        dropp = dateutil.parser.parse(dropp).timestamp()\r\n    except:\r\n        dropp = None\r\n    # searches\r\n    searches = int(\r\n        soup.find_all(\"div\", class_=\"tabular\")[0].text.replace(\" / month\", \"\")\r\n    )\r\n    # Capitals\r\n    capitals = soup.find_all(\"samp\")[0].text\r\n    try:\r\n        ret = {\"searches\": searches, \"droptime\": int(dropp), \"spelling\": capitals}\r\n    except:\r\n        ret = {\"searches\": searches, \"droptime\": dropp, \"spelling\": capitals}\r\n    return ret\r\n\r\n\r\ndef getNameHistory(searches=None, length=None):\r\n    print(searches, length)\r\n    # general data\r\n    if searches == None:\r\n        searches = \"&\"\r\n    if length == None:\r\n        length = \"&\"\r\n    data = get_data(\r\n        f\"minecraft-names?searches={str(searches)}&length_op=eq&length={str(length)}\"\r\n    )\r\n    data = str(data)\r\n    with open(\"main.html\", \"w\", encoding=\"utf-8\") as f:\r\n        f.write(data)\r\n    soup = BeautifulSoup(data, \"html.parser\")\r\n    names = []\r\n\r\n    # names.append(soup.select_one(\"div.px-3:nth-child(1)\"))\r\n    names.extend(soup.find_all(\"td\", class_=\"text-left\"))\r\n    # print(names)\r\n    rel = soup.select(\"[rel='next']\")\r\n    nl = []\r\n    for name in names:\r\n        try:\r\n            username = name.find(\"a\").text\r\n            # print(username)\r\n            nl.append(username)\r\n        except:\r\n            pass\r\n\r\n    return nl\r\n\r\n\r\ndef getNameDrops(searches=None, length=None):\r\n    #print(searches, length)\r\n    # general data\r\n    if searches == None:\r\n        searches = \"&\"\r\n    if length == None:\r\n        length = \"&\"\r\n    if length == \"&\" or length == 0:\r\n        data = get_data(\r\n            f\"minecraft-names?searches={str(searches)}\"\r\n        )\r\n    elif searches == \"&\" or searches == 0:\r\n        data = get_data(\r\n            f\"minecraft-names?length_op=eq&length={str(length)}\"\r\n        )\r\n    else:\r\n        data = get_data(\r\n            f\"minecraft-names?searches={str(searches)}&length_op=eq&length={str(length)}\"\r\n        )\r\n    data = str(data)\r\n    #with open(\"main.html\", \"w\", encoding=\"utf-8\") as f:\r\n        #f.write(data)\r\n    soup = BeautifulSoup(data, \"html.parser\")\r\n    names = []\r\n    drops = []\r\n    #print(soup)\r\n    # names.append(soup.select_one(\"div.px-3:nth-child(1)\"))\r\n    names.extend(soup.find_all(\"td\", class_=\"text-left\"))\r\n    drops.extend(soup.find_all(\"td\", class_=\"text-left text-nowrap text-ellipsis border-top-0\"))\r\n    # print(names)\r\n    # print(drops)\r\n    rel = soup.select(\"[rel='next']\")\r\n    pnl = []\r\n    for name in names:\r\n        try:\r\n            username = name.find(\"a\").text\r\n            # print(username)\r\n            pnl.append(username)\r\n        except:\r\n            pass\r\n    nl = [[0 for x in range(2)] for y in range(len(pnl))]\r\n    for x in range(len(pnl)):\r\n        nl[x][0] = pnl[x]\r\n    x = 0\r\n    for drop in drops:\r\n        try:\r\n            droptime = dateutil.parser.parse(drop.text).timestamp()\r\n            nl[x][1] = droptime\r\n            x = x + 1\r\n        except:\r\n            #print(\"pass\")\r\n            pass\r\n    # print(nl)\r\n    if len(nl) == 0:\r\n        print(f\"{Fore.RED}No Names found!\")\r\n        return None\r\n    else:\r\n        ret = jsonBuilder(nl)\r\n        return ret\r\n\r\ndef jsonBuilder(input):\r\n    structure = None\r\n    for x in range(len(input)):\r\n        if x == 0:\r\n            structure = '{\"name\":\"' + str(input[x][0]) + '\",\"droptime\":' + str(input[x][1]) + '},'\r\n        elif x != len(input)-1:\r\n            structure = structure + '{\"name\":\"' + str(input[x][0]) + '\",\"droptime\":' + str(input[x][1]) + '},'\r\n        else:\r\n            structure = structure + '{\"name\":\"' + str(input[x][0]) + '\",\"droptime\":' + str(input[x][1]) + '}'\r\n    structure = '[' + structure + ']'\r\n    jstruct = json.loads(structure)\r\n    return jstruct\r\n\r\ndef prevOwnerDroptime(name: str, prevOwner: str):\r\n    # Name to UUID\r\n    headers = {\"Content-Type\": \"application/json\"}\r\n    payload = [f\"{prevOwner}\"]\r\n    response = requests.post(\"https://api.mojang.com/profiles/minecraft\", data=json.dumps(payload), headers=headers).json()\r\n    uuid = response[0][\"id\"]\r\n    \r\n    # UUID to Namehistory\r\n    response = requests.get(f\"https://api.mojang.com/user/profiles/{uuid}/names\").json()\r\n    if response[-2][\"name\"] == name:\r\n        changetime = response[-1][\"changedToAt\"]\r\n        droptime = changetime + 3196800\r\n        return droptime\r\n    else:\r\n        return None\r\n\r\ndef check_scraper(): # Checks if you can use the scraper (doesn't work in some countries)\r\n    data = get_data(f\"minecraft-names\")\r\n    data = str(data)\r\n    with open(\"main.html\", \"w\", encoding=\"utf-8\") as f:\r\n        f.write(data)\r\n    soup = BeautifulSoup(data, \"html.parser\")\r\n    content = str(soup)\r\n    if content.find(\"td\") >= 0:\r\n        return True\r\n    else:\r\n        return False\r\n"
  },
  {
    "path": "scrapercheck.py",
    "content": "import scraper\n\nresp = scraper.check_scraper()\n\nif resp:\n    print(\"The scraper works for you\")\nelse:\n    print(\"Sorry but the scraper doesnt work for you\")"
  }
]