Skip to content

Commit c2ecf85

Browse files
authored
Merge pull request #24 from PrinceS25/email
Add Email Notifications
2 parents 91999b9 + a0b7b4e commit c2ecf85

21 files changed

+142
-142
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# StockAlertBot
2-
Faced with the scenario of scalpers using bots to hog up all the inventory of popular holiday toys and sell them at ridiciously high markup price, I decided to at least attempt to put up a fight so we can get our hands on things we ~~want~~ need to survive the #Coronavirus quarantine(s). Of course, this is only half the battle. For full writeup on scoring items, look [here](https://github.com/PrinceS25/StockAlertBot/wiki/Beating-Scalpers).
2+
Faced with the scenario of scalpers using bots to hog up all the inventory of popular holiday toys and sell them at ridiculously high markup price, I decided to at least attempt to put up a fight so we can get our hands on things we ~~want~~ need to survive the #Coronavirus quarantine(s). Of course, this is only half the battle. For full writeup on scoring items, look [here](https://github.com/PrinceS25/StockAlertBot/wiki/Beating-Scalpers).
33

44
<p align="center">
55
Donate, buy me a <a href="https://buymeacoff.ee/PrinceSingh" target="_blank">Pizza</a> or <a href="https://paypal.me/PrinceSingh25" target="_blank">PayPal</a> me if you'd like to see this project expanded and support me. :) <br> <br>
@@ -56,6 +56,14 @@ Currently, the following stores are supported:
5656
3. Click on any of the urls that has the string "key=" and copy the whole key
5757
4. Paste it to `TARGET_KEY`
5858
* **If** you want to send alerts to webhook URL(s) like [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) or [Slack](https://api.slack.com/messaging/webhooks), add them to `WEBHOOK_URLS` array
59+
* **If** you want to send alerts to email, change `EMAIL` in `config.json` to `true`. Make a copy of `example.env` and rename it to `.env`. Inside `.env`, type out one of the following service providers (`EMAIL_SERVICE`), your email (`EMAIL_FROM`) and password (`EMAIL_PASS`) and the email you want alerts sent to (`EMAIL_TO`). All without quotes.
60+
```
61+
Gmail, Yahoo, iCloud, Hotmail, Outlook365, QQ, 126, 163, 1und1, AOL, DebugMail, DynectEmail,
62+
FastMail, GandiMail, Godaddy, GodaddyAsia, GodaddyEurope, hot.ee, mail.ee, Mail.ru, Maildev, Mailgun, Mailjet,
63+
Mailosaur, Mandrill, Naver, OpenMailBox, Postmark, QQex, SendCloud, SendGrid, SendinBlue, SendPulse, SES,
64+
SES-US-EAST-1, SES-US-WEST-2, SES-EU-WEST-1, Sparkpost, Yandex, Zoho, qiye.aliyun
65+
```
66+
**NOTE** If you receive the error: `535 5.7.0 (#AUTH005) Too many bad auth attempts`, most likely you are using Yahoo for the email server or an email server managed by Yahoo, such as AOL or AT&T. Yahoo has implemented an option that by default, does not let 3rd party products access the email servers. To resolve, go to https://login.yahoo.com/account/security and then enable the option to allow apps that use less secure sign in. Use the password generated by "Generate app password". If you are using AOL, do the same thing, from https://login.aol.com/account/security.
5967
2. Execute and continue about your day
6068
`node main.js`\
6169
OR\
@@ -74,7 +82,7 @@ Currently, the following stores are supported:
7482
* ~~Tesco~~
7583
* ~~Argos~~
7684
* Add GUI - Make it easier to use
77-
* Add Email and Maybe SMS Notifications
85+
* Add ~~Email and~~ Maybe SMS Notifications
7886
* ~~Fix~~ Find Bugs
7987
* ~~Initially create seperation between intervals for Amazon items~~
8088
* ~~Add a way to have independent delay timers for Amazon~~

config.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@
5353
"TARGET_KEY": "ff457966e64d5e877fdbad070f276d18ecec4a01",
5454

5555

56+
"__EMAIL_comment": [
57+
"IF YOU WANT EMAIL ALERTS",
58+
"Make sure to rename example.env file to .env"
59+
],
60+
"EMAIL": false,
61+
62+
5663
"__WEBHOOK_URLS_comment": [
57-
"IF YOU WANT SLACK OR DISCORD WEBHOOKS"
64+
"IF YOU WANT SLACK OR DISCORD ALERTS"
5865
],
5966
"WEBHOOK_URLS": [
6067
""

example.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ** Configuration for email alerts ** #
2+
########################################
3+
4+
EMAIL_SERVICE =
5+
EMAIL_FROM =
6+
EMAIL_PASS =
7+
EMAIL_TO =

main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export var {
2525
AMAZON_DELAY,
2626
TARGET_ZIP_CODE,
2727
TARGET_KEY,
28+
EMAIL,
2829
WEBHOOK_URLS
2930
} = require('./config.json')
3031

package-lock.json

Lines changed: 11 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"axios": "^0.21.1",
1212
"beepbeep": "^1.3.0",
1313
"dom-parser": "^0.1.6",
14+
"dotenv": "^8.2.0",
1415
"moment": "^2.29.1",
16+
"nodemailer": "^6.4.17",
1517
"open": "^7.3.0"
1618
},
1719
"repository": {

stores/amazon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -45,7 +45,7 @@ export default async function amazon(url, interval, originalIntervalValue, first
4545
if (ALARM) threeBeeps();
4646
if (OPEN_URL && !urlOpened) {
4747
open(url);
48-
sendAlertToWebhooks(url, title, image, store)
48+
sendAlerts(url, title, image, store)
4949
urlOpened = true;
5050
}
5151
console.info(moment().format('LTS') + ': ***** In Stock at ' + store + ' *****: ', title);

stores/antonline.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -49,7 +49,7 @@ export default async function antonline(url, interval) {
4949
if (ALARM) threeBeeps();
5050
if (OPEN_URL && !urlOpened) {
5151
open(url);
52-
sendAlertToWebhooks(url, title, image, store)
52+
sendAlerts(url, title, image, store)
5353
urlOpened = true;
5454
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
5555
}

stores/argos.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -62,7 +62,7 @@ export default async function argos(url, interval) {
6262
if (ALARM) threeBeeps();
6363
if (OPEN_URL && !urlOpened) {
6464
open(url);
65-
sendAlertToWebhooks(url, title, image, store)
65+
sendAlerts(url, title, image, store)
6666
urlOpened = true;
6767
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
6868
}

stores/bestbuy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -54,7 +54,7 @@ export default async function bestbuy(url, interval) {
5454
if (ALARM) threeBeeps();
5555
if (OPEN_URL && !urlOpened) {
5656
open(url);
57-
sendAlertToWebhooks(url, title, image, store)
57+
sendAlerts(url, title, image, store)
5858
urlOpened = true;
5959
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
6060
}

stores/costco.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -45,7 +45,7 @@ export default async function costco(url, interval) {
4545
if (ALARM) threeBeeps();
4646
if (OPEN_URL && !urlOpened) {
4747
open(url);
48-
sendAlertToWebhooks(url, title, image, store)
48+
sendAlerts(url, title, image, store)
4949
urlOpened = true;
5050
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
5151
}

stores/currys.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -55,7 +55,7 @@ export default async function currys(url, interval) {
5555
if (ALARM) threeBeeps();
5656
if (OPEN_URL && !urlOpened) {
5757
open(url);
58-
sendAlertToWebhooks(url, title, image, store)
58+
sendAlerts(url, title, image, store)
5959
urlOpened = true;
6060
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
6161
}

stores/microcenter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -52,7 +52,7 @@ export default async function microcenter(url, interval) {
5252
if (ALARM) threeBeeps();
5353
if (OPEN_URL && !urlOpened) {
5454
open(url);
55-
sendAlertToWebhooks(url, title, image, store)
55+
sendAlerts(url, title, image, store)
5656
urlOpened = true;
5757
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
5858
}

stores/newegg.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -64,7 +64,7 @@ export default async function newegg(url, interval) {
6464
if (ALARM) threeBeeps();
6565
if (OPEN_URL && !urlOpened) {
6666
open(url);
67-
sendAlertToWebhooks(url, title, image, store)
67+
sendAlerts(url, title, image, store)
6868
urlOpened = true;
6969
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
7070
}

stores/target.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from "url";
22
import { ALARM, OPEN_URL, TARGET_KEY, TARGET_ZIP_CODE, USER_AGENTS } from '../main.js'
3-
import threeBeeps from "../utils/beep.js"
4-
import sendAlertToWebhooks from "../utils/webhook.js"
3+
import threeBeeps from "../utils/notification/beep.js"
4+
import sendAlerts from "../utils/notification/alerts.js"
55
import writeErrorToFile from "../utils/writeToFile.js"
66
import axios from "axios";
77
import moment from "moment";
@@ -86,7 +86,7 @@ export default async function target(url, interval, key, zip_code) {
8686
if (ALARM) threeBeeps();
8787
if (OPEN_URL && !urlOpened) {
8888
open(url);
89-
sendAlertToWebhooks(url, title, image, store)
89+
sendAlerts(url, title, image, store)
9090
urlOpened = true;
9191
setTimeout(() => urlOpened = false, 1000 * 295) // Open URL and post to webhook every 5 minutes
9292
}

0 commit comments

Comments
 (0)