diff --git a/.env-example b/.env-example index 374eb99..b52a73b 100644 --- a/.env-example +++ b/.env-example @@ -1,18 +1,18 @@ EMAIL_USERNAME="youremail@gmail.com" EMAIL_PASSWORD="secretpassword" NOTIFICATION_TEST="false" +OPEN_BROWSER="true" PAGE_TIMEOUT="30000" +PHONE_NUMBER="1234567890" +PHONE_CARRIER="tmobile" +PLAY_SOUND="notification.mp3" +PUSHOVER_TOKEN="123pushover-token456" +PUSHOVER_USER="123pushover-user-key" RATE_LIMIT_TIMEOUT="5000" +SHOW_ONLY_BRANDS="evga" SLACK_CHANNEL="SlackChannelName" SLACK_TOKEN="slack-token" STORES="bestbuy,bandh,nvidia" -PHONE_NUMBER="1234567890" -PHONE_CARRIER="tmobile" -PUSHOVER_TOKEN="123pushover-token456" -PUSHOVER_USER="123pushover-user-key" -OPEN_BROWSER="true" -PLAY_SOUND="false" SCREENSHOT="true" TELEGRAM_ACCESS_TOKEN="" TELEGRAM_CHAT_ID="1234" -SHOW_ONLY_BRANDS="evga" diff --git a/README.md b/README.md index 9243477..eecb287 100644 --- a/README.md +++ b/README.md @@ -56,33 +56,33 @@ At any point you want the program to stop, use Ctrl + C. ### Customization -To customize `nvidia-snatcher`, make a copy of `.env-example` as `.env` and make any changes to your liking. +To customize `nvidia-snatcher`, make a copy of `.env-example` as `.env` and make any changes to your liking. _Note that all environment variables are **optional**._ Here is a list of variables that you can use to customize your newly copied `.env` file: -| **Environment variable** | **Description** | -|:---:|---| -| `EMAIL_USERNAME` | Gmail address (e.g., `jensen.robbed.us@gmail.com`); optional | -| `EMAIL_PASSWORD` | Gmail password; see below if you have MFA; optional | -| `NOTIFICATION_TEST` | Test all the notifications configured; optional, default: `false` | -| `PAGE_TIMEOUT` | Navigation Timeout in milliseconds (`0` for infinite); optional, default: `30000` | -| `PHONE_NUMBER` | 10 digit phone number (e.g., `1234567890`); optional, email configuration required | -| `PHONE_CARRIER` | [Supported carriers](#supported-carriers) for SMS; optional, email configuration required | -| `RATE_LIMIT_TIMEOUT` | Rate limit timeout for each full store cycle; optional, default: `5000` | -| `SHOW_ONLY_BRANDS` | If set, will only show specified brands, seperated by `,` | -| `SLACK_CHANNEL` | Slack channel for posting (e.g., `update`); optional | -| `SLACK_TOKEN` | Slack API token; optional | -| `STORES` | [Supported stores](#supported-stores) you want to be scraped; optional, default: `nvidia` | -| `OPEN_BROWSER` | Toggle for whether or not the browser should open when item is found, default: `true` | -| `PLAY_SOUND` | Play this sound notification if a card is found.; optional | -| `SCREENSHOT` | Capture screenshot of page on successful hit; optional, default `true` | -| `TELEGRAM_ACCESS_TOKEN` | Telegram access token; optional | -| `TELEGRAM_CHAT_ID` | Telegram chat ID; optional | +| **Environment variable** | **Description** | **Notes** | +|:---:|---|---| +| `EMAIL_USERNAME` | Gmail address | E.g.: `jensen.robbed.us@gmail.com` | +| `EMAIL_PASSWORD` | Gmail password | See below if you have MFA | +| `NOTIFICATION_TEST` | Test all the notifications configured | Default: `false` | +| `OPEN_BROWSER` | Toggle for whether or not the browser should open when item is found | Default: `true` | +| `PAGE_TIMEOUT` | Navigation Timeout in milliseconds | `0` for infinite, default: `30000` | +| `PHONE_NUMBER` | 10 digit phone number | E.g.: `1234567890`, email configuration required | +| `PHONE_CARRIER` | [Supported carriers](#supported-carriers) for SMS | Email configuration required | +| `PLAY_SOUND` | Play this sound notification if a card is found | E.g.: `path/to/notification.wav`, valid formats: wav, mp3, flac, [free sounds available](https://notificationsounds.com/) | +| `PUSHOVER_TOKEN` | Pushover access token | +| `PUSHOVER_USERNAME` | Pushover username | +| `RATE_LIMIT_TIMEOUT` | Rate limit timeout for each full store cycle | Default: `5000` | +| `SHOW_ONLY_BRANDS` | Filter to show specified brands | Comma separated, E.g.: `evga,zotac` | +| `SLACK_CHANNEL` | Slack channel for posting | E.g., `update`, no need for `#` | +| `SLACK_TOKEN` | Slack API token | +| `STORES` | [Supported stores](#supported-stores) you want to be scraped | Comma separated, default: `nvidia` | +| `SCREENSHOT` | Capture screenshot of page if a card is found | Default: `true` | +| `TELEGRAM_ACCESS_TOKEN` | Telegram access token | +| `TELEGRAM_CHAT_ID` | Telegram chat ID | > :point_right: If you have multi-factor authentication (MFA), you will need to create an [app password](https://myaccount.google.com/apppasswords) and use this instead of your Gmail password. -> :point_right: Free sounds available [here](https://freesound.org/home/). Place sounds into `resources/sounds/` - #### Supported stores | **Stores** | **Environment variable** | diff --git a/src/config.ts b/src/config.ts index a37470e..bb895a8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -23,8 +23,8 @@ const notifications = { }, playSound: process.env.PLAY_SOUND ?? '', pushover: { - token: process.env.PUSHOVER_TOKEN, - user: process.env.PUSHOVER_USER + token: process.env.PUSHOVER_TOKEN ?? '', + user: process.env.PUSHOVER_USER ?? '' }, slack: { channel: process.env.SLACK_CHANNEL ?? '', diff --git a/src/notification/sound.ts b/src/notification/sound.ts index 3376929..75b52c8 100644 --- a/src/notification/sound.ts +++ b/src/notification/sound.ts @@ -1,9 +1,9 @@ -import playerLib = require('play-sound'); +import playerLib from 'play-sound'; import {Config} from '../config'; import {Logger} from '../logger'; -import * as fs from 'fs'; +import fs from 'fs'; -const notificationSound = './resources/sounds/' + Config.notifications.playSound; +const notificationSound = Config.notifications.playSound; const player = playerLib(); export function playSound() {