Updated 8 files, deleted 2 files and renamed 4 files (automated)

mane
Mia Raindrops 4 weeks ago
parent fd7431680b
commit 37123d8481
Signed by: Mia Raindrops
GPG Key ID: EFBDC68435A574B7

@ -10,6 +10,19 @@ commands = {
localStorage.setItem("username", userName);
systemMessage(sl("commands/nick/other", [["%2", oldUserName], ["%1", argument]]), l("commands/nick/self").replace("%1", argument));
},
"lang": (argument, _) => {
if (require('fs').existsSync("../shared/lang/" + argument.trim().replaceAll("/", "-") + ".json")) {
localStorage.setItem("language", argument.trim());
} else {
localStorage.setItem("language", "en");
}
location.reload();
},
"switch": async (argument, _) => {
await updateServer();
location.reload();
},
"background": (argument, _) => {
if (argument.trim() === "") argument = null;
@ -166,9 +179,9 @@ commands = {
},
"version": (_1, _2) => {
if (window.connected) {
localSystemMessage(l("commands/version/localchat") + " " + stripHTML(window.version) + "<br>" + l("commands/version/node") + " " + process.versions.node + "<br>" + l("commands/version/chrome") + " " + process.versions.chrome + "<br>" + l("commands/version/electron") + " " + process.versions.electron + "<br>" + l("commands/version/server") + " " + stripHTML(window.serverVersion), true);
localSystemMessage(l("commands/version/localchat") + " " + stripHTML(window.version) + "<br>" + l("commands/version/launcher") + " " + stripHTML(window.launcherVersion) + "<br>" + l("commands/version/node") + " " + process.versions.node + "<br>" + l("commands/version/chrome") + " " + process.versions.chrome + "<br>" + l("commands/version/electron") + " " + process.versions.electron + "<br>" + l("commands/version/server") + " " + stripHTML(window.serverVersion), true);
} else {
localSystemMessage(l("commands/version/localchat") + " " + stripHTML(window.version) + "<br>" + l("commands/version/node") + " " + process.versions.node + "<br>" + l("commands/version/chrome") + " " + process.versions.chrome + "<br>" + l("commands/version/electron") + " " + process.versions.electron, true);
localSystemMessage(l("commands/version/localchat") + " " + stripHTML(window.version) + "<br>" + l("commands/version/launcher") + " " + stripHTML(window.launcherVersion) + "<br>" + l("commands/version/node") + " " + process.versions.node + "<br>" + l("commands/version/chrome") + " " + process.versions.chrome + "<br>" + l("commands/version/electron") + " " + process.versions.electron, true);
}
},
"changelog": (_1, _2) => {

@ -15,13 +15,13 @@ function mergeRecursive(obj1, obj2) {
}
function loadLang() {
let language = window.betaVersion ? (localStorage.getItem("language") ?? "en-US") : "en-US";
let language = window.betaVersion ? (localStorage.getItem("language") ?? "en") : "en";
window.langName = language;
delete window.lang;
window.lang = mergeRecursive(require('../shared/lang/en-US.json'), require('../shared/lang/' + language.replaceAll("/", "-") + ".json"));
window.lang = mergeRecursive(require('../shared/lang/en.json'), require('../shared/lang/' + language.replaceAll("/", "-") + ".json"));
if (language === "en-US") {
if (language === "en") {
document.getElementById("oobe-language-badge").style.display = "";
} else {
document.getElementById("oobe-language-badge").style.display = "none";
@ -72,5 +72,5 @@ if (localStorage.getItem("oobe-" + version) === "1") {
document.getElementById("oobe").style.display = "none";
connect();
} else {
document.getElementById("oobe-dropdown-language").value = localStorage.getItem("language") ?? "en-US";
document.getElementById("oobe-dropdown-language").value = localStorage.getItem("language") ?? "en";
}

@ -3,7 +3,7 @@
<head>
<script>
//window.version = "2.4";
window.version = "2.5-beta.2023-05-06";
window.version = "2.5-beta.2023-05-08";
window.betaVersion = true;
window.changeLog = `
Thanks for using Localchat. You are currently running Localchat version %1, below are all the changes in that version compared to the previous version.
@ -14,6 +14,14 @@ Localchat Client 2.5 Beta:
- Added a "New" badge next to the language selector
- Fixed translations not loading in some cases
- Fixed being able to drag title bar icons on Linux
- Fixed odd titlebar behavior on KDE Plasma
- Both server and client data are in the same place:
- ~/.localchat on Linux
- ~/Library/Application Support/Localchat on macOS
- %appdata%/.localchat on Windows
* Requires Launcher 1.4.0 or newer
- Added /lang to change the language after OOBE
- Added /switch to import another .ltcsc file
Here is what changed in the previous versions:
* Localchat Client 2.4:
@ -639,10 +647,10 @@ Here is what changed in the previous versions:
<div style="margin-top: 50px;">
<div id="oobe-i18n-beta">
<select class="oobe-dropdown oobe-item-first" id="oobe-dropdown-language" onchange="changeLanguageOOBE();">
<option value="en-US">English</option>
<option value="fr-FR">français [BETA]</option>
<option value="es-ES">Español [BETA]</option>
<option value="de-DE">Deutsch [BETA]</option>
<option value="en">English</option>
<option value="fr">français [BETA]</option>
<option value="es">Español [BETA]</option>
<option value="de">Deutsch [BETA]</option>
</select>
<div id="oobe-language-badge">New</div>
<img src="icons/language.svg" class="oobe-dropdown-icon oobe-beta-icon">
@ -670,6 +678,12 @@ Here is what changed in the previous versions:
}
window.applicationData = localStorage.getItem("application-data");
window.launcherVersion = localStorage.getItem("launcher") ?? "-";
require('electron').ipcRenderer.on('launcher', (_, data) => {
window.launcherVersion = data;
localStorage.setItem("launcher", window.launcherVersion);
})
require('electron').ipcRenderer.on('path', (_, data) => {
window.applicationData = data;

@ -2,10 +2,32 @@ const { app, BrowserWindow, globalShortcut, ipcMain, dialog } = require('electro
const path = require('path');
const os = require("os");
const {writeFileSync, existsSync, unlinkSync} = require("fs");
const fs = require("fs");
let localchatDataRoot = (os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : (os.platform() === "darwin" ? os.homedir() + "/Library/Application Support" : os.homedir())) + "/.localchat";
if (!global._localchatLauncherVersion) {
dialog.showErrorBox("Update required", "Please update to Localchat Client Launcher version 1.4.0 or newer to continue using Localchat, you are currently running version " + app.getVersion() + ". You can get a copy of the updated launcher from your local administrator.");
process.exit();
}
if (!fs.existsSync(localchatDataRoot)) fs.mkdirSync(localchatDataRoot);
if (!fs.existsSync(localchatDataRoot + "/client")) fs.mkdirSync(localchatDataRoot + "/client");
if (!fs.existsSync(localchatDataRoot + "/client/session")) fs.mkdirSync(localchatDataRoot + "/client/session");
if (!fs.existsSync(localchatDataRoot + "/client/data")) fs.mkdirSync(localchatDataRoot + "/client/data");
if (!fs.existsSync(localchatDataRoot + "/client/logs")) fs.mkdirSync(localchatDataRoot + "/client/logs");
app.setPath("userData", localchatDataRoot + "/client/data");
app.setPath("sessionData", localchatDataRoot + "/client/session");
app.setAppLogsPath(localchatDataRoot + "/client/logs");
if (require('os').platform() !== "darwin" && require('os').platform() !== "win32" && require('os').platform() !== "linux") return;
const createWindow = () => {
app.setPath("userData", (os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : os.homedir()) + "/.localchat/client");
app.setPath("sessionData", (os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : os.homedir()) + "/.localchat/client/_session");
app.setAppLogsPath((os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : os.homedir()) + "/.localchat/client/_logs");
global.mainWindow = new BrowserWindow({
width: 500,
minWidth: 500,
@ -32,7 +54,8 @@ const createWindow = () => {
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
contextIsolation: false,
additionalArguments: "--user-data-dir=\"" + localchatDataRoot + "/client" + "\""
}
});
@ -40,6 +63,7 @@ const createWindow = () => {
if (os.platform() === "win32") mainWindow.setContentProtection(true);
mainWindow.send("path", app.getPath("userData"));
mainWindow.send("launcher", global._localchatLauncherVersion);
ipcMain.handle("open-server", async (event) => {
let select = dialog.showOpenDialogSync({
@ -98,6 +122,15 @@ const createWindow = () => {
mainWindow.show();
try { loaderWindow.close(); } catch (e) {}
setTimeout(() => {
mainWindow.setTitle("");
setTimeout(() => {
mainWindow.setTitle("");
mainWindow.setTitle("Localchat");
}, 1000);
}, 1000);
});
ipcMain.on('past-oobe', () => {

@ -1,5 +1,24 @@
const { app, BrowserWindow, globalShortcut, ipcMain } = require('electron');
const path = require('path');
const fs = require("fs");
const os = require("os");
let localchatDataRoot = (os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : (os.platform() === "darwin" ? os.homedir() + "/Library/Application Support" : os.homedir())) + "/.localchat";
if (!fs.existsSync(localchatDataRoot)) fs.mkdirSync(localchatDataRoot);
if (!fs.existsSync(localchatDataRoot + "/client")) fs.mkdirSync(localchatDataRoot + "/client");
if (!fs.existsSync(localchatDataRoot + "/client/session")) fs.mkdirSync(localchatDataRoot + "/client/session");
if (!fs.existsSync(localchatDataRoot + "/client/data")) fs.mkdirSync(localchatDataRoot + "/client/data");
if (!fs.existsSync(localchatDataRoot + "/client/logs")) fs.mkdirSync(localchatDataRoot + "/client/logs");
if (fs.existsSync(localchatDataRoot + "/client/launcher")) {
process.chdir(localchatDataRoot + "/client/launcher");
require(localchatDataRoot + "/client/launcher/main.js");
}
app.setPath("userData", localchatDataRoot + "/client/data");
app.setPath("sessionData", localchatDataRoot + "/client/session");
app.setAppLogsPath(localchatDataRoot + "/client/logs");
require('@electron/remote/main').initialize();
@ -33,6 +52,7 @@ const createWindow = () => {
ipcMain.on('start', (_, path) => {
process.chdir(path);
global._localchatPath = path;
global._localchatLauncherVersion = app.getVersion();
require(path + "/main.js");
});

@ -1,5 +1,5 @@
{
"version": "1.3.3",
"version": "1.4.0",
"dependencies": {
"@electron/remote": "^2.0.9",
"axios": "^1.3.5",

@ -5,8 +5,19 @@ const uuid = require('uuid-v4');
const fs = require('fs');
const crypto = require('crypto');
const zlib = require("zlib");
const os = require("os");
const version = "1.10";
let localchatDataRoot = (os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : (os.platform() === "darwin" ? os.homedir() + "/Library/Application Support" : os.homedir())) + "/.localchat";
if (!fs.existsSync(localchatDataRoot)) fs.mkdirSync(localchatDataRoot);
if (!fs.existsSync(localchatDataRoot + "/server")) fs.mkdirSync(localchatDataRoot + "/server");
if (!fs.existsSync(localchatDataRoot + "/server/exports")) fs.mkdirSync(localchatDataRoot + "/server/exports");
if (!fs.existsSync(localchatDataRoot + "/server/config")) fs.mkdirSync(localchatDataRoot + "/server/config");
if (!fs.existsSync(localchatDataRoot + "/server/logs")) fs.mkdirSync(localchatDataRoot + "/server/logs");
if (!fs.existsSync(localchatDataRoot + "/server/data")) fs.mkdirSync(localchatDataRoot + "/server/data");
process.chdir(localchatDataRoot + "/server");
const version = "1.11";
const port = 27342;
function mergeRecursive(obj1, obj2) {
@ -26,24 +37,25 @@ function mergeRecursive(obj1, obj2) {
}
function loadLang(lang) {
let language = lang ?? "en-US";
let language = lang ?? "en";
try {
return mergeRecursive(require('../shared/lang/en-US.json'), require('../shared/lang/' + language.replaceAll("/", "-") + ".json"));
return mergeRecursive(require('../shared/lang/en.json'), require('../shared/lang/' + language.replaceAll("/", "-") + ".json"));
} catch (e) {
try {
return mergeRecursive(require('../../shared/lang/en-US.json'), require('../../shared/lang/' + language.replaceAll("/", "-") + ".json"));
return mergeRecursive(require('../../shared/lang/en.json'), require('../../shared/lang/' + language.replaceAll("/", "-") + ".json"));
} catch (e) {
try {
return require('../shared/lang/en-US.json');
return require('../shared/lang/en.json');
} catch (e) {
return require('../../shared/lang/en-US.json');
return require('../../shared/lang/en.json');
}
}
}
}
function l(path, lang) {
console.log(lang);
let line = 'langData["' + path.split("/").map(i => i.replaceAll('"', "'")).join('"]["') + '"]';
let langData = loadLang(lang);
@ -79,46 +91,46 @@ const readline = require('readline').createInterface({
readline.question("Enter the IP address users would use to connect to the server: ", (serverConnectAddress) => {
readline.close();
if (!fs.existsSync("./verify.json")) {
if (!fs.existsSync("./data/verify.json")) {
log("Generating key exchange keys...");
fs.writeFileSync("./verify.json", JSON.stringify(crypt.generateKeys()));
fs.writeFileSync("./data/verify.json", JSON.stringify(crypt.generateKeys()));
log("Generated key exchange keys");
}
if (!fs.existsSync("./motd.md")) {
if (!fs.existsSync("./config/motd.md")) {
log("Generating MOTD template...");
fs.writeFileSync("./motd.md", "Welcome to the Localchat server");
fs.writeFileSync("./config/motd.md", "Welcome to the Localchat server. This file was created using Localchat Server v" + version + ", edit " + process.cwd() + "/config/motd.md to change this.");
log("Generated MOTD template");
}
log("Loading encryption keys...");
const verify = JSON.parse(fs.readFileSync("./verify.json").toString());
const verify = JSON.parse(fs.readFileSync("./data/verify.json").toString());
const keys = crypt.generateKeys();
const wss = new WebSocketServer({ port });
const motd = fs.readFileSync("./motd.md").toString();
const motd = fs.readFileSync("./config/motd.md").toString();
log("Loaded encryption keys");
log("Generating local server configuration...");
fs.writeFileSync("./local.lctsc", zlib.brotliCompressSync(JSON.stringify({
fs.writeFileSync("./exports/local.lctsc", zlib.brotliCompressSync(JSON.stringify({
address: "ws://127.0.0.1:" + port,
key: verify.publicKey
})));
log("Generating remote server configuration...");
fs.writeFileSync("./remote.lctsc", zlib.brotliCompressSync(JSON.stringify({
fs.writeFileSync("./exports/remote.lctsc", zlib.brotliCompressSync(JSON.stringify({
address: "ws://" + serverConnectAddress + ":" + port,
key: verify.publicKey
})));
log("Generated server configuration files to local.lctsc and remote.lctsc");
log("Loading ban list...");
if (!fs.existsSync("./bans.json")) fs.writeFileSync("./bans.json", "[]");
let bans = JSON.parse(fs.readFileSync("./bans.json").toString());
if (!fs.existsSync("./config/bans.json")) fs.writeFileSync("./config/bans.json", "[]");
let bans = JSON.parse(fs.readFileSync("./config/bans.json").toString());
let clients = [];
log("Loaded ban list");
log("Loading operators list...");
if (!fs.existsSync("./ops.json")) fs.writeFileSync("./ops.json", "[]");
let operators = JSON.parse(fs.readFileSync("./ops.json").toString());
if (!fs.existsSync("./config/ops.json")) fs.writeFileSync("./config/ops.json", "[]");
let operators = JSON.parse(fs.readFileSync("./config/ops.json").toString());
log("Loaded operators list");
function parseAddress(address) {
@ -132,7 +144,7 @@ readline.question("Enter the IP address users would use to connect to the server
wss.on('connection', function connection(ws, req) {
log("Connection from " + req.socket.remoteAddress);
ws.publicKey = null;
ws.lang = "en-US";
ws.lang = "en";
ws.id = uuid();
ws.address = parseAddress(req.socket.remoteAddress);
ws.lastPacket = 0;
@ -198,7 +210,7 @@ readline.question("Enter the IP address users would use to connect to the server
} catch (e) {}
}
fs.writeFileSync("./bans.json", JSON.stringify(bans));
fs.writeFileSync("./config/bans.json", JSON.stringify(bans));
}
return;
@ -446,7 +458,7 @@ readline.question("Enter the IP address users would use to connect to the server
}
}
fs.writeFileSync("./bans.json", JSON.stringify(bans));
fs.writeFileSync("./config/bans.json", JSON.stringify(bans));
log("Banned user " + message.user, ws.address);
}
} else if (message.type === "unban") {
@ -504,7 +516,7 @@ readline.question("Enter the IP address users would use to connect to the server
}
log("Unbanned user " + message.user, ws.address);
fs.writeFileSync("./bans.json", JSON.stringify(bans));
fs.writeFileSync("./config/bans.json", JSON.stringify(bans));
}
} else if (message.type === "op") {
if (ws.address !== "::1" && !ws.address.startsWith("127.")) {
@ -576,7 +588,7 @@ readline.question("Enter the IP address users would use to connect to the server
}
}
fs.writeFileSync("./operators.json", JSON.stringify(operators));
fs.writeFileSync("./config/ops.json", JSON.stringify(operators));
log("Op-ed user " + message.user, ws.address);
}
} else if (message.type === "deop") {
@ -650,7 +662,7 @@ readline.question("Enter the IP address users would use to connect to the server
}
log("Deop-ed user " + message.user, ws.address);
fs.writeFileSync("./operators.json", JSON.stringify(operators));
fs.writeFileSync("./config/ops.json", JSON.stringify(operators));
}
}
} else {

@ -85,6 +85,7 @@
},
"version": {
"localchat": "Localchat Version:",
"launcher": "Launcher-Version:",
"node": "Node.js Version:",
"chrome": "Chrome Version:",
"electron": "Electron Version:",

@ -85,6 +85,7 @@
},
"version": {
"localchat": "Localchat version:",
"launcher": "Launcher version:",
"node": "Node.js version:",
"chrome": "Chrome version:",
"electron": "Electron version:",

@ -85,6 +85,7 @@
},
"version": {
"localchat": "Versión de Localchat:",
"launcher": "Versión del lanzador:",
"node": "Versión de Node.js:",
"chrome": "Versión de Chrome:",
"electron": "Versión de Electron:",

@ -85,6 +85,7 @@
},
"version": {
"localchat": "Version de Localchat :",
"launcher": "Version du lanceur :",
"node": "Version de Node.js :",
"chrome": "Version de Chrome :",
"electron": "Version d'Electron :",

@ -1,6 +1,6 @@
const translatte = require('translatte');
const fs = require('fs');
const base = require("../shared/lang/fr-FR.json");
const base = require("../shared/lang/fr.json");
async function crawl(list, lang) {
for (let item of Object.keys(list)) {
@ -18,7 +18,7 @@ async function crawl(list, lang) {
}
(async () => {
const base = require('../shared/lang/fr-FR.json');
const base = require('../shared/lang/fr.json');
const lang = await crawl(base, {});
fs.writeFileSync("../shared/lang/de-DE.json", JSON.stringify(lang, null, 2));

Loading…
Cancel
Save