Action sending/recieving
authorDarren <darren@darrenwhitlen.com>
Fri, 31 Aug 2012 21:30:55 +0000 (22:30 +0100)
committerDarren <darren@darrenwhitlen.com>
Fri, 31 Aug 2012 21:30:55 +0000 (22:30 +0100)
client_backbone/model_application.js

index f1a5faa3aafca8c3fd74c9d4230b96c2520bf016..b53e192419f48023942bb99ceb7eaf007d6d383a 100644 (file)
@@ -162,6 +162,31 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
         });\r
 \r
 \r
+        gw.on('onaction', function (event) {\r
+            var panel,\r
+                is_pm = (event.channel == kiwi.gateway.get('nick'));\r
+\r
+            if (is_pm) {\r
+                // If a panel isn't found for this PM, create one\r
+                panel = that.panels.getByName(event.nick);\r
+                if (!panel) {\r
+                    panel = new kiwi.model.Channel({name: event.nick});\r
+                    that.panels.add(panel);\r
+                }\r
+\r
+            } else {\r
+                // If a panel isn't found for this channel, reroute to the\r
+                // server panel\r
+                panel = that.panels.getByName(event.channel);\r
+                if (!panel) {\r
+                    panel = that.panels.server;\r
+                }\r
+            }\r
+\r
+            panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action');\r
+        });\r
+\r
+\r
         gw.on('ontopic', function (event) {\r
             var c;\r
             c = that.panels.getByName(event.channel);\r
@@ -264,6 +289,9 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
         controlbox.on('command', this.allCommands);\r
         controlbox.on('command_msg', this.msgCommand);\r
 \r
+        controlbox.on('command_action', this.actionCommand);\r
+        controlbox.on('command_me', this.actionCommand);\r
+\r
         controlbox.on('command_join', this.joinCommand);\r
         controlbox.on('command_j', this.joinCommand);\r
 \r
@@ -349,6 +377,16 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
         kiwi.gateway.privmsg(destination, ev.params.join(' '));\r
     };\r
 \r
+    this.actionCommand = function (ev) {\r
+        if (kiwi.current_panel === kiwi.app.panels.server) {\r
+            return;\r
+        }\r
+\r
+        var panel = kiwi.current_panel;\r
+        panel.addMsg('', '* ' + kiwi.gateway.get('nick') + ' ' + ev.params.join(' '), 'action');\r
+        kiwi.gateway.action(panel.get('name'), ev.params.join(' '));\r
+    };\r
+\r
     this.partCommand = function (ev) {\r
         if (ev.params.length === 0) {\r
             kiwi.gateway.part(kiwi.current_panel.get('name'));\r