removed Python and the Python Script, added the apprise-api docker container to the Docker-compose to send notificaiton
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
import * as Bun from "bun";
|
||||
|
||||
export async function sendNotification(title: string, body: string, click?: string | null) {
|
||||
const command = [
|
||||
"python3",
|
||||
"./src/notification.py",
|
||||
`--title=${title}`,
|
||||
`--body=${body}`,
|
||||
];
|
||||
if ( click ) {
|
||||
command.push(`--click=${click}`);
|
||||
export async function sendNotification(title: string, body: string, link?: string | null) {
|
||||
console.dir({
|
||||
sendNotification: {
|
||||
title,
|
||||
body,
|
||||
link
|
||||
}
|
||||
const proc = Bun.spawn(command);
|
||||
const text = await proc.stdout.text();
|
||||
console.log("sendNotification: " + text);
|
||||
}
|
||||
});
|
||||
const response = await fetch("http://apprise:8000/notify", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
urls: [
|
||||
`ntfys://${process.env.ntfy_username}:${process.env.ntfy_password}@${process.env.ntfy_host}/${process.env.ntfy_topic}${ link ? `?click=${link}`: "?click=https://77th-jsoc.com/#/events" }`,
|
||||
`discord://${process.env.dc_webhook}?avatar_url=${process.env.dc_avatar_url}&botname=${process.env.dc_botname}`
|
||||
].join(","),
|
||||
title: title,
|
||||
body: body,
|
||||
format: "text"
|
||||
})
|
||||
});
|
||||
const responseBody = await response.json();
|
||||
return responseBody;
|
||||
}
|
||||
Reference in New Issue
Block a user