From f6a2242158fe17d33fbf9f292b1e930041bce1d7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 7 Nov 2013 13:41:15 +0100 Subject: webchat: no more empty messages --- webchat/hello_web.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'webchat/hello_web.js') diff --git a/webchat/hello_web.js b/webchat/hello_web.js index 076097f0..4d420268 100644 --- a/webchat/hello_web.js +++ b/webchat/hello_web.js @@ -65,22 +65,24 @@ echo.on('connection', function(conn) { console.log('data:',data); try { var object = JSON.parse(data); - if (/^\/nick\s+(.+)$/.test(object.message)) { //if nick is send use nick instead of ip - object.from = origin; - } else if (typeof object.nick === 'string') { - object.from = object.nick; - } else { - object.from = origin; - }; - console.log(object.message); - irc_client.say("#krebs", object.from + ' → ' + object.message); - Clients.broadcast(object); + if (object.message.length > 0) { //if message is not empty + if (/^\/nick\s+(.+)$/.test(object.message)) { //if nick is send use nick instead of ip + object.from = origin; + } else if (typeof object.nick === 'string') { + object.from = object.nick; + } else { + object.from = origin; + }; + console.log(object.message); + irc_client.say("#krebs", object.from + ' → ' + object.message); + Clients.broadcast(object); + } } catch (error) { console.log(error); } }); -conn.on('close', function() { //propagate if client quits the page + conn.on('close', function() { //propagate if client quits the page Clients.splice(Clients.indexOf(conn)); Clients.broadcast({from: 'system', message: origin + ' has quit'}) // irc_client.say("#krebs", origin + ' has quit'); -- cgit v1.2.3