mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-22 13:37:29 +00:00
👀🏨 Checkpoint
./server.js:933874/21476
This commit is contained in:
parent
6e81ebcf6e
commit
1d6feef28c
32
server.js
32
server.js
@ -9,6 +9,7 @@ var lastClosed = new Date("1970-01-01");
|
|||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const db = "./.data/data.json";
|
const db = "./.data/data.json";
|
||||||
|
const closingTimeout = 5 * 60 * 1000; // 5 mins
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var content = fs.readFileSync(db, "utf8");
|
var content = fs.readFileSync(db, "utf8");
|
||||||
@ -119,7 +120,13 @@ request.post(
|
|||||||
process.env.MATRIXUSERNAME.substring(
|
process.env.MATRIXUSERNAME.substring(
|
||||||
process.env.MATRIXUSERNAME.indexOf(":") + 1
|
process.env.MATRIXUSERNAME.indexOf(":") + 1
|
||||||
) +
|
) +
|
||||||
"/_matrix/client/r0/rooms/" + process.env.MATRIXROOM + "/send/m.room.message/" + String(millis()) + "?access_token=" + accessToken + "&limit=1",
|
"/_matrix/client/r0/rooms/" +
|
||||||
|
process.env.MATRIXROOM +
|
||||||
|
"/send/m.room.message/" +
|
||||||
|
new Date().getTime() +
|
||||||
|
"?access_token=" +
|
||||||
|
accessToken +
|
||||||
|
"&limit=1",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
msgtype: "m.text",
|
msgtype: "m.text",
|
||||||
body: process.env.MATRIXMESSAGE
|
body: process.env.MATRIXMESSAGE
|
||||||
@ -128,17 +135,22 @@ request.post(
|
|||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(error, response, body) {}
|
function(error, response, body2) {
|
||||||
|
if (!error) {
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(
|
||||||
|
db,
|
||||||
|
JSON.stringify({ fuzIsOpen, lastSeen, lastClosed })
|
||||||
|
);
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
console.log(body2)
|
||||||
|
setTimeout(loop, 10 * 1000);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
try {
|
} else {
|
||||||
fs.writeFileSync(
|
setTimeout(loop, 10 * 1000);
|
||||||
db,
|
|
||||||
JSON.stringify({ fuzIsOpen, lastSeen, lastClosed })
|
|
||||||
);
|
|
||||||
} catch (err) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(loop, 10 * 1000);
|
|
||||||
};
|
};
|
||||||
setTimeout(loop, 1 * 1000); // give some time for presence button to show up (1 min)
|
setTimeout(loop, 1 * 1000); // give some time for presence button to show up (1 min)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user