NOTIFY to set notification services
This commit is contained in:
parent
e57c2c4408
commit
2f0961b1b3
3 changed files with 34 additions and 6 deletions
10
README.md
10
README.md
|
|
@ -30,6 +30,7 @@ Data is stored in the volume `fgc`.
|
|||
1. [Install Node.js](https://nodejs.org/en/download)
|
||||
2. Clone/download this repository and `cd` into it in a terminal
|
||||
3. Run `npm install && npx playwright install firefox`
|
||||
4. Run `pip install apprise` to install [apprise](https://github.com/caronc/apprise) if you want notifications
|
||||
|
||||
This downloads Firefox to a cache in home ([doc](https://playwright.dev/docs/browsers#managing-browser-binaries)).
|
||||
If you are missing some dependencies for the browser on your system, you can use `sudo npx playwright install firefox --with-deps`.
|
||||
|
|
@ -63,6 +64,7 @@ Available options/variables and their default values:
|
|||
| WIDTH | 1280 | Width of the opened browser (and screen vor VNC in Docker). |
|
||||
| HEIGHT | 1280 | Height of the opened browser (and screen vor VNC in Docker). |
|
||||
| VNC_PASSWORD | | VNC password for Docker. No password used by default! |
|
||||
| NOTIFY | | Notification services to use (Pushover, Slack, Telegram...), see below. |
|
||||
| EMAIL | | Default email for any login. |
|
||||
| PASSWORD | | Default password for any login. |
|
||||
| EG_EMAIL | | Epic Games email for login. Overrides EMAIL. |
|
||||
|
|
@ -80,6 +82,12 @@ See `config.js` for all options.
|
|||
On Linux/macOS you can prefix the variables you want to set, for example `EMAIL=foo@bar.baz SHOW=1 node epic-games` will show the browser and skip asking you for your login email.
|
||||
For Docker you can pass variables using `-e VAR=VAL`, for example `docker run -e EMAIL=foo@bar.baz ...` or using `--env-file` (see [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)). If you are using [docker compose](https://docs.docker.com/compose/environment-variables/), you can put them in the `environment:` section.
|
||||
|
||||
### Notifications
|
||||
The scripts will try to send notifications for successfully claimed games and any errors like needing to log in or encountered captchas (should not happen).
|
||||
|
||||
[apprise](https://github.com/caronc/apprise) is used for notifications and offers many services including Pushover, Slack, Telegram, SMS, Email, desktop and custom notifications.
|
||||
You just need to set `NOTIFY` to the notifications services you want to use, e.g. `NOTIFY='mailto://myemail:mypass@gmail.com' 'pbul://o.gn5kj6nfhv736I7jC3cj3QLRiyhgl98b'` - refer to their list of services and [examples](https://github.com/caronc/apprise#command-line-usage).
|
||||
|
||||
### Automatic login, two-factor authentication
|
||||
If you set the options for email, password and OTP key, there will be no prompts and logins should happen automatically. This is optional since all stores should stay logged in since cookies are refreshed.
|
||||
To get the OTP key, it is easiest to follow the store's guide for adding an authenticator app. You should also scan the shown QR code with your favorite app to have an alternative method for 2FA.
|
||||
|
|
@ -166,6 +174,6 @@ Added OTP generation via otplib for automatic login, even with 2FA.
|
|||
|
||||
---
|
||||
|
||||
Logo with smaller aspect ratio (for Telegram bot etc.):
|
||||
Logo with smaller aspect ratio (for Telegram bot etc.): 👾 - [emojipedia](https://emojipedia.org/alien-monster/)
|
||||
|
||||

|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export const cfg = {
|
|||
height: Number(process.env.HEIGHT) || 1280, // height of the opened browser
|
||||
timeout: (Number(process.env.TIMEOUT) || 20) * 1000, // 20s, default for playwright is 30s
|
||||
novnc_port: process.env.NOVNC_PORT, // running in docker if set
|
||||
notify: process.env.NOTIFY, // apprise notification services
|
||||
// auth epic-games
|
||||
eg_email: process.env.EG_EMAIL || process.env.EMAIL,
|
||||
eg_password: process.env.EG_PASSWORD || process.env.PASSWORD,
|
||||
|
|
|
|||
19
util.js
19
util.js
|
|
@ -76,3 +76,22 @@ export const stealth = async (context) => {
|
|||
await context.addInitScript(evasion.cb, evasion.a);
|
||||
}
|
||||
};
|
||||
|
||||
// notifications via apprise CLI
|
||||
import { exec } from 'child_process';
|
||||
import { cfg } from './config.js';
|
||||
|
||||
export const notify = (html) => {
|
||||
if (!cfg.notify) return;
|
||||
exec(`apprise ${cfg.notify} -i html -b '${html}'`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
if (error.message.includes('command not found')) {
|
||||
console.info('Run `pip install apprise`. See https://github.com/vogler/free-games-claimer#notifications');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (stderr) console.error(`stderr: ${stderr}`);
|
||||
if (stdout) console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue