h
This commit is contained in:
parent
b77a9aa946
commit
cd9b914455
11
index.js
11
index.js
|
@ -163,12 +163,17 @@ ${stats.isNewRecord ? `🎉 NEW RECORD! 🎉 A new record has been set, at ${sta
|
||||||
</table>
|
</table>
|
||||||
`.split('\n').map(s => s.trim()).join(''),
|
`.split('\n').map(s => s.trim()).join(''),
|
||||||
"tel.litenet.call_stats_summary": {
|
"tel.litenet.call_stats_summary": {
|
||||||
...stats, date: yesterday
|
...stats,
|
||||||
|
date: yesterday,
|
||||||
|
allTimeRecordData: records.callRecord
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.LOG_MESSAGES) {
|
||||||
console.log("Sending Matrix message:", JSON.stringify(message, null, 2));
|
console.log("Sending Matrix message:", JSON.stringify(message, null, 2));
|
||||||
console.log("Plaintext:\n", message.body);
|
console.log("Plaintext:\n", message.body);
|
||||||
console.log("HTML:\n", message.formatted_body);
|
console.log("HTML:\n", message.formatted_body);
|
||||||
|
}
|
||||||
|
|
||||||
if (!process.env.NOOP) {
|
if (!process.env.NOOP) {
|
||||||
if (!process.env.MATRIX_BASE_URL || !process.env.MATRIX_ROOM_ID || !process.env.MATRIX_ACCESS_TOKEN) {
|
if (!process.env.MATRIX_BASE_URL || !process.env.MATRIX_ROOM_ID || !process.env.MATRIX_ACCESS_TOKEN) {
|
||||||
|
@ -218,7 +223,10 @@ async function sendSummaryDiscord(yesterday, stats) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = { embeds: [ embed ] };
|
const payload = { embeds: [ embed ] };
|
||||||
|
|
||||||
|
if (process.env.LOG_MESSAGES)
|
||||||
console.log("Sending Discord message:", JSON.stringify(payload, null, 2));
|
console.log("Sending Discord message:", JSON.stringify(payload, null, 2));
|
||||||
|
|
||||||
if (hook && !process.env.NOOP)
|
if (hook && !process.env.NOOP)
|
||||||
await hook.send(payload);
|
await hook.send(payload);
|
||||||
}
|
}
|
||||||
|
@ -227,5 +235,6 @@ if (process.env.NOOP || process.env.RUN_ONCE) {
|
||||||
sendSummary();
|
sendSummary();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Scheduling...");
|
console.log("Scheduling...");
|
||||||
const schedule = cron.schedule("0 1 * * *", sendSummary);
|
const schedule = cron.schedule("0 1 * * *", sendSummary);
|
||||||
|
|
Loading…
Reference in a new issue