From 8466f9f398294ce3925f95b6cfa26572b656a61a Mon Sep 17 00:00:00 2001 From: serg06 Date: Wed, 23 Sep 2020 11:02:44 -0400 Subject: [PATCH] chore(misc): tiny improvements (#233) Co-authored-by: Jef LeCompte --- README.md | 4 ++-- src/index.ts | 5 +++++ src/notification/sound.ts | 8 ++++++++ src/store/model/index.ts | 11 ++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e1c21b9..6d77b48 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The purpose of this bot is to get an Nvidia card. It tries multiple things to do > :point_right: You may get false positives from time to time, so I apologize for that. The library currently waits for all calls to be completed before parsing, but sometimes this can have unknown behavior. Patience is a virtue :) -| | **Adorama** | **Amazon** | **ASUS** | **EVGA** | **Best Buy** | **B&H** | **Micro Center** | **Newegg** | **Nvidia** | **Office Depot** | **Zotac** | +| | **Adorama** | **Amazon** | **ASUS** | **B&H** | **Best Buy** | **EVGA** | **Micro Center** | **Newegg** | **Nvidia** | **Office Depot** | **Zotac** | |:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| | **3070**| | | | | | | | | | | | | **3080** | `✔` | `✔` | `✔` | `✔` | `✔` | `✔` | `✔` | `✔` | `✔` | `✔` | `✔` | @@ -112,9 +112,9 @@ Here is a list of variables that you can use to customize your newly copied `.en | Amazon | `amazon`| | Amazon (CA) | `amazon-ca`| | ASUS | `asus` | +| B&H | `bandh`| | Best Buy | `bestbuy`| | Best Buy (CA) | `bestbuy-ca`| -| B&H | `bandh`| | EVGA | `evga`| | EVGA (EU) | `evga-eu`| | Micro Center | `microcenter`| diff --git a/src/index.ts b/src/index.ts index e2066c2..73984fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,11 @@ puppeteer.use(adBlocker); * Starts the bot. */ async function main() { + if (Stores.length === 0) { + Logger.error('No stores selected.'); + return; + } + const args: string[] = []; // Skip Chromium Linux Sandbox diff --git a/src/notification/sound.ts b/src/notification/sound.ts index da4a187..26a9165 100644 --- a/src/notification/sound.ts +++ b/src/notification/sound.ts @@ -4,7 +4,15 @@ import fs from 'fs'; import playerLib from 'play-sound'; const notificationSound = Config.notifications.playSound; + +Logger.info('Searching for sound player...'); const player = playerLib(); +if (player.player === null) { + Logger.warn('No sound player found.'); +} else { + const playerName: string = player.player; + Logger.info(`Sound player found: ${playerName}`); +} export function playSound() { // Check if file exists diff --git a/src/store/model/index.ts b/src/store/model/index.ts index a652af0..fb7dbac 100644 --- a/src/store/model/index.ts +++ b/src/store/model/index.ts @@ -9,6 +9,7 @@ import {BestBuyCa} from './bestbuy-ca'; import {Config} from '../../config'; import {Evga} from './evga'; import {EvgaEu} from './evga-eu'; +import {Logger} from '../../logger'; import {MicroCenter} from './microcenter'; import {NewEgg} from './newegg'; import {NewEggCa} from './newegg-ca'; @@ -38,9 +39,17 @@ const masterList = new Map([ const list = new Map(); for (const name of Config.store.stores) { - list.set(name, masterList.get(name)); + if (masterList.has(name)) { + list.set(name, masterList.get(name)); + } else { + const logString = `No store named ${name}, skipping.`; + Logger.warn(logString); + } } +const logString = `Selected stores: ${Array.from(list.keys()).join(', ')}`; +Logger.info(logString); + export const Stores = Array.from(list.values()) as Store[]; export * from './store';