Rename stuff, add message log
This commit is contained in:
parent
bdc9668e7e
commit
7756394588
15
src/index.js
15
src/index.js
|
@ -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) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue