From a7973dfbd0e326ed48710df1830affd27931008b Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Fri, 25 Jan 2013 03:00:42 +0000 Subject: [PATCH] MODE handling --- server/irc/channel.js | 11 ++++++++++- server/irc/commands.js | 7 ++++--- server/irc/user.js | 11 ++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/server/irc/channel.js b/server/irc/channel.js index 3a8993f..99b19ff 100644 --- a/server/irc/channel.js +++ b/server/irc/channel.js @@ -37,7 +37,8 @@ IrcChannel.prototype.irc_events = { nicklistEnd: onNicklistEnd, banlist: onBanList, banlist_end: onBanListEnd, - topicsetby: onTopicSetby + topicsetby: onTopicSetby, + mode: onMode }; @@ -194,6 +195,14 @@ function onTopicSetBy(event) { }); }; +function onMode(event) { + this.irc_connection.clientEvent('mode', { + target: event.target, + nick: event.nick, + modes: event.modes + }); +}; + /* server:event diff --git a/server/irc/commands.js b/server/irc/commands.js index a58355f..dd0f4aa 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -372,7 +372,7 @@ var listeners = { prefixes = this.irc_connection.options.PREFIX || [], always_param = (chanmodes[0] || '').concat((chanmodes[1] || '')), modes = [], - has_param, i, j, add; + has_param, i, j, add, event; prefixes = _.reduce(prefixes, function (list, prefix) { list.push(prefix.mode); @@ -416,8 +416,9 @@ var listeners = { } } - this.client.sendIrcCommand('mode', { - server: this.con_num, + event = (_.contains(this.irc_connection.options.CHANTYPES, command.params[0][0]) ? 'channel' : 'user') + command.params[0] + ':mode'; + + this.irc_connection.emit(event, { target: command.params[0], nick: command.nick || command.prefix || '', modes: modes diff --git a/server/irc/user.js b/server/irc/user.js index f3ba146..2ca5117 100755 --- a/server/irc/user.js +++ b/server/irc/user.js @@ -27,7 +27,8 @@ IrcUser.prototype.irc_events = { notice: onNotice, ctcp_response: onCtcpResponse, privmsg: onPrivmsg, - ctcp_request: onCtcpRequest + ctcp_request: onCtcpRequest, + mode: onMode }; function onNick(event) { @@ -162,3 +163,11 @@ function onCtcpRequest(event) { msg: event.msg }); }; + +function onMode(event) { + this.irc_connection.clientEvent('mode', { + target: event.target, + nick: event.nick, + modes: event.modes + }); +}; -- 2.25.1