fixed ZNC support
authorpk910 <philipp@zoelle1.de>
Thu, 9 Feb 2012 17:13:41 +0000 (18:13 +0100)
committerpk910 <philipp@zoelle1.de>
Thu, 9 Feb 2012 17:22:16 +0000 (18:22 +0100)
src/IRCParser.c

index c4999828a6b0f889da575f8999e4e48be5e3e22b..b6fc71e8bffbf930c67f872dd691c7ffb256692e 100644 (file)
@@ -482,22 +482,30 @@ static IRC_CMD(raw_topic) {
 
 static IRC_CMD(raw_privmsg) {
     if(from == NULL || argc < 2) return 0;
+    if(!stricmplen(from, "*status", 7) || !stricmplen(from, "-sBNC", 5)) {
+        #ifdef HAVE_THREADS
+        unsigned int tid = (unsigned int) pthread_self_tid();
+        while(!clientsocket_parseorder_top(tid)) {
+            usleep(1000); //1ms
+        }
+        #endif
+        if(!match("Disconnected from IRC.*", argv[1])) {
+            //ZNC DISCONNECT
+            bot_disconnect(client);
+            return 1;
+        }
+        if(!match("* disconnected from the server.", argv[1])) {
+            //sBNC DISCONNECT
+            bot_disconnect(client);
+            return 1;
+        }
+    }
     struct UserNode *user = getUserByMask(from);
     if(user == NULL) {
         user = createTempUserMask(from);
                if(!user) return 0;
         user->flags |= USERFLAG_ISTMPUSER;
     }
-    if(!stricmp(user->nick, "*status") && !match("Disconnected from IRC.*", argv[1])) {
-        //ZNC DISCONNECT
-        bot_disconnect(client);
-        return 1;
-    }
-    if(!stricmp(user->nick, "-sBNC") && !match("* disconnected from the server.", argv[1])) {
-        //sBNC DISCONNECT
-        bot_disconnect(client);
-        return 1;
-    }
     if(argv[0][0] == '#') { //Channel message
         struct ChanNode *chan = getChanByName(argv[0]);
         if(chan && chan->chanbot == client->user) {