Add message param to irc.part RPC command (as per #509)
authorJack Allnutt <jack@allnutt.eu>
Sun, 8 Jun 2014 08:28:16 +0000 (09:28 +0100)
committerJack Allnutt <jack@allnutt.eu>
Sun, 8 Jun 2014 08:30:34 +0000 (09:30 +0100)
client/src/models/application.js
client/src/models/gateway.js
server/clientcommands.js

index 4b828f26acadff9d1f3c44b4255a4d675dafb29f..ef12636bf1c28a9bbb096b2bd72580b7a2282690 100644 (file)
     }\r
 \r
     function partCommand (ev) {\r
-        var that = this;\r
-\r
+        var that = this,\r
+            chans,\r
+            msg;\r
         if (ev.params.length === 0) {\r
             this.connections.active_connection.gateway.part(_kiwi.app.panels().active.get('name'));\r
         } else {\r
-            _.each(ev.params, function (channel) {\r
-                that.connections.active_connection.gateway.part(channel);\r
+            chans = ev.params[0].split(',');\r
+            msg = ev.params[1];\r
+            _.each(chans, function (channel) {\r
+                that.connections.active_connection.gateway.part(channel, msg);\r
             });\r
         }\r
     }\r
index 76ffeaf694faf1711a4771bfd746b2d546354a88..1bad0a4156eb991cb94975577e87fbc91e9ec72f 100644 (file)
@@ -348,11 +348,20 @@ _kiwi.model.Gateway = function () {
     /**\r
     *   Leaves a channel\r
     *   @param  {String}    channel     The channel to part\r
+    *   @param  {String}    message     Optional part message\r
     *   @param  {Function}  callback    A callback function\r
     */\r
-    this.part = function (connection_id, channel, callback) {\r
+    this.part = function (connection_id, channel, message, callback) {\r
+        "use strict";\r
+\r
+        // The message param is optional, so juggle args if it is missing\r
+        if (typeof arguments[2] === 'function') {\r
+            callback = arguments[2];\r
+            message = undefined;\r
+        }\r
         var args = {\r
-            channel: channel\r
+            channel: channel,\r
+            message: message\r
         };\r
 \r
         this.rpcCall('irc.part', connection_id, args, callback);\r
index 1eea2eef1a3d6cdde519204ca468452c3a95d941..a60a6e64cebda42eb3c262b0a7c7f4ee35a9aa05 100644 (file)
@@ -158,7 +158,7 @@ var listeners = {
     part: function (irc_connection, callback, args) {\r
         if (args.channel) {\r
             _.each(args.channel.split(","), function (chan) {\r
-                irc_connection.write('PART ' + chan, callback);\r
+                irc_connection.write('PART ' + chan + (args.message ? ' :' + args.message : ''), callback);\r
             });\r
         }\r
     },\r