Skip to content

Commit

Permalink
feat(notification): add telegram (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doridian committed Sep 19, 2020
1 parent d4de1a4 commit 393d5f6
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
@@ -0,0 +1,5 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
indent_style = tab
3 changes: 3 additions & 0 deletions .env.example
Expand Up @@ -13,3 +13,6 @@ PUSHOVER_USER="123pushover-user-key"
OPEN_BROWSER="true"
PLAY_SOUND="false"
SCREENSHOT="true"
TELEGRAM_ACCESS_TOKEN=""
TELEGRAM_CHAT_ID="1234"
SHOW_ONLY_BRANDS="evga"
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -72,11 +72,14 @@ First, you're going to need to copy the `.env.example` to `.env`. The current op
| `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` |
| `SLACK_CHANNEL` | Slack channel for posting (e.g., `update`); optional |
| `SLACK_TOKEN` | Slack API token; 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 |
| `SHOW_ONLY_BRANDS` | If set, will only show specified brands, seperated by `,` |

> :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.
Expand Down
169 changes: 156 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -22,6 +22,7 @@
"homepage": "https://github.com/jef/nvidia-snatcher#readme",
"dependencies": {
"dotenv": "^8.2.0",
"messaging-api-telegram": "^1.0.0",
"nodemailer": "^6.4.11",
"open": "^7.2.1",
"puppeteer": "^5.3.0",
Expand Down
9 changes: 8 additions & 1 deletion src/config.ts
Expand Up @@ -29,6 +29,10 @@ const notifications = {
token: process.env.PUSHOVER_TOKEN,
user: process.env.PUSHOVER_USER
},
telegram: {
botToken: process.env.TELEGRAM_ACCESS_TOKEN ?? '',
chatId: process.env.TELEGRAM_CHAT_ID ?? ''
},
test: process.env.NOTIFICATION_TEST ?? 'false',
playSound: process.env.PLAY_SOUND ?? 'false'
};
Expand All @@ -47,10 +51,13 @@ const stores = process.env.STORES ?? 'nvidia';

const openBrowser = process.env.OPEN_BROWSER ?? 'true';

const showOnlyBrands = process.env.SHOW_ONLY_BRANDS ? process.env.SHOW_ONLY_BRANDS.split(',') : [];

export const Config = {
notifications,
rateLimitTimeout,
page,
stores,
openBrowser
openBrowser,
showOnlyBrands
};

0 comments on commit 393d5f6

Please sign in to comment.