summaryrefslogtreecommitdiffstats
path: root/webchat
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-11-07 13:41:15 +0100
committerlassulus <lassulus@googlemail.com>2013-11-07 13:41:15 +0100
commitf6a2242158fe17d33fbf9f292b1e930041bce1d7 (patch)
tree074e7a53659a6059840499bbee4de9b28581ca75 /webchat
parenta8dcc8b3ce76916d3299956b64aa765cb8321482 (diff)
webchat: no more empty messages
Diffstat (limited to 'webchat')
-rw-r--r--webchat/hello_web.js24
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');