-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
69 lines (57 loc) · 1.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const client = require("discord-rich-presence")(yourclientid);
const { F1TelemetryClient, constants } = require("f1-2020-client");
const { app, BrowserWindow } = require("electron");
const { PACKETS } = constants;
const Tracks = require("./config/tracks.json");
const Session = require("./config/SessionTypes.json");
const CarType = require("./config/Cars.json");
const f1Client = new F1TelemetryClient();
let date = Date.now();
let interval;
f1Client.start();
resetStatus = () => {
client.updatePresence({
state: "In the paddock",
largeImageKey: "f12020",
startTimestamp: date,
});
};
f1Client.on(PACKETS.session, (data) => {
if (interval) {
clearInterval(interval);
}
client.updatePresence({
details: `${Session[data.m_sessionType].Type} at ${
Tracks[data.m_trackId].Name
}`,
state: `${CarType[data.m_formula].CarType}`,
largeImageKey: "f12020",
startTimestamp: date,
});
console.log(data);
interval = setInterval(() => {
resetStatus();
}, 5000);
});
client.updatePresence({
state: "In the paddock",
largeImageKey: "f12020",
startTimestamp: date,
});
//Electron
function createWindow() {
// Crea la finestra del browser
const win = new BrowserWindow({
width: 300,
height: 150,
resizable: false,
webPreferences: {
nodeIntegration: true,
},
autoHideMenuBar: true,
icon: "./assets/icons/win/icon.ico",
});
// and load the index.html of the app.
win.loadFile("index.html");
}
app.whenReady().then(createWindow);