From 059f4918c3e3e53095ef624e93abd5e85781402e Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Fri, 25 Jan 2013 00:40:53 +0000 Subject: [PATCH] More channel commands --- server/irc/channel.js | 35 ++++++++++++++++++++++++++++++++++- server/irc/commands.js | 27 ++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/server/irc/channel.js b/server/irc/channel.js index 345b580..1825969 100644 --- a/server/irc/channel.js +++ b/server/irc/channel.js @@ -4,6 +4,7 @@ function IrcChannel(irc_connection, name) { this.name = name; this.members = []; + this.ban_list_buffer = []; } @@ -29,7 +30,10 @@ IrcChannel.prototype.bindEvents = function() { ctcp_response: onCtcpResponse, topic: onTopic, nicklist: onNicklist, - nicklistEnd: onNicklistEnd + nicklistEnd: onNicklistEnd, + banlist: onBanList, + banlist_end: onBanListEnd, + topicsetby: onTopicSetby }; } @@ -181,6 +185,35 @@ function onTopic(event) { }); }; + +function onBanList(event) { + this.ban_list_buffer.push(event); +}; + +function onBanListEnd(event) { + var that = this; + this.ban_list_buffer.forEach(function (ban) { + that.irc_connection.clientEvent('banlist', ban); + }); + this.ban_list_buffer = []; +}; + +function onTopic(event) { + this.irc_connection.clientEvent('topic', { + channel: event.channel, + topic: event.topic + }); +}; + +function onTopicSetBy(event) { + this.irc_connection.clientEvent('topicsetby', { + nick: event.nick, + channel: event.channel, + when: event.when + }); +}; + + /* server:event server:* diff --git a/server/irc/commands.js b/server/irc/commands.js index a494302..1f05857 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -238,19 +238,36 @@ var listeners = { 'RPL_BANLIST': function (command) { - this.client.sendIrcCommand('banlist', {server: this.con_num, channel: command.params[1], banned: command.params[2], banned_by: command.params[3], banned_at: command.params[4]}); + this.irc_connection.emit('channel:' + command.params[1] + ':banlist', { + channel: command.params[1], + banned: command.params[2], + banned_by: command.params[3], + banned_at: command.params[4] + }); }, 'RPL_ENDOFBANLIST': function (command) { - this.client.sendIrcCommand('banlist_end', {server: this.con_num, channel: command.params[1]}); + this.irc_connection.emit('channel:' + command.params[1] + ':banlist_end', { + channel: commands.params[1] + }); }, 'RPL_TOPIC': function (command) { - this.client.sendIrcCommand('topic', {server: this.con_num, nick: '', channel: command.params[1], topic: command.trailing}); + this.irc_connection.emit('channel:' + command.params[1] + ':topic', { + channel: command.params[1], + topic: command.trailing + }); }, 'RPL_NOTOPIC': function (command) { - this.client.sendIrcCommand('topic', {server: this.con_num, nick: '', channel: command.params[1], topic: ''}); + this.irc_connection.emit('channel:' + command.params[1] + ':topic', { + channel: command.params[1], + topic: '' + }); }, 'RPL_TOPICWHOTIME': function (command) { - this.client.sendIrcCommand('topicsetby', {server: this.con_num, nick: command.params[2], channel: command.params[1], when: command.params[3]}); + this.irc_connection.emit('channel:' + command.params[1] + ':topicsetby', { + nick: command.params[2], + channel: command.params[1], + when: command.params[3] + }); }, 'PING': function (command) { this.irc_connection.write('PONG ' + command.trailing); -- 2.25.1