i have no clue what i changed

This commit is contained in:
Hri7566 2021-05-28 17:15:00 -04:00
parent 4aefb8d9cb
commit 0cf80d62db
7 changed files with 63 additions and 45 deletions

View File

@ -25,7 +25,8 @@ module.exports = Object.seal({
time: 500 time: 500
}, },
cursor: { cursor: {
time: 16 time: 16,
amount: 10
}, },
kickban: { kickban: {
amount: 2, amount: 2,

View File

@ -4,7 +4,7 @@
"description": "Attempt at making a MPP Server.", "description": "Attempt at making a MPP Server.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "nodemon"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -97,7 +97,7 @@ class Client extends EventEmitter {
normal: new RateLimitChain(quotas.chat.normal.amount, quotas.chat.normal.time), normal: new RateLimitChain(quotas.chat.normal.amount, quotas.chat.normal.time),
insane: new RateLimitChain(quotas.chat.insane.amount, quotas.chat.insane.time) insane: new RateLimitChain(quotas.chat.insane.amount, quotas.chat.insane.time)
}, },
cursor: new RateLimit(quotas.cursor.time), cursor: new RateLimitChain(quotas.cursor.amount, quotas.cursor.time),
chown: new RateLimitChain(quotas.chown.amount, quotas.chown.time), chown: new RateLimitChain(quotas.chown.amount, quotas.chown.time),
userset: new RateLimitChain(quotas.userset.amount, quotas.userset.time), userset: new RateLimitChain(quotas.userset.amount, quotas.userset.time),
kickban: new RateLimitChain(quotas.kickban.amount, quotas.kickban.time), kickban: new RateLimitChain(quotas.kickban.amount, quotas.kickban.time),

View File

