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