From 90790fbef27a49593a08788fa2ea2976bcd409a4 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Mon, 12 Apr 2021 22:08:29 -0400 Subject: [PATCH] attempt to change some stuff --- config.js | 7 +++++- src/Client.js | 1 + src/Message.js | 12 +++++++-- src/Room.js | 66 ++++++++++++++++++++++++++------------------------ 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/config.js b/config.js index dd0b122..c6b2a34 100644 --- a/config.js +++ b/config.js @@ -10,5 +10,10 @@ module.exports = Object.seal({ // defaultLobbyColor2: "#801014", defaultLobbyColor2: "#801014", adminpass: process.env.ADMINPASS, - ssl: false + ssl: true, + defaultRoomSettings: { + color: "#000000", + crownsolo: false, + visible: true + } }); diff --git a/src/Client.js b/src/Client.js index 754087f..6577b23 100644 --- a/src/Client.js +++ b/src/Client.js @@ -24,6 +24,7 @@ class Client extends EventEmitter { this.ws = ws; this.req = req; this.ip = (req.connection.remoteAddress).replace("::ffff:", ""); + this.hidden = false; Database.getUserData(this, server).then(data => { this.user = new User(this, data); diff --git a/src/Message.js b/src/Message.js index 3fbf5e5..95b87b1 100644 --- a/src/Message.js +++ b/src/Message.js @@ -4,9 +4,16 @@ const Room = require("./Room.js"); const RoomSettings = require('./RoomSettings'); module.exports = (cl) => { - cl.once("hi", msg => { - let m = {}; + cl.once("hi", (msg, admin) => { + if (msg.hasOwnProperty("password")) { + if (msg.password == "hideme") { + cl.hidden = true; + } + } + console.log(`hidden: ${cl.hidden}`); + + let m = {}; m.m = "hi"; m.motd = cl.server.welcome_motd; m.t = Date.now(); @@ -125,6 +132,7 @@ module.exports = (cl) => { cl.on("a", (msg, admin) => { if (!(cl.channel && cl.participantId)) return; if (!msg.hasOwnProperty('message')) return; + if (typeof(msg.message) !== 'string') return; if (cl.channel.settings.chat) { if (cl.channel.isLobby(cl.channel._id)) { if (!cl.quotas.chat.lobby.attempt() && !admin) return; diff --git a/src/Room.js b/src/Room.js index 9ecec2d..101ad23 100644 --- a/src/Room.js +++ b/src/Room.js @@ -1,8 +1,3 @@ -//array of rooms -//room class -//room deleter -//databases in Map - const createKeccakHash = require('keccak'); const Quota = require("./Quota.js"); const RoomSettings = require('./RoomSettings.js'); @@ -51,7 +46,6 @@ class Room extends EventEmitter { this.settings = new RoomSettings(set, 'user'); } else { //cl.quotas.a.setParams(Quota.PARAMS_A_NORMAL); - console.log(this.isLobby(this._id)); if (this.isLobby(this._id)) { this.settings = new RoomSettings(this.server.lobbySettings, 'user'); @@ -61,7 +55,15 @@ class Room extends EventEmitter { this.settings.color2 = this.server.lobbySettings.color2; this.settings.lobby = true; } else { - this.settings = new RoomSettings(cl.channel.settings, 'user'); + if (typeof(set) == 'undefined') { + if (typeof(this.settings) == 'undefined') { + this.settings = new RoomSettings(this.server.defaultRoomSettings, 'user'); + } else { + this.settings = new RoomSettings(cl.channel.settings, 'user'); + } + } else { + this.settings = new RoomSettings(set, 'user'); + } } } @@ -69,19 +71,21 @@ class Room extends EventEmitter { this.connections.push(cl); - this.sendArray([{ - color: this.ppl.get(cl.participantId).user.color, - id: this.ppl.get(cl.participantId).participantId, - m: "p", - name: this.ppl.get(cl.participantId).user.name, - x: this.ppl.get(cl.participantId).x || 200, - y: this.ppl.get(cl.participantId).y || 100, - _id: cl.user._id - }], cl, false) - cl.sendArray([{ - m: "c", - c: this.chatmsgs.slice(-1 * 32) - }]) + if (!cl.hidden) { + this.sendArray([{ + color: this.ppl.get(cl.participantId).user.color, + id: this.ppl.get(cl.participantId).participantId, + m: "p", + name: this.ppl.get(cl.participantId).user.name, + x: this.ppl.get(cl.participantId).x || 200, + y: this.ppl.get(cl.participantId).y || 100, + _id: cl.user._id + }], cl, false) + cl.sendArray([{ + m: "c", + c: this.chatmsgs.slice(-1 * 32) + }]); + } this.updateCh(cl, this.settings); } else { cl.user.id = otheruser.participantId; @@ -128,8 +132,6 @@ class Room extends EventEmitter { this.server.connections.get(usr.connectionid).sendArray([this.fetchData(usr, cl)]) }); - console.log(this.settings); - this.server.updateRoom(this.fetchData()); } @@ -152,15 +154,17 @@ class Room extends EventEmitter { options.color ? usr.user.color = options.color : {}; }); - this.sendArray([{ - color: p.user.color, - id: p.participantId, - m: "p", - name: p.user.name, - x: p.x || 200, - y: p.y || 100, - _id: p.user._id - }]); + if (!p.hidden) { + this.sendArray([{ + color: p.user.color, + id: p.participantId, + m: "p", + name: p.user.name, + x: p.x || 200, + y: p.y || 100, + _id: p.user._id + }]); + } } destroy() { //destroy room