mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 01:47:39 +00:00
refactor: map sms, fix amazon text
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
+9
-3
@@ -9,9 +9,15 @@ const notifications = {
|
||||
password: process.env.EMAIL_PASSWORD ?? ''
|
||||
},
|
||||
phone: {
|
||||
availableCarriers: ['sprint', 'verizon', 'tmobile', 'att', 'google'],
|
||||
carrier: process.env.PHONE_CARRIER,
|
||||
number: process.env.PHONE_NUMBER
|
||||
availableCarriers: new Map([
|
||||
['sprint', 'messaging.sprintpcs.com'],
|
||||
['verizon', 'vtext.com'],
|
||||
['tmobile', 'tmomail.net'],
|
||||
['att', 'txt.att.net'],
|
||||
['google', 'msg.fi.google.com']
|
||||
]),
|
||||
carrier: process.env.PHONE_CARRIER ?? '',
|
||||
number: process.env.PHONE_NUMBER ?? ''
|
||||
},
|
||||
slack: {
|
||||
channel: process.env.SLACK_CHANNEL ?? '',
|
||||
|
||||
+7
-7
@@ -5,13 +5,6 @@ import open from 'open';
|
||||
import sendNotification from './notification';
|
||||
import {Logger} from './logger';
|
||||
|
||||
/**
|
||||
* Send test email.
|
||||
*/
|
||||
if (Config.notifications.test === 'true') {
|
||||
sendNotification('test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the bot.
|
||||
*/
|
||||
@@ -94,6 +87,13 @@ function isOutOfStock(domText: string, oosLabels: string[]) {
|
||||
return oosLabels.some(label => domTextLowerCase.includes(label));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send test email.
|
||||
*/
|
||||
if (Config.notifications.test === 'true') {
|
||||
sendNotification('test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Will continually run until user interferes.
|
||||
*/
|
||||
|
||||
@@ -4,18 +4,19 @@ import {Config} from '../config';
|
||||
import {Logger} from '../logger';
|
||||
|
||||
const subject = 'NVIDIA - BUY NOW';
|
||||
const email = Config.notifications.email;
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: Config.notifications.email.username,
|
||||
pass: Config.notifications.email.password
|
||||
user: email.username,
|
||||
pass: email.password
|
||||
}
|
||||
});
|
||||
|
||||
const mailOptions: Mail.Options = {
|
||||
from: Config.notifications.email.username,
|
||||
to: Config.notifications.email.username,
|
||||
from: email.username,
|
||||
to: email.username,
|
||||
subject
|
||||
};
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ export default function sendNotification(cartUrl: string) {
|
||||
}
|
||||
|
||||
if (Config.notifications.phone.number) {
|
||||
const carrier = Config.notifications.phone.carrier?.toLowerCase();
|
||||
if (carrier && Config.notifications.phone.availableCarriers.includes(carrier)) {
|
||||
const carrier = Config.notifications.phone.carrier.toLowerCase();
|
||||
if (carrier && Config.notifications.phone.availableCarriers.has(carrier)) {
|
||||
sendSMS(cartUrl);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-14
@@ -4,20 +4,13 @@ import {Config} from '../config';
|
||||
import {Logger} from '../logger';
|
||||
|
||||
const subject = 'NVIDIA - BUY NOW';
|
||||
|
||||
enum carrierAddress {
|
||||
sprint = 'messaging.sprintpcs.com',
|
||||
verizon = 'vtext.com',
|
||||
tmobile = 'tmomail.net',
|
||||
att = 'txt.att.net',
|
||||
google = 'msg.fi.google.com'
|
||||
}
|
||||
const [email, phone] = [Config.notifications.email, Config.notifications.phone];
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: Config.notifications.email.username,
|
||||
pass: Config.notifications.email.password
|
||||
user: email.username,
|
||||
pass: email.password
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,9 +34,8 @@ export default function sendSMS(text: string) {
|
||||
}
|
||||
|
||||
function generateAddress() {
|
||||
const carrier = Config.notifications.phone.carrier?.toLowerCase();
|
||||
if (carrier && Object.keys(carrierAddress).includes(carrier)) {
|
||||
// @ts-expect-error
|
||||
return [Config.notifications.phone.number, carrierAddress[carrier]].join('@');
|
||||
const carrier = phone.carrier.toLowerCase();
|
||||
if (carrier && phone.availableCarriers.has(carrier)) {
|
||||
return [phone.number, phone.availableCarriers.get(carrier)].join('@');
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -7,49 +7,49 @@ export const Amazon: Store = {
|
||||
brand: 'pny',
|
||||
model: 'xlr8',
|
||||
url: 'https://www.amazon.com/PNY-GeForce-Gaming-Epic-X-Graphics/dp/B08HBR7QBM?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'msi',
|
||||
model: 'gaming trio',
|
||||
url: 'https://www.amazon.com/MSI-GeForce-RTX-3080-10G/dp/B08HR7SV3M?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'evga',
|
||||
model: 'ftw3',
|
||||
url: 'https://www.amazon.com/EVGA-10G-P5-3897-KR-GeForce-Technology-Backplate/dp/B08HR3Y5GQ?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'evga',
|
||||
model: 'xc3',
|
||||
url: 'https://www.amazon.com/EVGA-10G-P5-3885-KR-GeForce-Cooling-Backplate/dp/B08HR55YB5?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'gigabyte',
|
||||
model: 'windforce',
|
||||
url: 'https://www.amazon.com/GIGABYTE-GeForce-Graphics-WINDFORCE-GV-N3080GAMING/dp/B08HJTH61J?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'gigabyte',
|
||||
model: 'windforce eagle',
|
||||
url: 'https://www.amazon.com/GIGABYTE-GeForce-Graphics-WINDFORCE-GV-N3080EAGLE/dp/B08HJS2JLJ?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'asus',
|
||||
model: 'tuf',
|
||||
url: 'https://www.amazon.com/ASUS-Graphics-DisplayPort-Military-Grade-Certification/dp/B08HH5WF97?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
},
|
||||
{
|
||||
brand: 'msi',
|
||||
model: 'ventus',
|
||||
url: 'https://www.amazon.com/MSI-GeForce-RTX-3080-10G/dp/B08HR5SXPS?ref_=ast_sto_dp',
|
||||
oosLabels: ['currently unavailable', 'Enter the characters you see below']
|
||||
oosLabels: ['currently unavailable', 'enter the characters you see below']
|
||||
}
|
||||
],
|
||||
name: 'amazon'
|
||||
|
||||
Reference in New Issue
Block a user