From 6e81ebcf6e540de66a371d235dd833232ccaf9e5 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Mon, 4 Nov 2019 23:19:45 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=95=F0=9F=8E=B0=20Checkpoint=20./serve?= =?UTF-8?q?r.js:933874/10600?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index d0266f2..6da0548 100644 --- a/server.js +++ b/server.js @@ -104,7 +104,7 @@ request.post( }, function(error, response, body) { console.log(body); - const token = JSON.parse(body)["access_token"]; + const accessToken = JSON.parse(body)["access_token"]; const loop = () => { console.log("loop", lastClosed); if (lastSeen < new Date() - 2 * 60 * 1000 && lastClosed < lastSeen) { @@ -112,7 +112,24 @@ request.post( lastClosed = new Date(); //lastNofified = new Date(); //https.post ... send message to Fuz process.env.MATRIXROOM - + request.put( + { + url: + "https://" + + process.env.MATRIXUSERNAME.substring( + process.env.MATRIXUSERNAME.indexOf(":") + 1 + ) + + "/_matrix/client/r0/rooms/" + process.env.MATRIXROOM + "/send/m.room.message/" + String(millis()) + "?access_token=" + accessToken + "&limit=1", + body: JSON.stringify({ + msgtype: "m.text", + body: process.env.MATRIXMESSAGE + }), + headers: { + "Content-Type": "application/json" + } + }, + function(error, response, body) {} + ); try { fs.writeFileSync( db,