first message command test
This commit is contained in:
parent
2bbd9dde65
commit
95fbc3cea4
@ -62,3 +62,25 @@ function cmd_echo(input) {
|
||||
return " ";
|
||||
return input.join(' ');
|
||||
}
|
||||
|
||||
async function cmd_msg(input) {
|
||||
if (input === undefined)
|
||||
return "No message given!";
|
||||
const data = {
|
||||
id: user.id,
|
||||
message: input.join(' ')
|
||||
};
|
||||
const res = await fetch('/message', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
if (res.status === 200) {
|
||||
const resData = await res.json();
|
||||
return resData.message;
|
||||
} else
|
||||
return "Server returned status " + res.status;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const pretext = "root@baipyr.us:~# ";
|
||||
const user = { id: crypto.randomUUID(), name: "", history: [] };
|
||||
let pretext = "root@baipyr.us:~# ";
|
||||
|
||||
// Initiating variables
|
||||
const length = pretext.length+1;
|
||||
|
Loading…
Reference in New Issue
Block a user