From c0bbfb79ac28155847ccca12d9cd6ac5f8035971 Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 1 Jun 2014 12:28:05 +0100 Subject: [PATCH] Combining join, part, kick + quit client events into a single 'channel' event --- client/src/models/gateway.js | 7 +++++++ client/src/models/network.js | 8 ++++---- server/irc/channel.js | 12 ++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/client/src/models/gateway.js b/client/src/models/gateway.js index 4d8e49b..76ffeaf 100644 --- a/client/src/models/gateway.js +++ b/client/src/models/gateway.js @@ -232,6 +232,13 @@ _kiwi.model.Gateway = function () { event_data: data }); } + + if (command == 'channel' && data.type) { + that.trigger('connection:' + data.connection_id.toString(), { + event_name: 'channel:' + data.type, + event_data: data + }); + } } // Trigger the global events diff --git a/client/src/models/network.js b/client/src/models/network.js index f183fdd..b90ad64 100644 --- a/client/src/models/network.js +++ b/client/src/models/network.js @@ -125,10 +125,10 @@ this.gateway.on('options', onOptions, this); this.gateway.on('motd', onMotd, this); - this.gateway.on('join', onJoin, this); - this.gateway.on('part', onPart, this); - this.gateway.on('quit', onQuit, this); - this.gateway.on('kick', onKick, this); + this.gateway.on('channel:join', onJoin, this); + this.gateway.on('channel:part', onPart, this); + this.gateway.on('channel:quit', onQuit, this); + this.gateway.on('channe:kick', onKick, this); this.gateway.on('message', onMessage, this); this.gateway.on('nick', onNick, this); this.gateway.on('ctcp_request', onCtcpRequest, this); diff --git a/server/irc/channel.js b/server/irc/channel.js index 30d53ca..b95dd1f 100644 --- a/server/irc/channel.js +++ b/server/irc/channel.js @@ -54,7 +54,8 @@ function onJoin(event) { irc_event: event }) .done(function() { - that.irc_connection.clientEvent('join', { + that.irc_connection.clientEvent('channel', { + type: 'join', channel: that.name, nick: event.nick, ident: event.ident, @@ -74,7 +75,8 @@ function onPart(event) { irc_event: event }) .done(function() { - that.irc_connection.clientEvent('part', { + that.irc_connection.clientEvent('channel', { + type: 'part', nick: event.nick, ident: event.ident, hostname: event.hostname, @@ -95,7 +97,8 @@ function onKick(event) { irc_event: event }) .done(function() { - that.irc_connection.clientEvent('kick', { + that.irc_connection.clientEvent('channel', { + type: 'kick', kicked: event.kicked, // Nick of the kicked nick: event.nick, // Nick of the kicker ident: event.ident, @@ -117,7 +120,8 @@ function onQuit(event) { irc_event: event }) .done(function() { - that.irc_connection.clientEvent('quit', { + that.irc_connection.clientEvent('channel', { + type: 'quit', nick: event.nick, ident: event.ident, hostname: event.hostname, -- 2.25.1