forked from Hri7566/mpp-server-dev2
i have no clue what i changed
This commit is contained in:
parent
e8d2e492de
commit
e45582efea
|
@ -25,7 +25,8 @@ module.exports = Object.seal({
|
|||
time: 500
|
||||
},
|
||||
cursor: {
|
||||
time: 16
|
||||
time: 16,
|
||||
amount: 10
|
||||
},
|
||||
kickban: {
|
||||
amount: 2,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"description": "Attempt at making a MPP Server.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "nodemon"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -97,7 +97,7 @@ class Client extends EventEmitter {
|
|||
normal: new RateLimitChain(quotas.chat.normal.amount, quotas.chat.normal.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),
|
||||
userset: new RateLimitChain(quotas.userset.amount, quotas.userset.time),
|
||||
kickban: new RateLimitChain(quotas.kickban.amount, quotas.kickban.time),
|
||||
|
|
|
@ -38,6 +38,7 @@ module.exports = (cl) => {
|
|||
|
||||
cl.on("ch", msg => {
|
||||
if (typeof(msg.set) !== 'object') msg.set = {};
|
||||
console.log(msg);
|
||||
|
||||
if (typeof(msg._id) == "string") {
|
||||
if (msg._id.length > 512) return;
|
||||
|
@ -66,7 +67,8 @@ module.exports = (cl) => {
|
|||
});
|
||||
|
||||
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 (!msg.hasOwnProperty("x")) msg.x = null;
|
||||
if (!msg.hasOwnProperty("y")) msg.y = null;
|
||||
|
@ -137,12 +139,12 @@ module.exports = (cl) => {
|
|||
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 && !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 {
|
||||
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 {
|
||||
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);
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
src/Room.js
46
src/Room.js
|
@ -5,6 +5,7 @@ const Logger = require('./Logger.js');
|
|||
const Quota = require("./Quota.js");
|
||||
const RoomSettings = require('./RoomSettings.js');
|
||||
const ftc = require('fancy-text-converter');
|
||||
const Notification = require('./Notification');
|
||||
|
||||
class Room extends EventEmitter {
|
||||
constructor(server, _id, settings) {
|
||||
|
@ -306,7 +307,7 @@ class Room extends EventEmitter {
|
|||
if (msg.message.length > 512) return;
|
||||
let filter = ["AMIGHTYWIND", "CHECKLYHQ"];
|
||||
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) {
|
||||
let message = {};
|
||||
message.m = "a";
|
||||
|
@ -330,7 +331,7 @@ class Room extends EventEmitter {
|
|||
message.m = "a";
|
||||
message.a = msg.message;
|
||||
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 = {
|
||||
color: p.user.color,
|
||||
|
@ -414,44 +415,17 @@ class Room extends EventEmitter {
|
|||
}
|
||||
|
||||
Notification(who, title, text, html, duration, target, klass, id) {
|
||||
let obj = {
|
||||
m: "notification",
|
||||
new Notification({
|
||||
id: id,
|
||||
chat: undefined,
|
||||
refresh: undefined,
|
||||
title: title,
|
||||
text: text,
|
||||
html: html,
|
||||
target: target,
|
||||
duration: duration,
|
||||
class: klass,
|
||||
id: id
|
||||
};
|
||||
|
||||
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]);
|
||||
});
|
||||
}
|
||||
}
|
||||
target: target,
|
||||
class: klass
|
||||
}).send(who, this);
|
||||
}
|
||||
|
||||
bindEventListeners() {
|
||||
|
|
|
@ -19,7 +19,7 @@ class User {
|
|||
this.color = data.color;
|
||||
this.flags = typeof data.flags == "object" ? data.flags : {
|
||||
volume: 100,
|
||||
"no chat rate limit": false,
|
||||
"no chat rate limit": false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ class User {
|
|||
}
|
||||
|
||||
checkFlags() {
|
||||
/*
|
||||
if (typeof(this.cl.server.specialIntervals[this._id]) == 'undefined') {
|
||||
this.cl.server.specialIntervals[this._id] = {};
|
||||
}
|
||||
if (this.hasFlag('rainbow', true)) {
|
||||
if (!this.cl.server.specialIntervals[this._id].hasOwnProperty('rainbow')) {
|
||||
console.log('rainbow triggered');
|
||||
let h = Math.floor(Math.random() * 360);
|
||||
let s = 50;
|
||||
let l = 50;
|
||||
|
@ -71,6 +71,7 @@ class User {
|
|||
console.log('rainbow off triggered');
|
||||
clearInterval(this.cl.server.specialIntervals[this._id].rainbow);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
stopFlagEvents() {
|
||||
|
|
Loading…
Reference in New Issue