Updated app.js (automated)

mane
Mia Raindrops 2 weeks ago
parent 6ecb6d7d7d
commit 0931c055e7
Signed by: Mia Raindrops
GPG Key ID: EFBDC68435A574B7

@ -5,7 +5,7 @@ const axios = require('axios');
const si = require('systeminformation');
global.luna_version = "1.4.0";
global.dsb_version = 6;
global.dsb_version = 7;
global.lastSentData = {};
global.clientsList = {};
global.lastDataUpdate = 0;
@ -57,7 +57,7 @@ app.whenReady().then(() => {
function updateTray() {
let template = [
{ label: 'Luna ' + luna_version, type: 'normal', enabled: false, icon: __dirname + "/icons/menu/16x16@2x.png" },
{ label: 'Luna ' + luna_version + '-' + dsb_version, type: 'normal', enabled: false, icon: __dirname + "/icons/menu/16x16@2x.png" },
{ label: 'Last updated ' + timeAgo(global.lastDataUpdate), type: 'normal', enabled: false },
];
@ -71,7 +71,7 @@ function updateTray() {
const contextMenu = Menu.buildFromTemplate(template);
tray.setToolTip('Luna ' + luna_version);
tray.setToolTip('Luna ' + luna_version + '-' + dsb_version);
tray.setContextMenu(contextMenu);
}
@ -196,17 +196,19 @@ global.startApp = async () => {
if (!(await axios("https://ponies.equestria.horse/api/session", {
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
})).data['created']) {
throw new Error();
clearInterval(global.i1); clearInterval(global.i2); clearInterval(global.i3); clearInterval(global.i4);
require('./auth')();
return;
}
} catch (e) {
clearInterval(global.i1); clearInterval(global.i2); clearInterval(global.i3); clearInterval(global.i4);
require('./auth')();
return;
console.error(e);
}
await axios("https://ponies.equestria.horse/api/rename?name=" + encodeURIComponent("Luna " + luna_version + " (Desktop DSB " + dsb_version + ", " + hostname() + ", " + ((await si.osInfo()).distro) + ")"), {
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
try {
await axios("https://ponies.equestria.horse/api/rename?name=" + encodeURIComponent("Luna " + luna_version + " (Desktop DSB " + dsb_version + ", " + hostname() + ", " + ((await si.osInfo()).distro) + ")"), {
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
} catch (e) {}
refresh();
systemProfile();
@ -217,24 +219,24 @@ global.startApp = async () => {
global.i2 = setInterval(async () => {
try {
let data = (await axios("https://ponies.equestria.horse/api/session", {
if (!(await axios("https://ponies.equestria.horse/api/session", {
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
})).data;
console.log(data);
if (!data['created']) {
throw new Error();
})).data['created']) {
clearInterval(global.i1); clearInterval(global.i2); clearInterval(global.i3); clearInterval(global.i4);
require('./auth')();
return;
}
} catch (e) {
clearInterval(global.i1); clearInterval(global.i2); clearInterval(global.i3); clearInterval(global.i4);
require('./auth')();
return;
console.error(e);
}
await axios("https://ponies.equestria.horse/api/rename?name=" + encodeURIComponent("Luna " + luna_version + " (Desktop DSB " + dsb_version + ", " + hostname() + ", " + ((await si.osInfo()).distro) + ")"), {
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
try {
await axios("https://ponies.equestria.horse/api/rename?name=" + encodeURIComponent("Luna " + luna_version + " (Desktop DSB " + dsb_version + ", " + hostname() + ", " + ((await si.osInfo()).distro) + ")"), {
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
});
} catch (e) {
console.error(e);
}
try {
await axios("https://ponies.equestria.horse/api/computer?type=heartbeat", {