]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add automatic join on Q invites.
authorChris Porter <redacted>
Sat, 6 Dec 2008 15:50:20 +0000 (15:50 +0000)
committerChris Porter <redacted>
Sat, 6 Dec 2008 15:50:20 +0000 (15:50 +0000)
TODO.txt
js/irc/ircclient.js
js/ui/optionspane.js

index 6e28317164e6b383488d514e6cf43f3c19dc7de8..8fa297f0ff7ac94454d6b79e1a4fc945691d1e96 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -8,6 +8,9 @@ UI:
   FEAT: Last position line\r
   FEAT: branding\r
   TIDY: warning/info messages should have their colour decided by CSS\r
+  FEAT: privacy policy\r
+  FEAT: +x\r
+  TIDY: connect dialog offset looks non-centred\r
   \r
 Authing:\r
   TIDY: Finish integration (notably login button on non-autoconnect page).\r
index d8c742b419d4eefc9fbc8849f441a27ddfd8a971..5d138a30f5a1f4d6e46992bf3732445d83ec3470 100644 (file)
@@ -19,6 +19,9 @@ qwebirc.irc.IRCClient = new Class({
 
     this.statusWindow = this.ui.newClient(this);
     this.lastNicks = [];
+    
+    this.inviteChanList = [];
+    this.activeTimers = {};
   },
   newLine: function(window, type, data) {
     if(!data)
@@ -388,11 +391,29 @@ qwebirc.irc.IRCClient = new Class({
       this.newTargetOrActiveLine(nick, "PRIVNOTICE", {"m": message, "h": host, "n": nick});
     }
   },
+  isNetworkService: function(user) {
+    /* TODO: refactor */
+    return user == "Q!TheQBot@CServe.quakenet.org";
+  },
+  __joinInvited: function() {
+    this.exec("/JOIN " + this.inviteChanList.join(","));
+    this.inviteChanList = [];
+    delete this.activeTimers["serviceInvite"];
+  },
   userInvite: function(user, channel) {
     var nick = user.hostToNick();
     var host = user.hostToHost();
 
     this.newServerLine("INVITE", {"c": channel, "h": host, "n": nick});
+    if(this.ui.uiOptions.ACCEPT_SERVICE_INVITES && this.isNetworkService(user)) {
+      if(this.activeTimers.serviceInvite)
+        $clear(this.activeTimers.serviceInvite);
+        
+      /* we do this so we can batch the joins, i.e. instead of sending 5 JOIN comands we send 1 with 5 channels. */
+      this.activeTimers.serviceInvite = this.__joinInvited.delay(100, this);
+      
+      this.inviteChanList.push(channel);
+    }
   },
   userMode: function(modes) {
     this.newServerLine("UMODE", {"m": modes, "n": this.nickname});
@@ -451,6 +472,14 @@ qwebirc.irc.IRCClient = new Class({
     this.send("QUIT :" + message);
     this.disconnect();
   },
+  disconnect: function() {
+    for(var k in this.activeTimers) {
+      this.activeTimers[k].cancel();
+    };
+    this.activeTimers = {};
+    
+    this.parent();
+  },
   awayMessage: function(nick, message) {
     this.newQueryLine(nick, "AWAY", {"n": nick, "m": message}, true);
   },
index fc698f81499e79f62530522eaea2d924032e8d40..ce2ad297d1235fbbac8d5c80b7a8b7b1e3df4338 100644 (file)
@@ -17,7 +17,8 @@ qwebirc.config.DEFAULT_OPTIONS = [
   }],
   [2, "DEDICATED_MSG_WINDOW", "Send privmsgs to dedicated messages window", false],
   [4, "DEDICATED_NOTICE_WINDOW", "Send notices to dedicated message window", false],
-  [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames", true]
+  [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames", true],
+  [5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true],
 ];
 
 qwebirc.config.DefaultOptions = null;