@ -38,6 +38,7 @@ module.exports = (cl) => {
cl.on("ch", msg => { cl.on("ch", msg => {
if (typeof(msg.set) !== 'object') msg.set = {}; if (typeof(msg.set) !== 'object') msg.set = {};
console.log(msg);
if (typeof(msg._id) == "string") { if (typeof(msg._id) == "string") {
if (msg._id.length > 512) return; if (msg._id.length > 512) return;
@ -66,7 +67,8 @@ module.exports = (cl) => {
}); });
cl.on("m", (msg, admin) => { cl.on("m", (msg, admin) => {
// if (!cl.quotas.cursor.attempt() && !admin) return; if (!cl.hasOwnProperty('room')) return;
if (!cl.quotas.cursor.attempt() && !admin) return;
if (!(cl.channel && cl.participantId)) return; if (!(cl.channel && cl.participantId)) return;
if (!msg.hasOwnProperty("x")) msg.x = null; if (!msg.hasOwnProperty("x")) msg.x = null;
if (!msg.hasOwnProperty("y")) msg.y = null; if (!msg.hasOwnProperty("y")) msg.y = null;
@ -137,12 +139,12 @@ module.exports = (cl) => {
if (typeof(msg.message) !== 'string') return; if (typeof(msg.message) !== 'string') return;
if (cl.channel.settings.chat) { if (cl.channel.settings.chat) {
if (cl.channel.isLobby(cl.channel._id)) { if (cl.channel.isLobby(cl.channel._id)) {
if (!cl.quotas.chat.lobby.attempt() && !admin && !cl.user.hasFlag('no rate chat limit', true)) return; if (!cl.quotas.chat.lobby.attempt() && !admin && !cl.user.hasFlag('no chat rate limit', true)) return;
} else { } else {
if (!(cl.user._id == cl.channel.crown.userId)) { if (!(cl.user._id == cl.channel.crown.userId)) {
if (!cl.quotas.chat.normal.attempt() && !admin && !cl.user.hasFlag('no rate chat limit', true)) return; if (!cl.quotas.chat.normal.attempt() && !admin && !cl.user.hasFlag('no chat rate limit', true)) return;
} else { } else {
if (!cl.quotas.chat.insane.attempt() && !admin && !cl.user.hasFlag('no rate chat limit', true)) return; if (!cl.quotas.chat.insane.attempt() && !admin && !cl.user.hasFlag('no chat rate limit', true)) return;
} }
} }
cl.channel.emit('a', cl, msg); cl.channel.emit('a', cl, msg);

40
src/Notification.js Normal file
View File

@ -0,0 +1,40 @@
module.exports = class Notification {
constructor (data) {
this.id = data.id;
this.chat = data.chat;
this.refresh = data.refresh;
this.title = data.title;
this.text = data.text;
this.html = data.html;
this.target = data.target;
this.duration = data.duration;
this.class = data.class;
this.id = data.id;
}
send(_id, room) {
let obj = {};
Object.assign(obj, this);
obj.m = "notification";
switch (_id) {
case "all": {
for (let con of Array.from(room.server.connections.values())) {
con.sendArray([obj]);
}
break;
}
case "room": {
for (let con of room.connections) {
con.sendArray([obj]);
}
break;
}
default: {
Array.from(room.server.connections.values()).filter((usr) => typeof(usr.user) !== 'undefined' ? usr.user._id == _id : null).forEach((p) => {
p.sendArray([obj]);
});
}
}
}
}

View File

@ -5,6 +5,7 @@ const Logger = require('./Logger.js');
const Quota = require("./Quota.js"); const Quota = require("./Quota.js");
const RoomSettings = require('./RoomSettings.js'); const RoomSettings = require('./RoomSettings.js');
const ftc = require('fancy-text-converter'); const ftc = require('fancy-text-converter');
const Notification = require('./Notification');
class Room extends EventEmitter { class Room extends EventEmitter {
constructor(server, _id, settings) { constructor(server, _id, settings) {
@ -306,7 +307,7 @@ class Room extends EventEmitter {
if (msg.message.length > 512) return; if (msg.message.length > 512) return;
let filter = ["AMIGHTYWIND", "CHECKLYHQ"]; let filter = ["AMIGHTYWIND", "CHECKLYHQ"];
let regexp = new RegExp("\\b(" + filter.join("|") + ")\\b", "i"); let regexp = new RegExp("\\b(" + filter.join("|") + ")\\b", "i");
if (regexp.test(msg.message)) return; if (regexp.test(msg.message.split(' ').join(''))) return;
if (p.participantId == 0) { if (p.participantId == 0) {
let message = {}; let message = {};
message.m = "a"; message.m = "a";
@ -330,7 +331,7 @@ class Room extends EventEmitter {
message.m = "a"; message.m = "a";
message.a = msg.message; message.a = msg.message;
if (prsn.user.hasFlag('vowels')) { if (prsn.user.hasFlag('vowels')) {
if (prsn.user.flags.vowels != false) message.a = message.a.split(/[aeiouAEIOU]/).join(prsn.user.flags["vowels"]); if (prsn.user.flags.vowels != false) message.a = message.a.split(/[aeiou]/).join('o').split(/[AEIOU]/).join('O');
} }
message.p = { message.p = {
color: p.user.color, color: p.user.color,
@ -414,44 +415,17 @@ class Room extends EventEmitter {
} }
Notification(who, title, text, html, duration, target, klass, id) { Notification(who, title, text, html, duration, target, klass, id) {
let obj = { new Notification({
m: "notification", id: id,
chat: undefined,
refresh: undefined,
title: title, title: title,
text: text, text: text,
html: html, html: html,
target: target,
duration: duration, duration: duration,
class: klass, target: target,
id: id class: klass
}; }).send(who, this);
if (!id) delete obj.id;
if (!title) delete obj.title;
if (!text) delete obj.text;
if (!html) delete obj.html;
if (!target) delete obj.target;
if (!duration) delete obj.duration;
if (!klass) delete obj.class;
switch (who) {
case "all": {
for (let con of Array.from(this.server.connections.values())) {
con.sendArray([obj]);
}
break;
}
case "room": {
for (let con of this.connections) {
con.sendArray([obj]);
}
break;
}
default: {
Array.from(this.server.connections.values()).filter((usr) => typeof(usr.user) !== 'undefined' ? usr.user._id == who : null).forEach((p) => {
p.sendArray([obj]);
});
}
}
} }
bindEventListeners() { bindEventListeners() {

View File

@ -19,7 +19,7 @@ class User {
this.color = data.color; this.color = data.color;
this.flags = typeof data.flags == "object" ? data.flags : { this.flags = typeof data.flags == "object" ? data.flags : {
volume: 100, volume: 100,
"no chat rate limit": false, "no chat rate limit": false
} }
} }
@ -32,12 +32,12 @@ class User {
} }
checkFlags() { checkFlags() {
/*
if (typeof(this.cl.server.specialIntervals[this._id]) == 'undefined') { if (typeof(this.cl.server.specialIntervals[this._id]) == 'undefined') {
this.cl.server.specialIntervals[this._id] = {}; this.cl.server.specialIntervals[this._id] = {};
} }
if (this.hasFlag('rainbow', true)) { if (this.hasFlag('rainbow', true)) {
if (!this.cl.server.specialIntervals[this._id].hasOwnProperty('rainbow')) { if (!this.cl.server.specialIntervals[this._id].hasOwnProperty('rainbow')) {
console.log('rainbow triggered');
let h = Math.floor(Math.random() * 360); let h = Math.floor(Math.random() * 360);
let s = 50; let s = 50;
let l = 50; let l = 50;
@ -71,6 +71,7 @@ class User {
console.log('rainbow off triggered'); console.log('rainbow off triggered');
clearInterval(this.cl.server.specialIntervals[this._id].rainbow); clearInterval(this.cl.server.specialIntervals[this._id].rainbow);
} }
*/
} }
stopFlagEvents() { stopFlagEvents() {