thanks kazukazu123123 (#14)

This commit is contained in:
charsyチャーシィ 2021-02-28 21:04:31 -07:00
parent d9d732d683
commit 3b21ce6d03
2 changed files with 15 additions and 17 deletions

View File

@ -32,20 +32,16 @@ module.exports = (cl) => {
let param; let param;
if (cl.channel.isLobby(cl.channel._id)) { if (cl.channel.isLobby(cl.channel._id)) {
param = Quota.N_PARAMS_LOBBY; param = Quota.N_PARAMS_LOBBY;
param.m = "nq";
cl.sendArray([param])
} else { } else {
if (!(cl.user._id == cl.channel.crown.userId)) { if (!(cl.user._id == cl.channel.crown.userId)) {
param = Quota.N_PARAMS_NORMAL; param = Quota.N_PARAMS_NORMAL;
param.m = "nq";
cl.sendArray([param])
} else { } else {
param = Quota.N_PARAMS_RIDICULOUS; param = Quota.N_PARAMS_RIDICULOUS;
}
}
param.m = "nq"; param.m = "nq";
cl.sendArray([param]) cl.sendArray([param])
} }
}
}
}) })
cl.on("m", (msg, admin) => { cl.on("m", (msg, admin) => {
if (!cl.quotas.cursor.attempt() && !admin) return; if (!cl.quotas.cursor.attempt() && !admin) return;
@ -141,7 +137,7 @@ module.exports = (cl) => {
if (!msg.hasOwnProperty("set") || !msg.set) msg.set = {}; if (!msg.hasOwnProperty("set") || !msg.set) msg.set = {};
if (msg.set.hasOwnProperty('name') && typeof msg.set.name == "string") { if (msg.set.hasOwnProperty('name') && typeof msg.set.name == "string") {
if (msg.set.name.length > 40) return; 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; cl.user.name = msg.set.name;
let user = new User(cl); let user = new User(cl);
user.getUserData().then((usr) => { user.getUserData().then((usr) => {
@ -159,12 +155,14 @@ module.exports = (cl) => {
} }
}) })
cl.on('kickban', msg => { cl.on('kickban', msg => {
if (cl.channel.crown == null) return;
if (!(cl.channel && cl.participantId)) return; if (!(cl.channel && cl.participantId)) return;
if (!cl.channel.crown.userId) return;
if (!(cl.user._id == cl.channel.crown.userId)) return; if (!(cl.user._id == cl.channel.crown.userId)) return;
if (msg.hasOwnProperty('_id') && typeof msg._id == "string") { if (msg.hasOwnProperty('_id') && typeof msg._id == "string") {
if (!cl.quotas.kickban.attempt() && !admin) return; if (!cl.quotas.kickban.attempt() && !admin) return;
let _id = msg._id; let _id = msg._id;
let ms = msg.ms || 0; let ms = msg.ms || 3600000;
cl.channel.kickban(_id, ms); cl.channel.kickban(_id, ms);
} }
}) })

View File

@ -44,8 +44,10 @@ class Room extends EventEmitter {
} }
} }
this.crowndropped = false; this.crowndropped = false;
this.settings = {visible:true,color:this.server.defaultRoomColor,chat:true,crownsolo:false};
} else { } else {
//cl.quotas.a.setParams(Quota.PARAMS_A_NORMAL); //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); this.ppl.set(participantId, cl);
@ -63,7 +65,7 @@ class Room extends EventEmitter {
m: "c", m: "c",
c: this.chatmsgs.slice(-1 * 32) c: this.chatmsgs.slice(-1 * 32)
}]) }])
this.updateCh(cl); this.updateCh(cl, this.settings);
} else { } else {
cl.user.id = otheruser.participantId; cl.user.id = otheruser.participantId;
cl.participantId = otheruser.participantId; cl.participantId = otheruser.participantId;
@ -73,7 +75,7 @@ class Room extends EventEmitter {
m: "c", m: "c",
c: this.chatmsgs.slice(-1 * 32) 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) { kickban(_id, ms) {
ms = parseInt(ms); ms = parseInt(ms);
if (ms >= (1000 * 60 * 60 - 500)) return; if (ms >= (1000 * 60 * 60)) return;
if (ms < 0) return; if (ms < 0) return;
ms = Math.round(ms / 1000) * 1000; ms = Math.round(ms / 1000) * 1000;
let user = this.connections.find((usr) => usr.user._id == _id); let user = this.connections.find((usr) => usr.user._id == _id);
if (!user) return; if (!user) return;
let asd = true; let asd = true;
let tonc = true;
let pthatbanned = this.ppl.get(this.crown.participantId); let pthatbanned = this.ppl.get(this.crown.participantId);
this.connections.filter((usr) => usr.participantId == user.participantId).forEach((u) => { this.connections.filter((usr) => usr.participantId == user.participantId).forEach((u) => {
user.bantime = Math.floor(Math.floor(ms / 1000) / 60); user.bantime = Math.floor(Math.floor(ms / 1000) / 60);
@ -330,7 +331,7 @@ class Room extends EventEmitter {
"#room", "#room",
"short" "short"
) )
if (this.crown && (this.crown.userId == _id) && tonc) { if (this.crown && (this.crown.userId == _id)) {
this.Notification("room", this.Notification("room",
"Certificate of Award", "Certificate of Award",
`Let it be known that ${user.user.name} kickbanned him/her self.`, `Let it be known that ${user.user.name} kickbanned him/her self.`,
@ -338,7 +339,6 @@ class Room extends EventEmitter {
7000, 7000,
"#room" "#room"
); );
tonc = false;
} }
} }