From: Jack Allnutt Date: Sun, 8 Jun 2014 08:28:16 +0000 (+0100) Subject: Add message param to irc.part RPC command (as per #509) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7f272ac9f56471ac4fc7030cc767cc2a1d335bfd;p=KiwiIRC.git Add message param to irc.part RPC command (as per #509) --- diff --git a/client/src/models/application.js b/client/src/models/application.js index 4b828f2..ef12636 100644 --- a/client/src/models/application.js +++ b/client/src/models/application.js @@ -554,13 +554,16 @@ } function partCommand (ev) { - var that = this; - + var that = this, + chans, + msg; if (ev.params.length === 0) { this.connections.active_connection.gateway.part(_kiwi.app.panels().active.get('name')); } else { - _.each(ev.params, function (channel) { - that.connections.active_connection.gateway.part(channel); + chans = ev.params[0].split(','); + msg = ev.params[1]; + _.each(chans, function (channel) { + that.connections.active_connection.gateway.part(channel, msg); }); } } diff --git a/client/src/models/gateway.js b/client/src/models/gateway.js index 76ffeaf..1bad0a4 100644 --- a/client/src/models/gateway.js +++ b/client/src/models/gateway.js @@ -348,11 +348,20 @@ _kiwi.model.Gateway = function () { /** * Leaves a channel * @param {String} channel The channel to part + * @param {String} message Optional part message * @param {Function} callback A callback function */ - this.part = function (connection_id, channel, callback) { + this.part = function (connection_id, channel, message, callback) { + "use strict"; + + // The message param is optional, so juggle args if it is missing + if (typeof arguments[2] === 'function') { + callback = arguments[2]; + message = undefined; + } var args = { - channel: channel + channel: channel, + message: message }; this.rpcCall('irc.part', connection_id, args, callback); diff --git a/server/clientcommands.js b/server/clientcommands.js index 1eea2ee..a60a6e6 100644 --- a/server/clientcommands.js +++ b/server/clientcommands.js @@ -158,7 +158,7 @@ var listeners = { part: function (irc_connection, callback, args) { if (args.channel) { _.each(args.channel.split(","), function (chan) { - irc_connection.write('PART ' + chan, callback); + irc_connection.write('PART ' + chan + (args.message ? ' :' + args.message : ''), callback); }); } },