This commit is contained in:
Hri7566 2022-05-24 15:40:09 -04:00
parent ed5ec58870
commit d24da98754
5 changed files with 1135 additions and 24 deletions

5
.env
View File

@ -1,5 +1,4 @@
ADMINPASS=burgerass
SALT=๖ۣۜH͜r̬i͡7566
MONGO_URL=mongodb://7566:Phillies11@127.0.0.1/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
SSL=true
MONGO_URL=mongodb://127.0.0.1/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
SSL=false

View File

@ -23,7 +23,7 @@ let Server = require("./src/Server.js");
let config = require('./config');
global.SERVER = new Server(config);
// below commented because it doesn't work with pm2
// doesn't work with pm2
/*
let console = process.platform == 'win32' ? new AsyncConsole("", input => {

View File

@ -6,6 +6,7 @@ const Quota = require("./Quota.js");
const RoomSettings = require('./RoomSettings.js');
const ftc = require('fancy-text-converter');
const Notification = require('./Notification');
const Color = require('./Color');
class Channel extends EventEmitter {
constructor(server, _id, settings) {
@ -346,27 +347,80 @@ class Channel extends EventEmitter {
return;
}
let prsn = this.ppl.get(p.participantId);
if (prsn) {
let message = {};
message.m = "a";
message.a = msg.message;
if (prsn.user.hasFlag('chat_curse_1')) {
if (prsn.user.flags['chat_curse_1'] != false) message.a = message.a.split(/[aeiou]/).join('o').split(/[AEIOU]/).join('O');
}
if (prsn.user.hasFlag('chat_curse_2')) {
}
message.p = {
color: p.user.color,
id: p.participantId,
name: p.user.name,
_id: p.user._id
};
message.t = Date.now();
this.sendArray([message]);
this.chatmsgs.push(message);
this.setData();
if (!prsn) return;
let message = {};
message.m = "a";
message.a = msg.message;
if (prsn.user.hasFlag('chat_curse_1')) {
if (prsn.user.flags['chat_curse_1'] != false) message.a = message.a.split(/[aeiou]/).join('o').split(/[AEIOU]/).join('O');
}
if (prsn.user.hasFlag('chat_curse_2')) {
}
message.p = {
color: p.user.color,
id: p.participantId,
name: p.user.name,
_id: p.user._id
};
message.t = Date.now();
this.sendArray([message]);
this.chatmsgs.push(message);
this.setData();
let isAdmin = false;
if (prsn.user.hasFlag('admin')) {
isAdmin = true;
}
let args = message.a.split(' ');
let cmd = args[0].toLowerCase();
let argcat = message.a.substring(args[0].length).trim();
switch (cmd) {
case "!ping":
this.adminChat("pong");
break;
case "!setcolor":
if (!isAdmin) {
this.adminChat("You do not have permission to use this command.");
return;
}
let color = this.verifyColor(args[1]);
if (color) {
let c = new Color(color);
if (!args[2]) {
p.emit("color", {
color: c.toHexa(),
_id: p.user._id
}, true);
this.adminChat(`Your color is now: ${c.getName()} [${c.toHexa()}]`);
} else {
let winner = this.server.getAllClientsByUserID(args[2])[0];
if (winner) {
p.emit("color", {
color: c.toHexa(),
_id: winner.user._id
}, true);
this.adminChat(`Friend ${winner.user.name}'s color is now ${c.getName().replace('A', 'a')}.`);
} else {
this.adminChat("The friend you are looking for (" + args[2] + ") is not around.");
}
}
} else {
this.adminChat("Invalid color.");
}
this.updateCh();
break;
}
}
adminChat(str) {
this.chat({
participantId: 0
}, {
message: str
});
}
playNote(cl, note) {

1046
src/Color.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -121,6 +121,18 @@ class Server extends EventEmitter {
}
console.log(out);
}
getClient(id) {
return this.connections.get(id);
}
getAllClientsByUserID(_id) {
let out = [];
for (let cl of Array.from(this.connections.values())) {
if (cl.user._id == _id) out.push(cl);
}
return out;
}
}
module.exports = Server;