NOTIFY to set notification services

This commit is contained in:
Ralf Vogler 2023-01-25 16:44:42 +01:00
parent e57c2c4408
commit 2f0961b1b3
3 changed files with 34 additions and 6 deletions

19
util.js
View file

@ -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}`);
});
}