Merge M2Ys4U-joinfix
[KiwiIRC.git] / server / irc / commands.js
index 71b848235b2e533692662909f8c47c78e850a14f..b17ec4f3a4bff2c49643075590637afe6d8249bf 100644 (file)
@@ -14,6 +14,7 @@ var irc_numerics = {
     RPL_LUSERME:            '255',
     RPL_LOCALUSERS:         '265',
     RPL_GLOBALUSERS:        '266',
+    RPL_AWAY:               '301',
     RPL_WHOISREGNICK:       '307',
     RPL_WHOISUSER:          '311',
     RPL_WHOISSERVER:        '312',
@@ -136,6 +137,12 @@ var listeners = {
             msg: command.trailing
         });
     },
+    'RPL_AWAY': function (command) {
+        this.irc_connection.emit('user ' + command.params[1] + ' whoisaway', {
+            nick: command.params[1],
+            reason: command.trailing
+        });
+    },
     'RPL_WHOISUSER': function (command) {
         this.irc_connection.emit('user ' + command.params[1] + ' whoisuser', {
             nick: command.params[1],
@@ -343,9 +350,13 @@ var listeners = {
                 msg: command.trailing.substr(1, command.trailing.length - 2)
             });
         } else {
-            namespace = (command.params[0] == this.irc_connection.nick) ? 'user' : 'channel';
+            namespace = (command.params[0] == this.irc_connection.nick || command.params[0] == '*') ?
+                'user' :
+                'channel';
+
             this.irc_connection.emit(namespace + ' ' + command.params[0] + ' notice', {
-                nick: command.nick,
+                from_server: command.prefix ? true : false,
+                nick: command.nick || command.prefix || undefined,
                 ident: command.ident,
                 hostname: command.hostname,
                 target: command.params[0],
@@ -754,6 +765,7 @@ function genericNotice (command, msg, is_error) {
 
     this.client.sendIrcCommand('notice', {
         server: this.con_num,
+        from_server: true,
         nick: command.prefix,
         ident: '',
         hostname: '',