Nick: slack alerts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import axios from "axios";
|
||||
|
||||
export async function sendSlackWebhook(
|
||||
message: string,
|
||||
alertEveryone: boolean = false
|
||||
) {
|
||||
const webhookUrl = process.env.SLACK_WEBHOOK_URL;
|
||||
const messagePrefix = alertEveryone ? "<!channel> " : "";
|
||||
const payload = {
|
||||
text: `${messagePrefix} ${message}`,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post(webhookUrl, payload, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
console.log("Webhook sent successfully:", response.data);
|
||||
} catch (error) {
|
||||
console.error("Error sending webhook:", error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user