this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' unknown_command', {
command: command,
- params: params,
- trailing: data.trailing
+ params: params
});
-
-
-/*
- this.irc_connection.emit(namespace + ' ' + command.params[0] + ' notice', {
- from_server: command.prefix ? true : false,
- nick: command.nick || command.prefix || undefined,
- ident: command.ident,
- hostname: command.hostname,
- target: command.params[0],
- msg: command.trailing
- });
- */
- };
+};
handlers = {
'RPL_ENDOFWHOIS': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' endofwhois', {
nick: command.params[1],
- msg: command.trailing
+ msg: command.params[command.params.length - 1]
});
},
'RPL_AWAY': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' whoisaway', {
nick: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
nick: command.params[1],
ident: command.params[2],
host: command.params[3],
- msg: command.trailing
+ msg: command.params[command.params.length - 1]
});
},
this.irc_connection.emit('user ' + command.params[1] + ' whoisserver', {
nick: command.params[1],
irc_server: command.params[2],
- server_info: command.trailing
+ server_info: command.params[command.params.length - 1]
});
},
'RPL_WHOISOPERATOR': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' whoisoperator', {
nick: command.params[1],
- msg: command.trailing
+ msg: command.params[command.params.length - 1]
});
},
'RPL_WHOISCHANNELS': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' whoischannels', {
nick: command.params[1],
- chans: command.trailing
+ chans: command.params[command.params.length - 1]
});
},
'RPL_WHOISMODES': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' whoismodes', {
nick: command.params[1],
- msg: command.trailing
+ msg: command.params[command.params.length - 1]
});
},
'RPL_WHOISREGNICK': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' whoisregnick', {
nick: command.params[1],
- msg: command.trailing
+ msg: command.params[command.params.length - 1]
});
},
'RPL_WHOISHOST': function (command) {
this.irc_connection.emit('user ' + command.params[1] + ' whoishost', {
nick: command.params[1],
- msg: command.trailing
+ msg: command.params[command.params.length - 1]
});
},
nick: command.params[1],
ident: command.params[2],
host: command.params[3],
- real_name: command.trailing
+ real_name: command.params[command.params.length - 1]
});
},
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' list_channel', {
channel: command.params[1],
num_users: parseInt(command.params[2], 10),
- topic: command.trailing
+ topic: command.params[command.params.length - 1]
});
},
this.irc_connection.emit('channel ' + channel + ' info', {
channel: channel,
- url: command.trailing
+ url: command.params[command.params.length - 1]
});
},
'RPL_MOTD': function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' motd', {
- motd: command.trailing + '\n'
+ motd: command.params[command.params.length - 1] + '\n'
});
},
},
'RPL_NAMEREPLY': function (command) {
- var members = command.trailing.split(' ');
+ var members = command.params[command.params.length - 1].split(' ');
var member_list = [];
var that = this;
_.each(members, function (member) {
'RPL_TOPIC': function (command) {
this.irc_connection.emit('channel ' + command.params[1] + ' topic', {
channel: command.params[1],
- topic: command.trailing
+ topic: command.params[command.params.length - 1]
});
},
},
'PING': function (command) {
- this.irc_connection.write('PONG ' + command.trailing);
+ this.irc_connection.write('PONG ' + command.params[command.params.length - 1]);
},
'JOIN': function (command) {
var channel, time;
- if (typeof command.trailing === 'string' && command.trailing !== '') {
- channel = command.trailing;
- } else if (typeof command.params[0] === 'string' && command.params[0] !== '') {
+ if (typeof command.params[0] === 'string' && command.params[0] !== '') {
channel = command.params[0];
}
// Check if we have a server-time
time = getServerTime.call(this, command);
- // Some IRCds (Note: Nefarious) send the channel as the trailing param
- if (!command.params[0]) {
- channel = command.trailing;
- } else {
- channel = command.params[0];
- message = command.trailing;
+ channel = command.params[0];
+ if (command.params.length > 1) {
+ message = command.params[command.params.length - 1];
}
this.irc_connection.emit('channel ' + channel + ' part', {
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- message: command.trailing,
+ message: command.params[command.params.length - 1],
time: time
});
},
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
- message: command.trailing,
+ message: command.params[command.params.length - 1],
time: time
});
},
'NOTICE': function (command) {
var namespace,
- time;
+ time,
+ msg;
// Check if we have a server-time
time = getServerTime.call(this, command);
-
- if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
+ msg = command.params[command.params.length - 1];
+ if ((msg.charAt(0) === String.fromCharCode(1)) && (msg.charAt(msg.length - 1) === String.fromCharCode(1))) {
// It's a CTCP response
- namespace = (command.params[0].toLowerCase() == this.irc_connection.nick.toLowerCase()) ? 'user' : 'channel';
+ namespace = (command.params[0].toLowerCase() === this.irc_connection.nick.toLowerCase()) ? 'user' : 'channel';
this.irc_connection.emit(namespace + ' ' + command.params[0] + ' ctcp_response', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- msg: command.trailing.substring(1, command.trailing.length - 1),
+ msg: msg.substring(1, msg.length - 1),
time: time
});
} else {
- namespace = (command.params[0].toLowerCase() == this.irc_connection.nick.toLowerCase() || command.params[0] == '*') ?
+ namespace = (command.params[0].toLowerCase() === this.irc_connection.nick.toLowerCase() || command.params[0] === '*') ?
'user' :
'channel';
ident: command.ident,
hostname: command.hostname,
target: command.params[0],
- msg: command.trailing,
+ msg: msg,
time: time
});
}
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
- newnick: command.trailing || command.params[0],
+ newnick: command.params[0],
time: time
});
},
var time;
// If we don't have an associated channel, no need to continue
- if (!command.params[0]) return;
+ if (!command.params[0]) {
+ return;
+ }
// Check if we have a server-time
time = getServerTime.call(this, command);
var channel = command.params[0],
- topic = command.trailing || '';
+ topic = command.params[command.params.length - 1] || '';
this.irc_connection.emit('channel ' + channel + ' topic', {
nick: command.nick,
time = getServerTime.call(this, command);
// Get a JSON representation of the modes
- modes = parseModeList.call(this, command.params[1] || command.trailing, command.params.slice(2));
+ modes = parseModeList.call(this, command.params[1], command.params.slice(2));
event = (_.contains(this.irc_connection.options.CHANTYPES, command.params[0][0]) ? 'channel ' : 'user ') + command.params[0] + ' mode';
this.irc_connection.emit(event, {
},
'PRIVMSG': function (command) {
- var tmp, namespace, time;
+ var tmp, namespace, time, msg;
// Check if we have a server-time
time = getServerTime.call(this, command);
- if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
+ msg = command.params[command.params.length - 1];
+ if ((msg.charAt(0) === String.fromCharCode(1)) && (msg.charAt(msg.length - 1) === String.fromCharCode(1))) {
//CTCP request
- if (command.trailing.substr(1, 6) === 'ACTION') {
+ if (msg.substr(1, 6) === 'ACTION') {
this.irc_connection.clientEvent('action', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- msg: command.trailing.substring(8, command.trailing.length - 1),
+ msg: msg.substring(8, msg.length - 1),
time: time
});
- } else if (command.trailing.substr(1, 4) === 'KIWI') {
- tmp = command.trailing.substring(6, command.trailing.length - 1);
+ } else if (msg.substr(1, 4) === 'KIWI') {
+ tmp = msg.substring(6, msg.length - 1);
namespace = tmp.split(' ', 1)[0];
this.irc_connection.clientEvent('kiwi', {
namespace: namespace,
data: tmp.substr(namespace.length + 1),
time: time
});
- } else if (command.trailing.substr(1, 7) === 'VERSION') {
+ } else if (msg.substr(1, 7) === 'VERSION') {
this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION KiwiIRC' + String.fromCharCode(1));
- } else if (command.trailing.substr(1, 6) === 'SOURCE') {
+ } else if (msg.substr(1, 6) === 'SOURCE') {
this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'SOURCE http://www.kiwiirc.com/' + String.fromCharCode(1));
- } else if (command.trailing.substr(1, 10) === 'CLIENTINFO') {
+ } else if (msg.substr(1, 10) === 'CLIENTINFO') {
this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'CLIENTINFO SOURCE VERSION TIME' + String.fromCharCode(1));
} else {
- namespace = (command.params[0].toLowerCase() == this.irc_connection.nick.toLowerCase()) ? 'user' : 'channel';
+ namespace = (command.params[0].toLowerCase() === this.irc_connection.nick.toLowerCase()) ? 'user' : 'channel';
this.irc_connection.emit(namespace + ' ' + command.nick + ' ctcp_request', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
target: command.params[0],
- type: (command.trailing.substring(1, command.trailing.length - 1).split(' ') || [null])[0],
- msg: command.trailing.substring(1, command.trailing.length - 1),
+ type: (msg.substring(1, msg.length - 1).split(' ') || [null])[0],
+ msg: msg.substring(1, msg.length - 1),
time: time
});
}
} else {
// A message to a user (private message) or to a channel?
- namespace = (command.params[0].toLowerCase() == this.irc_connection.nick.toLowerCase()) ? 'user ' + command.nick : 'channel ' + command.params[0];
+ namespace = (command.params[0].toLowerCase() === this.irc_connection.nick.toLowerCase()) ? 'user ' + command.nick : 'channel ' + command.params[0];
this.irc_connection.emit(namespace + ' privmsg', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- msg: command.trailing,
+ msg: msg,
time: time
});
}
'CAP': function (command) {
// TODO: capability modifiers
// i.e. - for disable, ~ for requires ACK, = for sticky
- var capabilities = command.trailing.replace(/(?:^| )[\-~=]/, '').split(' ');
+ var capabilities = command.params[command.params.length - 1].replace(/(?:^| )[\-~=]/, '').split(' ');
var request;
// Which capabilities we want to enable
this.irc_connection.emit('user ' + command.nick + ' away', {
nick: command.nick,
- msg: command.trailing,
+ msg: command.params[command.params.length - 1],
time: time
});
},
'ERROR': function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' error', {
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_PASSWDMISMATCH: function (command) {
ERR_NOSUCHNICK: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' no_such_nick', {
nick: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_CANNOTSENDTOCHAN: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' cannot_send_to_chan', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_TOOMANYCHANNELS: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' too_many_channels', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' user_not_in_channel', {
nick: command.params[0],
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_NOTONCHANNEL: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' not_on_channel', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_CHANNELISFULL: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' channel_is_full', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_INVITEONLYCHAN: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' invite_only_channel', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_BANNEDFROMCHAN: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' banned_from_channel', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_BADCHANNELKEY: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' bad_channel_key', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_CHANOPRIVSNEEDED: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' chanop_privs_needed', {
channel: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_NICKNAMEINUSE: function (command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' nickname_in_use', {
nick: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
ERR_ERRONEUSNICKNAME: function(command) {
this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' erroneus_nickname', {
nick: command.params[1],
- reason: command.trailing
+ reason: command.params[command.params.length - 1]
});
},
RPL_MAPMORE: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_MAPEND: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LINKS: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_ENDOFLINKS: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
ERR_UNKNOWNCOMMAND: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, '`' + params.join(', ') + '` ' + command.trailing);
+ genericNotice.call(this, command, '`' + params.slice(0, -1).join(', ') + '` ' + command.params[command.params.length - 1]);
},
ERR_NOMOTD: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, command.trailing);
+ genericNotice.call(this, command, command.params[command.params.length - 1]);
},
ERR_NOPRIVILEGES: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, command.trailing);
+ genericNotice.call(this, command, command.params[command.params.length - 1]);
},
RPL_STATSCONN: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LUSERCLIENT: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LUSEROP: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LUSERUNKNOWN: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LUSERCHANNELS: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LUSERME: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_LOCALUSERS: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},
RPL_GLOBALUSERS: function (command) {
var params = _.clone(command.params);
params.shift();
- genericNotice.call(this, command, params.join(', ') + ' ' + command.trailing);
+ genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
}
};