1
0
mirror of https://api.glitch.com/git/presence-button synced 2024-11-05 06:47:29 +00:00

🍎👂 Checkpoint

./server.js:933874/6555
This commit is contained in:
Glitch (hello-express) 2019-11-03 23:06:02 +00:00
parent 647bfe55a4
commit 757b40f737

View File

@ -63,7 +63,7 @@ app.get("/status", (req, res) => {
fuzIsOpen = req.query.fuzisopen === "1";
lastSeen = new Date();
try {
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen }));
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen, lastClosed }));
} catch (err) {}
res.sendStatus(200);
@ -78,6 +78,11 @@ const loop = () => {
if (lastSeen < new Date() - 2 * 60 * 1000 && lastClosed < lastSeen) {
// the Fuz is newly closed, notify on matrix and write file to survive reboot
lastClosed = new Date();
//lastNofified = new Date();
//https.post ... send message to Fuz process.env.MATRIXROOM
try {
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen, lastClosed }));
} catch (err) {}
}
setTimeout(loop, 10 * 1000);