h
This commit is contained in:
parent
47c972a8ea
commit
bcfad68767
9
index.js
9
index.js
|
@ -175,14 +175,19 @@ ${stats.isNewRecord ? `🎉 NEW RECORD! 🎉 A new record has been set, at ${sta
|
|||
console.warn("MATRIX_BASE_URL, MATRIX_ROOM_ID or MATRIX_ACCESS_TOKEN not set, skipping Matrix message.");
|
||||
return;
|
||||
}
|
||||
await fetch(`${process.env.MATRIX_BASE_URL}/_matrix/client/v3/rooms/${encodeURIComponent(process.env.MATRIX_ROOM_ID)}/send/m.room.message/${Math.random()}`, {
|
||||
const resp = await fetch(`${process.env.MATRIX_BASE_URL}/_matrix/client/v3/rooms/${encodeURIComponent(process.env.MATRIX_ROOM_ID)}/send/m.room.message/${Math.random()}`, {
|
||||
method: 'PUT',
|
||||
body: message,
|
||||
headers: {
|
||||
"Authorization": `Bearer ${process.env.MATRIX_ACCESS_TOKEN}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
})
|
||||
});
|
||||
if (!resp.ok) {
|
||||
console.error("Failed to send Matrix message:", resp.status, await resp.text());
|
||||
} else {
|
||||
console.log("Matrix message sent successfully.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue