multiuser messaging

This commit is contained in:
Baipyrus 2023-02-02 10:45:07 +01:00
parent 5980709885
commit 0367fe45d1
2 changed files with 4 additions and 3 deletions

View File

@ -14,7 +14,7 @@ function runCommand(input) {
// Handle different chat modes // Handle different chat modes
switch (modeSplit[0]) { switch (modeSplit[0]) {
case "msg": case "msg":
directMessage(modeSplit[1], input); directMessage(modeSplit[1].split(','), input);
renameToSelf(); renameToSelf();
return ""; return "";
// case "chat": // case "chat":

View File

@ -151,6 +151,7 @@ function getChatMessages() {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
from: chatMode.split(' ')[1].split(','),
name: window.localStorage.getItem("name"), name: window.localStorage.getItem("name"),
id: window.localStorage.getItem("id") id: window.localStorage.getItem("id")
}) })
@ -177,16 +178,16 @@ function getChatMessages() {
} }
// Send a direct message, do not look at response // Send a direct message, do not look at response
function directMessage(name, message) { function directMessage(names, message) {
fetch('/message', { fetch('/message', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
recipient: name,
name: window.localStorage.getItem("name"), name: window.localStorage.getItem("name"),
id: window.localStorage.getItem("id"), id: window.localStorage.getItem("id"),
to: names,
message message
}) })
}).then(res => {}); }).then(res => {});