From 775639458895caac988821a5a372f0968c19b232 Mon Sep 17 00:00:00 2001 From: osmarks Date: Wed, 3 Oct 2018 18:18:11 +0100 Subject: [PATCH] Rename stuff, add message log --- src/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 547486f..560be18 100644 --- a/src/index.js +++ b/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) }; } }