mirror of
https://github.com/multipleof4/KalBot.git
synced 2026-03-16 21:41:02 +00:00
Feat: ntfy notification helper
This commit is contained in:
21
lib/notify.js
Normal file
21
lib/notify.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Send a push notification via ntfy.
|
||||||
|
*/
|
||||||
|
export async function notify(message, title = 'Kalbot', priority = 'default', tags = 'robot') {
|
||||||
|
const url = process.env.NTFY_URL;
|
||||||
|
if (!url) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
body: message,
|
||||||
|
headers: {
|
||||||
|
'Title': title,
|
||||||
|
'Priority': priority,
|
||||||
|
'Tags': tags
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[Notify] Error:', e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user