From 3808842dc1530c879acafe6597d7c5802bdf3d23 Mon Sep 17 00:00:00 2001 From: jak1 Date: Thu, 12 Jan 2023 13:06:10 +0100 Subject: added basic chat emotes --- app.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 3601207..efee026 100644 --- a/app.js +++ b/app.js @@ -96,7 +96,7 @@ io.sockets.on('connection', function(socket){ socket.on('sendMsgToServer', function(data){ if (data) for (var i in SOCKET_LIST){ - SOCKET_LIST[i].emit('addToChat', {ctimestamp: getTimeStamp(0), content: socket.playerName + ': ' + escapeHTML(data), tab: "world"}); + SOCKET_LIST[i].emit('addToChat', {ctimestamp: getTimeStamp(0), content: socket.playerName + ': ' + escapeHTML(chatEmote(data)), tab: "world"}); } }); @@ -328,4 +328,17 @@ escapeHTML = function(unsafe) { .replace(/>/g, ">") .replace(/"/g, """) .replace(/'/g, "'"); - } \ No newline at end of file + } + +chatEmote = function(msg) { + return msg.replace(":D", "😀") + .replace("O:)", "😇") + .replace("0:)", "😇") + .replace(":)", "🙂") + .replace(":(", "🙁") + .replace(":o", "😮") + .replace(":O", "😲") + .replace(":'(", "😢") + .replace(":')", "🥲") + .replace(":P", "😛"); +} -- cgit v1.2.3-70-g09d2