mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 15:47:35 +00:00
feat: webpage toggle, sound notification, fix evga links (#52)
Co-authored-by: Evan Gentis <evan.gentis@gmail.com> Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
+6
-2
@@ -23,7 +23,8 @@ const notifications = {
|
||||
channel: process.env.SLACK_CHANNEL ?? '',
|
||||
token: process.env.SLACK_TOKEN ?? ''
|
||||
},
|
||||
test: process.env.NOTIFICATION_TEST ?? 'false'
|
||||
test: process.env.NOTIFICATION_TEST ?? 'false',
|
||||
playSound: process.env.PLAY_SOUND ?? 'false'
|
||||
};
|
||||
|
||||
const page = {
|
||||
@@ -38,9 +39,12 @@ const rateLimitTimeout = Number(process.env.RATE_LIMIT_TIMEOUT) ?? 5000;
|
||||
|
||||
const stores = process.env.STORES ?? 'nvidia';
|
||||
|
||||
const openBrowser = process.env.OPEN_BROWSER ?? 'true';
|
||||
|
||||
export const Config = {
|
||||
notifications,
|
||||
rateLimitTimeout,
|
||||
page,
|
||||
stores
|
||||
stores,
|
||||
openBrowser
|
||||
};
|
||||
|
||||
+5
-1
@@ -67,7 +67,11 @@ async function lookup(store: Store) {
|
||||
}
|
||||
|
||||
const givenUrl = store.cartUrl ? store.cartUrl : link.url;
|
||||
await open(givenUrl);
|
||||
|
||||
if (Config.openBrowser === 'true') {
|
||||
await open(givenUrl);
|
||||
}
|
||||
|
||||
sendNotification(givenUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {Config} from '../config';
|
||||
import sendEmail from './email';
|
||||
import sendSlaskMessage from './slack';
|
||||
import sendSMS from './sms';
|
||||
import playSound from './sound';
|
||||
|
||||
export default function sendNotification(cartUrl: string) {
|
||||
if (Config.notifications.email.username && Config.notifications.email.password) {
|
||||
@@ -18,4 +19,8 @@ export default function sendNotification(cartUrl: string) {
|
||||
sendSMS(cartUrl);
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.notifications.playSound) {
|
||||
playSound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import playerLib = require('play-sound');
|
||||
import {Config} from '../config';
|
||||
import {Logger} from '../logger';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const notificationSound = './resources/sounds/' + Config.notifications.playSound;
|
||||
const player = playerLib();
|
||||
|
||||
export default function playSound() {
|
||||
// Check if file exists
|
||||
fs.access(notificationSound, fs.constants.F_OK, err => {
|
||||
if (err) {
|
||||
Logger.error(`error opening sound file: ${err.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
player.play(notificationSound, (err: string) => {
|
||||
Logger.info('✔ playing sound');
|
||||
|
||||
if (err) {
|
||||
Logger.error(`error playing sound: ${err}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
+21
-2
@@ -5,10 +5,29 @@ export const Evga: Store = {
|
||||
links: [
|
||||
{
|
||||
brand: 'evga',
|
||||
model: 'ftw3, xc3 black, xc3 gaming, xc3 ultra gaming',
|
||||
url: 'https://www.evga.com/products/productlist.aspx?type=0&family=GeForce+30+Series+Family&chipset=RTX+3080',
|
||||
model: 'xc3 black',
|
||||
url: 'https://www.evga.com/products/product.aspx?pn=10G-P5-3881-KR',
|
||||
oosLabels: ['out of stock']
|
||||
},
|
||||
{
|
||||
brand: 'evga',
|
||||
model: 'ftw3',
|
||||
url: 'https://www.evga.com/products/product.aspx?pn=10G-P5-3897-KR',
|
||||
oosLabels: ['out of stock']
|
||||
},
|
||||
{
|
||||
brand: 'evga',
|
||||
model: 'xc3 gaming',
|
||||
url: 'https://www.evga.com/products/product.aspx?pn=10G-P5-3883-KR',
|
||||
oosLabels: ['out of stock']
|
||||
},
|
||||
{
|
||||
brand: 'evga',
|
||||
model: 'xc3 ultra gaming',
|
||||
url: 'https://www.evga.com/products/product.aspx?pn=10G-P5-3885-KR',
|
||||
oosLabels: ['out of stock']
|
||||
}
|
||||
],
|
||||
name: 'evga'
|
||||
};
|
||||
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
declare module 'play-sound';
|
||||
Reference in New Issue
Block a user