attempt to change some stuff

This commit is contained in:
Hri7566 2021-04-12 22:08:29 -04:00
parent 91be717a1a
commit 90790fbef2
4 changed files with 52 additions and 34 deletions

View File

@ -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
}
});

View File

@ -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);

View File

@ -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;

View File

@ -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');
@ -60,15 +54,24 @@ class Room extends EventEmitter {
this.settings.color = this.server.lobbySettings.color;
this.settings.color2 = this.server.lobbySettings.color2;
this.settings.lobby = true;
} else {
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');
}
}
}
this.ppl.set(participantId, cl);
this.connections.push(cl);
if (!cl.hidden) {
this.sendArray([{
color: this.ppl.get(cl.participantId).user.color,
id: this.ppl.get(cl.participantId).participantId,
@ -81,7 +84,8 @@ class Room extends EventEmitter {
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,6 +154,7 @@ class Room extends EventEmitter {
options.color ? usr.user.color = options.color : {};
});
if (!p.hidden) {
this.sendArray([{
color: p.user.color,
id: p.participantId,
@ -162,6 +165,7 @@ class Room extends EventEmitter {
_id: p.user._id
}]);
}
}
destroy() { //destroy room
if (this.ppl.size > 0) return;