Add server + client versions to CTCP VERSION reply
authorDarren <darren@darrenwhitlen.com>
Sat, 29 Mar 2014 15:35:25 +0000 (15:35 +0000)
committerDarren <darren@darrenwhitlen.com>
Sat, 29 Mar 2014 15:35:25 +0000 (15:35 +0000)
client/src/models/gateway.js
server/client.js
server/irc/commands.js
server/kiwi.js

index 0744803a0677e735b5b736fa65f9d34a4b6746e1..c60243732ec2bfa1c3e2dc07420105cb421ec25e 100644 (file)
@@ -247,13 +247,23 @@ _kiwi.model.Gateway = function () {
 \r
 \r
     this.parseKiwi = function (command, data) {\r
+        var client_info_data;\r
+\r
         this.trigger('kiwi:' + command, data);\r
         this.trigger('kiwi', data);\r
 \r
         switch (command) {\r
         case 'connected':\r
+            // Send some info on this client to the server\r
+            client_info_data = {\r
+                command: 'client_info',\r
+                build_version: _kiwi.global.build_version\r
+            };\r
+            this.rpc.call('kiwi', client_info_data);\r
+\r
             this.connect_callback && this.connect_callback();\r
             delete this.connect_callback;\r
+\r
             break;\r
         }\r
     };\r
index d41dc52e3db96568ccc86567c3fa6f87727bab82..1798b3863d84b3272d82c056a0e35204621349c2 100755 (executable)
@@ -147,7 +147,17 @@ function kiwiCommand(command, callback) {
             } else {
                 return callback('Hostname, port and nickname must be specified');
             }
-        break;
+
+            break;
+
+        case 'client_info':
+            // keep hold of selected parts of the client_info
+            this.client_info = {
+                build_version: command.build_version.toString() || undefined
+            };
+
+            break;
+
         default:
             callback();
     }
index e1bf1191b1b765ec7f60398fd30a85ff24da724b..96927dcbb72bba62820e9e197d54f6c0ffb91862 100644 (file)
@@ -585,7 +585,7 @@ handlers = {
     },
 
     'PRIVMSG': function (command) {
-        var tmp, namespace, time, msg;
+        var tmp, namespace, time, msg, version_string, client_info;
 
         // Check if we have a server-time
         time = getServerTime.call(this, command);
@@ -611,7 +611,17 @@ handlers = {
                     time: time
                 });
             } else if (msg.substr(1, 7) === 'VERSION') {
-                this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION KiwiIRC' + String.fromCharCode(1));
+                client_info = this.irc_connection.state.client.client_info;
+                version_string = global.build_version;
+
+                // If the client build_version differs from the server, add this to the version_string
+                if (client_info && client_info.build_version !== global.build_version) {
+                    version_string += ', client build: ' + client_info.build_version;
+                }
+
+                version_string = 'KiwiIRC (' + version_string + ')';
+
+                this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION ' + version_string + String.fromCharCode(1));
             } 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 (msg.substr(1, 10) === 'CLIENTINFO') {
index 68dcf62a6317479bc3d8e332fb61a15154e7d2f9..58df8106a84b64f3c9f39b172137cdd33d372dff 100755 (executable)
@@ -13,6 +13,10 @@ var fs          = require('fs'),
 
 process.chdir(__dirname + '/../');
 
+// Get our own version from package.json
+global.build_version = require('../package.json').version;
+
+// Load the config, using -c argument if available
 (function (argv) {
     var conf_switch = argv.indexOf('-c');
     if (conf_switch !== -1) {