diff options
author | tv <tv@nomic.retiolum> | 2013-11-07 13:49:00 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-11-07 13:49:00 +0100 |
commit | 9e2500389cda454c1ef99308c355e271b0f6b4b6 (patch) | |
tree | 2da4480c1bc982cf5a9d461ae47da9984026a6ed /webchat/hello_web.js | |
parent | c5d1a95fd0792de7c8fbe93768dce9662f0b948f (diff) | |
parent | e3027c0a6d34b89a2733e27a4be2074e34182288 (diff) |
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'webchat/hello_web.js')
-rw-r--r-- | webchat/hello_web.js | 24 |
1 files changed, 13 insertions, 11 deletions
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'); |