multiple fixes
[NeonServV5.git] / src / IRCParser.c
index 91b493822ada4d0e89ed042323a5d954ee7b370f..17aeef45ed25ecfaf89d056c2b94d39c4214f497 100644 (file)
@@ -214,12 +214,12 @@ static IRC_CMD(raw_join) {
         //request member list
         chan->chanbot = user;
         struct ChanUser *chanuser = addChanUser(chan, user); //it must be a bot
-        get_userlist_with_invisible(chan, got_channel_userlist, chanuser);
+        get_userlist_with_invisible(chan, 0, got_channel_userlist, chanuser);
         putsock(client, "MODE %s", chan->name);
         putsock(client, "MODE %s +b", chan->name);
     } else if(!isUserOnChan(user, chan) && ((chan->flags & CHANFLAG_RECEIVED_USERLIST) || isBot(user))) {
         struct ChanUser *chanuser = addChanUser(chan, user);
-        if(isModeSet(chan->modes, 'D'))
+        if(isBot(user) && isModeSet(chan->modes, 'D')) //if the bot joins a channel it could also be invisible
             chanuser->flags |= CHANUSERFLAG_INVISIBLE;
         if(!noEvent) {
             if(wasRegistering)
@@ -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) {