no idea...
This commit is contained in:
parent
95d2567145
commit
e00105a8cf
|
@ -1,5 +1,6 @@
|
|||
.env
|
||||
node_modules
|
||||
ssl/
|
||||
src/db/rooms.db
|
||||
.history
|
||||
*.db/
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
16
src/Room.js
16
src/Room.js
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue