Contains software for notifying the user, when the price of monitored cryptocurrency, drops past a set threshold.
To add a Custom Notification Provider:
- Create a file entry in the
scripts/nodejs-crypto-dip-alert/notifications
folder ending with.notification.js
- Expose a
notify
function frommodule.exports
- The function is an async function so return a Promise
- Function has the following as parameters
coin
maxPrice
currentPrice
dipThreshold
- You can add configs to the
.env
file to determine if custom notif will be used. - e.g.
NOTIFY_YORUBA=
NOTIFY_MAILGUN=
/**
* posts a notification in the terminal console
* @param {{symbol: string, priceUsd: number}} coin
* @param {number} maxPrice
* @param {number} currentPrice
* @param {number} dipThreshold
*/
const notify = async (coin, maxPrice, currentPrice, dipThreshold) => {
// early return if not set in env flags
if (!process.env.NOTIFY_YORUBA || process.env.NOTIFY_YORUBA !== 'true') return;
console.log(`[🚨🚨🚨💰🚨🚨🚨] Egbami, ye, 😢 ${coin.symbol} ti jona`);
console.log(`[👀] Iwọn ti o pọju: ${maxPrice} `);
console.log(`[👀] Ni in si: ${currentPrice} `);
console.log(`[👀] Àbáwọlé: ${dipThreshold} `);
// await here if you need to
return Promise.resolve();
}
module.exports = notify;