From 0c01e826d93804addd9fae9bb377227fd07ebab3 Mon Sep 17 00:00:00 2001 From: azures04 Date: Sun, 11 May 2025 07:30:13 +0200 Subject: [PATCH] sync --- config.json | 3 ++- main.js | 39 +++++++++++++++++++++++++++++++++++---- modules/rpc.js | 23 +++++++++++++---------- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/config.json b/config.json index 3cd6f5a..93362ad 100644 --- a/config.json +++ b/config.json @@ -6,7 +6,8 @@ "checkBanStatus": "/api/v1/ban/iam", "telemetry": "/api/v1/telemetry", "gameFiles": "/api/v1/file/game", - "downloadFile": "/api/v1/file/game/download" + "downloadFile": "/api/v1/file/game/download", + "countdown": "/api/v1/countdown" }, "websockets": { "base": { diff --git a/main.js b/main.js index 6721989..5ebc0f9 100644 --- a/main.js +++ b/main.js @@ -133,6 +133,17 @@ async function checkIfIAmBanned() { } } +async function checkCoutdown(uuid) { + try { + const response = await fetch(`${config.api.base}${config.api.endpoints.countdown}/${uuid}`) + const json = await response.json() + console.log(json) + return json.success + } catch (error) { + return false + } +} + app.whenReady().then(() => { createLauncherWindow() app.on("activate", async () => { @@ -189,8 +200,18 @@ ipcMain.on("call", async (event, data) => { if (data.args.trim() != "") { auth = Authenticator.getAuth(data.args.username, data.args.password) launcherSettings.set("auth", { token: (await auth).access_token, type: "mojang", clientToken: (await auth).client_token }) - await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${(await auth).uuid}`) - await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + if (await checkCoutdown((await auth).uuid)) { + await launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + await fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${(await auth).uuid}`) + } else { + await launcherWindow.loadURL("https://nyancraft.catboat.fr") + await launcherWindow.webContents.insertCSS("a.download-button { display: none; } #return-button { app-region: no-drag } ") + await launcherWindow.webContents.executeJavaScript(` + const returnButton = document.querySelector(\"#return-button\") + returnButton.innerText = "Fermer le launcher" + returnButton.onclick = () => system.call("window::close") + `) + } } else { dialog.showErrorBox("Erreur", "Le mot de passe n'est pas défini. Les comptes crackés ne sont pas supporté par le launcher.") } @@ -203,8 +224,18 @@ ipcMain.on("call", async (event, data) => { auth = token.mclc() console.log(auth.meta) launcherSettings.set("auth", { token: auth.meta, type: "msa", clientToken: auth.client_token }) - launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) - fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`) + if (await checkCoutdown(auth.uuid)) { + launcherWindow.loadFile(path.join(__dirname, "app", "logged.html")) + fetch(`${config.api.base}${config.api.endpoints.telemetry}/${hwid.getHWID()}/${auth.uuid}`) + } else { + await launcherWindow.loadURL("https://nyancraft.catboat.fr") + await launcherWindow.webContents.insertCSS("a.download-button { display: none; } #return-button { app-region: no-drag } ") + await launcherWindow.webContents.executeJavaScript(` + const returnButton = document.querySelector(\"#return-button\") + returnButton.innerText = "Fermer le launcher" + returnButton.onclick = () => system.call("window::close") + `) + } } catch (error) { console.error(error) if (error == "error.gui.closed") { diff --git a/modules/rpc.js b/modules/rpc.js index 2fb32da..25de4da 100644 --- a/modules/rpc.js +++ b/modules/rpc.js @@ -3,19 +3,22 @@ const RPC = require("discord-rpc") class DiscordRPC { constructor() { readonly: this.activity = { - details: "Actif dans le launcher", + details: "Officiel | Solva x Alcaz", + timestamps : { start: Date.now() }, assets: { - large_image: "logo", - large_text: "CatBoat Minecraft Launcher" + large_image: "rpc_catboat_large", + large_text: "CatBoat Launcher", + small_image : "alflamme_comm_legoshi", + small_text: "by TheAlfiTeam", }, buttons: [ { - label: "Discord", - url: "https://discord.com/invite/catboat" + "label": "Discord", + "url": "https://discord.gg/catboat" }, { - label: "CatBoat", - url: "https://catboat.fr/" + "label": "Download Launcher", + "url": "https://catboat.thealfigame.fr" } ], instance: true @@ -30,12 +33,12 @@ class DiscordRPC { this.client.request("SET_ACTIVITY", { pid: process.pid, activity: this.activity }) console.log("The Discord Rich Presence has been set successfully.") }) - this.client.login({ clientId: "1365563093157154868" }).catch(e => { - console.log(e) + this.client.login({ clientId: "1259291027148115988" }).catch(e => { console.log("Silent client detected: the activity status has been disabled.") + console.log(e) this.isEnabled = false }).then(r => this.isEnabled = true) - .catch(err => console.log) + .catch(err => console.log(err)) } }