Skip to content

Commit

Permalink
Merge pull request #387 from Hari-Nagarajan/development
Browse files Browse the repository at this point in the history
Development for Release to Master
  • Loading branch information
DakkJaniels authored Dec 5, 2020
2 parents a696c8c + 978f0ab commit e6db84a
Show file tree
Hide file tree
Showing 14 changed files with 762 additions and 369 deletions.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ geckodriver.log
.profile
.profile-amz*
*_config.json
*.log
*_credentials.json
*.log*
__pycache__/
*.py[cod]
*.pkl
.vscode/
/config/apprise_config.json
/config/apprise_config.json
*.png
*.html
/config/*_credentials.json
/config/apprise_config.json
screenshots/*.png
html_saves/*.html
*.code-workspace
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ browser-cookie3 = "*"
coloredlogs = "*"
apprise = "*"
price-parser = "*"

pypresence = "==4.0.0"


[requires]
Expand Down
69 changes: 53 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# nvidia-bot
# Fairgame

[Installation](#Installation) | [Usage](#Usage) | [Discord](https://discord.gg/qDY2QBtAW6) | [Troubleshooting](#Troubleshooting)

## Why???

I built this in response to the severe tech scalping situation that's happening right now. Almost every tech product that's coming
We built this in response to the severe tech scalping situation that's happening right now. Almost every tech product that's coming
out right now is being instantly brought out by scalping groups and then resold at at insane prices. $699 GPUs are being listed
for $1700 on eBay, and these scalpers are buying 40 carts while normal consumers can't get a single one. Preorders for the PS5 are
being resold for nearly $1000. My take on this is that if I release a bot that anyone can use, for free, then the number of items
that scalpers can buy goes down and normal consumers can buy items for MSRP. If everyone is botting, then no one is botting.
being resold for nearly $1000. Our take on this is that if we release a bot that anyone can use, for free, then the number of items
that scalpers can buy goes down and normal consumers can buy items for MSRP.

**If everyone is botting, then no one is botting.**

## Got a question?

See the [FAQs](#frequently-asked-questions) first.
Read through this document and the cheat sheet linked in the next sections. See the [FAQs](#frequently-asked-questions) if that does not answer your questions.

## Installation

Easy_XII has created a great cheat sheet for getting started, [please follow this guide](https://docs.google.com/document/d/1grN282tPodM9N57bPq4bbNyKZC01t_4A-sLpzzu_7lM/).

This project uses [Pipenv](https://pypi.org/project/pipenv/) to manage dependencies. Hop in my [Discord](https://discord.gg/qDY2QBtAW6) if you have ideas, need help or just want to tell me about how you got your new 3080.
This project uses [Pipenv](https://pypi.org/project/pipenv/) to manage dependencies. Hop in my [Discord](https://discord.gg/qDY2QBtAW6) if you have ideas, need help or just want to tell us about how you got your new toys.

To get started you'll first need to clone this repository. If you are unfamiliar with Git, follow the [guide on how to do that on our Wiki](https://github.com/Hari-Nagarajan/nvidia-bot/wiki/How-to-use-GitHub-Desktop-App). You *can* use the "Download Zip" button on the GitHub repository's homepage but this makes receieving updates more difficult. If you can get setup with the GitHub Desktop app, updating to the latest version of the bot takes 1 click.
To get started you'll first need to clone this repository. If you are unfamiliar with Git, follow the [guide on how to do that on our Wiki](https://github.com/Hari-Nagarajan/fairgame/wiki/How-to-use-GitHub-Desktop-App). You *can* use the "Download Zip" button on the GitHub repository's homepage but this makes receieving updates more difficult. If you can get setup with the GitHub Desktop app, updating to the latest version of the bot takes 1 click.

!!! YOU WILL NEED TO USE THE 3.8 BRANCH OF PYTHON, 3.9.0 BREAKS DEPENDENCIES !!!
```
Expand Down Expand Up @@ -63,13 +65,14 @@ Commands:
--checkshipping : Bot will consider shipping + sales price in reserve check. Without this flag, only free shipping items will be considered
--detailed : Take more screenshots. !!!!!! This could cause you to miss checkouts !!!!!!
--used : Show used items in search listings
--random-delay : Set delay to a random interval
--single-shot : Quit after 1 successful purchase
--no-screenshots : Do not take screenshots
```

Make a copy of `amazon_config.template_json` and rename to `amazon_config.json`:
```json
{
"username": "",
"password": "",
"asin_groups": 2,
"asin_list_1": ["B07JH53M4T","B08HR7SV3M"],
"reserve_1": 1000,
Expand All @@ -78,15 +81,49 @@ Make a copy of `amazon_config.template_json` and rename to `amazon_config.json`:
"amazon_website": "smile.amazon.com"
}
```
* `username` is your Amazon account email address
* `password` is your Amazon account password
* `asin_groups` indicates the number of ASIN groups you want to use.
* `asin_list_x` list of ASINs for products you want to purchase. You must locate these (see Discord or lookup the ASIN on product pages).
* The first time an item from list "x" is in stock and under its associated reserve, it will purchase it.
* If the purchase is successful, the bot will not buy anything else from list "x".
* Use sequential numbers for x, starting from 1. x can be any integer from 1 to 18,446,744,073,709,551,616
* `reserve_x` is the most amount you want to spend for a single item (i.e., ASIN) in `asin_list_x`. Does not include tax. If --checkshipping flag is active, this includes shipping listed on offer page.
* `amazon_website` amazon domain you want to use. smile subdomain appears to work better, if available in your country.


Previously your username and password were entered into the config file, this is no longer the case. On first launch the bot will prompt
you for your credentials. You will then be asked for a password to encrypt them. Once done, your encrypted credentials will be stored in
`amazon_credentials.json`. If you ever forget your encryption password, just delete this file and the next launch of the bot will recreate
it. An example of this will look like the following:

```
python app.py amazon
INFO Initializing Apprise handler
INFO Initializing other notification handlers
INFO Enabled Handlers: ['Audio']
INFO No credential file found, let's make one
Amazon login ID: <your email address>
Amazon Password: <your amazon password>
INFO Create a password for the credential file
Credential file password: <a password used to encrypt your amazon credentials>
Verify credential file password: <the same password that was entered above>
INFO Credentials safely stored.
```

Starting the bot when you have created an encrypted file:

```
python app.py amazon --test
INFO Initializing Apprise handler
INFO Initializing other notification handlers
INFO Enabled Handlers: ['Audio']
Reading credentials from: amazon_credentials.json
Credential file password: <enter the previously created password>
```

At run time, the bot will automatically prune ASINs that cause errors.

=======

Example usage:

```
Expand Down Expand Up @@ -190,8 +227,8 @@ Maybe this works?
sudo apt update
sudo apt upgrade
sudo apt install chromium-chromedriver
git clone https://github.com/Hari-Nagarajan/nvidia-bot
cd nvidia-bot/
git clone https://github.com/Hari-Nagarajan/fairgame
cd fairgame/
pip3 install pipenv
export PATH=$PATH:/home/<YOURUSERNAME>/.local/bin
pipenv shell
Expand All @@ -201,7 +238,7 @@ pipenv install

3. Open the following file in a text editor:
```
/home/<YOURUSERNAME>/.local/share/virtualenvs/nvidia-bot-<RANDOMCHARS>/lib/python3.7/site-packages/selenium/webdriver/common/service.py
/home/<YOURUSERNAME>/.local/share/virtualenvs/fairgame-<RANDOMCHARS>/lib/python3.7/site-packages/selenium/webdriver/common/service.py
```
4. Edit line 38 from `self.path = executable` to `self.path = "chromedriver"`, then save and close the file.

Expand All @@ -216,9 +253,9 @@ python app.py
## Frequently Asked Questions

### 1. Can I run multiple instances of the bot?
Yes. For example you can run one instance to check stock on the Nvidia store and a separate instance to check stock on Amazon. Bear in mind that if you do this you may end up with multiple purchases going through at the same time.
Yes. For example you can run one instance to check stock on Best Buy and a separate instance to check stock on Amazon. Bear in mind that if you do this you may end up with multiple purchases going through at the same time.

### 2. Does Nvidia Bot automatically bypass CAPTCHA's on the store sites?
### 2. Does Fairgame automatically bypass CAPTCHA's on the store sites?
* For Amazon, yes. The bot will try and auto-solve CAPTCHA's during the checkout process.

## Attribution
Expand Down
86 changes: 57 additions & 29 deletions cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from stores.nvidia import NvidiaBuyer, GPU_DISPLAY_NAMES, CURRENCY_LOCALE_MAP
from utils import selenium_utils
from utils.logger import log
from utils.discord_presence import start_presence

notification_handler = NotificationHandler()

Expand All @@ -28,7 +29,7 @@ def decorator(*args, **kwargs):
except KeyboardInterrupt:
pass
except:
notification_handler.send_notification(f"nvidia-bot has crashed.")
notification_handler.send_notification(f"FairGame has crashed.")
raise

return decorator
Expand All @@ -39,31 +40,31 @@ def main():
pass


@click.command()
@click.option(
"--gpu",
type=click.Choice(GPU_DISPLAY_NAMES, case_sensitive=False),
prompt="What GPU are you after?",
cls=QuestionaryOption,
)
@click.option(
"--locale",
type=click.Choice(CURRENCY_LOCALE_MAP.keys(), case_sensitive=False),
prompt="What locale shall we use?",
cls=QuestionaryOption,
)
@click.option("--test", is_flag=True)
@click.option("--interval", type=int, default=5)
@notify_on_crash
def nvidia(gpu, locale, test, interval):
nv = NvidiaBuyer(
gpu,
notification_handler=notification_handler,
locale=locale,
test=test,
interval=interval,
)
nv.run_items()
# @click.command()
# @click.option(
# "--gpu",
# type=click.Choice(GPU_DISPLAY_NAMES, case_sensitive=False),
# prompt="What GPU are you after?",
# cls=QuestionaryOption,
# )
# @click.option(
# "--locale",
# type=click.Choice(CURRENCY_LOCALE_MAP.keys(), case_sensitive=False),
# prompt="What locale shall we use?",
# cls=QuestionaryOption,
# )
# @click.option("--test", is_flag=True)
# @click.option("--interval", type=int, default=5)
# @notify_on_crash
# def nvidia(gpu, locale, test, interval):
# nv = NvidiaBuyer(
# gpu,
# notification_handler=notification_handler,
# locale=locale,
# test=test,
# interval=interval,
# )
# nv.run_items()


@click.command()
Expand Down Expand Up @@ -92,8 +93,26 @@ def nvidia(gpu, locale, test, interval):
is_flag=True,
help="Show used items in search listings.",
)
@click.option("--random-delay", is_flag=True, help="Set delay to a random interval")
@click.option("--single-shot", is_flag=True, help="Quit after 1 successful purchase")
@click.option(
"--no-screenshots",
is_flag=True,
help="Take NO screenshots, do not bother asking for help if you use this... Screenshots are the best tool we have for troubleshooting",
)
@notify_on_crash
def amazon(no_image, headless, test, delay, checkshipping, detailed, used):
def amazon(
no_image,
headless,
test,
delay,
checkshipping,
detailed,
used,
random_delay,
single_shot,
no_screenshots,
):
if no_image:
selenium_utils.no_amazon_image()
else:
Expand All @@ -103,10 +122,13 @@ def amazon(no_image, headless, test, delay, checkshipping, detailed, used):
headless=headless,
notification_handler=notification_handler,
checkshipping=checkshipping,
random_delay=random_delay,
detailed=detailed,
used=used,
single_shot=single_shot,
no_screenshots=no_screenshots,
)
amzn_obj.run_item(delay=delay, test=test)
amzn_obj.run(delay=delay, test=test)


@click.command()
Expand All @@ -132,7 +154,13 @@ def test_notifications():

signal(SIGINT, handler)

main.add_command(nvidia)
try:
status = "Spinning up"
start_presence(status)
except:
pass

# main.add_command(nvidia)
main.add_command(amazon)
main.add_command(bestbuy)
main.add_command(test_notifications)
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"username": "",
"password": "",
"asin_groups": 2,
"asin_list_1": ["B07JH53M4T"],
"reserve_1": 15,
"asin_list_2": ["B08HR7SV3M"],
"reserve_2": 20,
"amazon_website": "smile.amazon.com"
}
}
15 changes: 0 additions & 15 deletions keylinks.md

This file was deleted.

2 changes: 1 addition & 1 deletion notifications/providers/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def send(self, message_body):
url = self.url_re.search(message_body)
payload = {
"text": message_body,
"title": "Nvidia-Bot Alert",
"title": "FairGame Alert",
"deviceId": self.deviceId,
"apikey": self.apikey,
}
Expand Down
Loading

0 comments on commit e6db84a

Please sign in to comment.