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 ADMINPASS=burgerass
SALT=๖ۣۜH͜r̬i͡7566 SALT=๖ۣۜH͜r̬i͡7566
MONGO_URL=mongodb://7566:Phillies11@127.0.0.1/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false MONGO_URL=mongodb://127.0.0.1/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
SSL=true SSL=false

View File

@ -23,7 +23,7 @@ let Server = require("./src/Server.js");
let config = require('./config'); let config = require('./config');
global.SERVER = new Server(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 => { 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 RoomSettings = require('./RoomSettings.js');
const ftc = require('fancy-text-converter'); const ftc = require('fancy-text-converter');
const Notification = require('./Notification'); const Notification = require('./Notification');
const Color = require('./Color');
class Channel extends EventEmitter { class Channel extends EventEmitter {
constructor(server, _id, settings) { constructor(server, _id, settings) {
@ -346,7 +347,7 @@ class Channel extends EventEmitter {
return; return;
} }
let prsn = this.ppl.get(p.participantId); let prsn = this.ppl.get(p.participantId);
if (prsn) { if (!prsn) return;
let message = {}; let message = {};
message.m = "a"; message.m = "a";
message.a = msg.message; message.a = msg.message;
@ -366,7 +367,60 @@ class Channel extends EventEmitter {
this.sendArray([message]); this.sendArray([message]);
this.chatmsgs.push(message); this.chatmsgs.push(message);
this.setData(); 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) { 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); 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; module.exports = Server;