prevent sending or logging of empty chats
This commit is contained in:
parent
5c936df3f6
commit
cdaa7c678d
|
@ -315,6 +315,7 @@ composeBox.addEventListener("keypress", event => {
|
|||
});
|
||||
|
||||
function sendChat(msg) {
|
||||
if (msg === "") return;
|
||||
setTimeout(() => {
|
||||
if (!ws) return;
|
||||
ws.send(JSON.stringify({
|
||||
|
|
|
@ -131,12 +131,12 @@ export function init(http_server) {
|
|||
case "chat":
|
||||
if (data.msg === undefined)
|
||||
throw new Error("Attempted chat with no message");
|
||||
Log.info('<' + socket.player.name + '> ' + data.msg)
|
||||
data.msg = data.msg.replaceAll("<", "<")
|
||||
data.msg = data.msg.replaceAll(">", ">")
|
||||
data.msg = data.msg.replaceAll("\n", "");
|
||||
data.msg = data.msg.trim();
|
||||
if (data.msg == "") return;
|
||||
Log.info('<' + socket.player.name + '> ' + data.msg)
|
||||
clients.forEach(client => {
|
||||
client.send(JSON.stringify({
|
||||
type: "chat",
|
||||
|
|
Loading…
Reference in a new issue