From 3b21ce6d03eb0ff7c59e00d3c49e8df81c9671b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?charsy=E3=83=81=E3=83=A3=E3=83=BC=E3=82=B7=E3=82=A3?= Date: Sun, 28 Feb 2021 21:04:31 -0700 Subject: [PATCH] thanks kazukazu123123 (#14) --- src/Message.js | 20 +++++++++----------- src/Room.js | 12 ++++++------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Message.js b/src/Message.js index 563dedc..40e72bf 100644 --- a/src/Message.js +++ b/src/Message.js @@ -31,20 +31,16 @@ module.exports = (cl) => { cl.setChannel(msg._id, msg.set); let param; if (cl.channel.isLobby(cl.channel._id)) { - param = Quota.N_PARAMS_LOBBY; - param.m = "nq"; - cl.sendArray([param]) + param = Quota.N_PARAMS_LOBBY; } else { if (!(cl.user._id == cl.channel.crown.userId)) { - param = Quota.N_PARAMS_NORMAL; - param.m = "nq"; - cl.sendArray([param]) + param = Quota.N_PARAMS_NORMAL; } else { - param = Quota.N_PARAMS_RIDICULOUS; - param.m = "nq"; - cl.sendArray([param]) + param = Quota.N_PARAMS_RIDICULOUS; } } + param.m = "nq"; + cl.sendArray([param]) } }) cl.on("m", (msg, admin) => { @@ -141,7 +137,7 @@ module.exports = (cl) => { if (!msg.hasOwnProperty("set") || !msg.set) msg.set = {}; if (msg.set.hasOwnProperty('name') && typeof msg.set.name == "string") { if (msg.set.name.length > 40) return; - if (!cl.quotas.name.attempt()) return; + if(!cl.quotas.name.attempt()) return; cl.user.name = msg.set.name; let user = new User(cl); user.getUserData().then((usr) => { @@ -159,12 +155,14 @@ module.exports = (cl) => { } }) cl.on('kickban', msg => { + if (cl.channel.crown == null) return; if (!(cl.channel && cl.participantId)) return; + if (!cl.channel.crown.userId) return; if (!(cl.user._id == cl.channel.crown.userId)) return; if (msg.hasOwnProperty('_id') && typeof msg._id == "string") { if (!cl.quotas.kickban.attempt() && !admin) return; let _id = msg._id; - let ms = msg.ms || 0; + let ms = msg.ms || 3600000; cl.channel.kickban(_id, ms); } }) diff --git a/src/Room.js b/src/Room.js index f319ef8..15a0a38 100644 --- a/src/Room.js +++ b/src/Room.js @@ -44,8 +44,10 @@ class Room extends EventEmitter { } } this.crowndropped = false; + this.settings = {visible:true,color:this.server.defaultRoomColor,chat:true,crownsolo:false}; } else { //cl.quotas.a.setParams(Quota.PARAMS_A_NORMAL); + this.settings = {visible:true,color:this.server.defaultRoomColor,chat:true,crownsolo:false,lobby:true}; } this.ppl.set(participantId, cl); @@ -63,7 +65,7 @@ class Room extends EventEmitter { m: "c", c: this.chatmsgs.slice(-1 * 32) }]) - this.updateCh(cl); + this.updateCh(cl, this.settings); } else { cl.user.id = otheruser.participantId; cl.participantId = otheruser.participantId; @@ -73,7 +75,7 @@ class Room extends EventEmitter { m: "c", c: this.chatmsgs.slice(-1 * 32) }]) - this.updateCh(cl); + this.updateCh(cl, this.settings); } } @@ -297,13 +299,12 @@ class Room extends EventEmitter { } kickban(_id, ms) { ms = parseInt(ms); - if (ms >= (1000 * 60 * 60 - 500)) return; + if (ms >= (1000 * 60 * 60)) return; if (ms < 0) return; ms = Math.round(ms / 1000) * 1000; let user = this.connections.find((usr) => usr.user._id == _id); if (!user) return; let asd = true; - let tonc = true; let pthatbanned = this.ppl.get(this.crown.participantId); this.connections.filter((usr) => usr.participantId == user.participantId).forEach((u) => { user.bantime = Math.floor(Math.floor(ms / 1000) / 60); @@ -330,7 +331,7 @@ class Room extends EventEmitter { "#room", "short" ) - if (this.crown && (this.crown.userId == _id) && tonc) { + if (this.crown && (this.crown.userId == _id)) { this.Notification("room", "Certificate of Award", `Let it be known that ${user.user.name} kickbanned him/her self.`, @@ -338,7 +339,6 @@ class Room extends EventEmitter { 7000, "#room" ); - tonc = false; } }