no idea...

This commit is contained in:
Hri7566 2022-03-29 03:32:56 +02:00
parent 862d09f37b
commit a4a334f263
6 changed files with 47 additions and 11 deletions

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
.env
node_modules
ssl/
src/db/rooms.db
.history
*.db/

View File

@ -27,7 +27,7 @@ class Database {
static async load() {
this.userdb = mongoose.connection;
this.roomdb = level('src/db/rooms.db');
this.roomdb = level('db/rooms.db');
// const writeFile = promisify(fs.writeFile);
// const readdir = promisify(fs.readdir);

View File

@ -246,7 +246,7 @@ module.exports = (cl) => {
c.user.color = msg.color;
require("./Database").updateUser(c.user._id, c.user);
c.user.cl.updateParticipant(c.user._id, c.user);
cl.channel.updateParticipant(c.user._id, c.user);
});
});
@ -305,8 +305,33 @@ module.exports = (cl) => {
});
});
cl.on('room_flag', (msg, admin) => {
if (!admin) return;
if (!msg.hasOwnProperty('_id') || !msg.hasOwnProperty('key') || !msg.hasOwnProperty('value')) return;
try {
let ch = cl.server.rooms.get(msg._id);
ch.flags[msg.key] = msg.value;
} catch(err) {
console.error(err);
}
});
cl.on('clear_chat', (msg, admin) => {
if (!admin) return;
cl.channel.connections.forEach(cl => {
cl.sendArray([{m:"c", c:[]}]);
});
});
cl.on('sudo', (msg, admin) => {
if (!admin) return;
if (typeof msg._id !== 'string') return;
if (typeof msg.msg !== 'object') return;
if (!msg.msg.m) return;
cl.server.connections.forEach(c => {
if (c.user._id !== msg._id) return;
c.emit(msg.msg.m, msg.msg);
});
});
}

View File

@ -31,6 +31,12 @@ class Room extends EventEmitter {
this.settings = set.settings;
this.chatmsgs = set.chat;
this.connections.forEach(cl => {
cl.sendArray([{
m: 'c',
c: this.chatmsgs.slice(-1 * 32)
}]);
});
this.setData();
});
}
@ -348,14 +354,18 @@ class Room extends EventEmitter {
playNote(cl, note) {
let vel = Math.round(cl.user.flags["volume"])/100 || undefined;
if (vel == 1) vel = undefined;
if (vel) {
for (let no of note.n) {
no.v /= vel;
}
}
this.sendArray([{
m: "n",
n: note.n,
p: cl.participantId,
t: note.t,
v: vel
t: note.t
}], cl, true);
}

View File

@ -61,7 +61,7 @@ class Server extends EventEmitter {
this.connections.set(++this.connectionid, new Client(ws, req, this));
});
this.legit_m = ["a", "bye", "hi", "ch", "+ls", "-ls", "m", "n", "devices", "t", "chset", "userset", "chown", "kickban", "admin message", "color", "eval", "notification", "user_flag", "room_flag", "clear_chat"]
this.legit_m = ["a", "bye", "hi", "ch", "+ls", "-ls", "m", "n", "devices", "t", "chset", "userset", "chown", "kickban", "admin message", "color", "eval", "notification", "user_flag", "room_flag", "clear_chat", "sudo"];
this.welcome_motd = config.motd || "You agree to read this message.";
this._id_Private_Key = config._id_PrivateKey || "boppity";

View File

@ -32,11 +32,11 @@ class User {
}
checkFlags() {
/*
if (typeof(this.cl.server.specialIntervals[this._id]) == 'undefined') {
this.cl.server.specialIntervals[this._id] = {};
}
if (this.hasFlag('rainbow', true)) {
console.log('rainbow on for ' + this._id);
if (!this.cl.server.specialIntervals[this._id].hasOwnProperty('rainbow')) {
let h = Math.floor(Math.random() * 360);
let s = 50;
@ -68,10 +68,9 @@ class User {
}, 1000/15);
}
} else if (this.hasFlag('rainbow', false)) {
console.log('rainbow off triggered');
console.log('rainbow off for ' + this._id);
clearInterval(this.cl.server.specialIntervals[this._id].rainbow);
}
*/
}
stopFlagEvents() {
@ -96,3 +95,4 @@ class User {
}
module.exports = User;