This commit is contained in:
Bingus_Violet 2024-02-07 21:59:21 -06:00
parent 30a2b53c4b
commit 9a7684c048

View file

@ -24,6 +24,7 @@ var highlight = config.highlightedWords
var uptime = Date.now() var uptime = Date.now()
var lastLanyardUpdate = Date.now() var lastLanyardUpdate = Date.now()
var lastPong = Date.now()
var thumbCount = 0 var thumbCount = 0
@ -381,27 +382,29 @@ async function pageUpdate() {
// Lanyard Stuffs // Lanyard Stuffs
var lanyard = new WebSocket('wss://api.lanyard.rest/socket') function socketeer() {
var lanyard = new WebSocket('https://api.violets-purgatory.dev')
function beat(dur) { function ping(dur) {
lanyard.send(JSON.stringify({ lanyard.send(JSON.stringify({
op: 3 op: 3
})) }))
setTimeout(() => { setTimeout(() => {
beat(dur) ping(dur)
if (Date.now() - lastPong > 120000) {
console.log("FUCK!")
lanyard.close()
socketeer()
}
}, dur); }, dur);
} }
lanyard.addEventListener("message", async (res) => { lanyard.addEventListener("message", async (res) => {
var data = JSON.parse(res.data) var data = JSON.parse(res.data)
if (data.op == 1) { if (data.op == 1) {
beat(data.d.heartbeat_interval) ping(30000)
lanyard.send(JSON.stringify({ lastPong = Date.now()
op: 2, } else if (data.op == 3) {
d: { lastPong = Date.now()
subscribe_to_id: "534132311781015564"
}
}))
} else if (data.op == 0) { } else if (data.op == 0) {
lanyardData = data.d lanyardData = data.d
lastLanyardUpdate = Date.now() lastLanyardUpdate = Date.now()
@ -439,7 +442,10 @@ lanyard.addEventListener("message", async (res) => {
} }
} }
}) })
}
socketeer()
app.get('/', async (req, res) => { app.get('/', async (req, res) => {
var html = await (pageUpdate()) var html = await (pageUpdate())