Rename stuff, add message log

This commit is contained in:
osmarks 2018-10-03 18:18:11 +01:00
parent bdc9668e7e
commit 7756394588
1 changed files with 12 additions and 3 deletions

View File

@ -10,11 +10,11 @@ const makeID = () => humanID({
});
const send = (sock, msg) => sock.send(JSON.stringify(msg));
const validateChannel = channel => { if (typeof channel !== "string" && typeof channel !== "number") throw new Error("Invalid type for channel!"); }
const wildcardChannel = "*";
let messageLogs = [];
const commands = {
open(ws, message) {
const channel = message.channel;
@ -59,10 +59,19 @@ const commands = {
}
});
toSend.sentTo = sentTo;
messageLogs.unshift(toSend);
return { sentTo, ID: toSend.ID };
},
getID(ws) {
ID(ws) {
return { ID: ws.ID };
},
log(ws, data) {
const start = data.start || 0;
const end = data.end || 100;
return { log: messageLogs.slice(start, end) };
}
}