]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/chanservnetevents.c
fix bug in G stats
[irc/quakenet/newserv.git] / chanserv / chanservnetevents.c
index bbb158ad9e8b215c0c980592dcec20cfe312122c..0320b00b86011732cdbcdcc9702115343602d677 100644 (file)
@@ -32,20 +32,12 @@ void cs_handlesethost(int hooknum, void *arg) {
 
 void cs_handlelostnick(int hooknum, void *arg) {
   nick *np=(nick *)arg;
-  nicklist **nlh;
-  nicklist *nlp;
   reguser *rup;
   
   if ((rup=getreguserfromnick(np))) {
-    for (nlh=&(rup->nicks);*nlh;nlh=&((*nlh)->next)) {
-      if ((*nlh)->np==np) {
-        nlp=*nlh;
-        *nlh=nlp->next;
-        freenicklist(nlp);
-        break;
-      }
-    }
-    if ((rup->status & QUSTAT_DEAD) && !rup->nicks) {
+    /* Clean up if this is the last user.  auth->usercount is decremented
+     * AFTER the hook is sent... */
+    if ((rup->status & QUSTAT_DEAD) && (np->auth->usercount==1)) {
       freereguser(rup);
     }  
   }
@@ -157,6 +149,10 @@ void cs_handlejoin(int hooknum, void *arg) {
   
   if (rup && (rcup=findreguseronchannel(rcp,rup)) && CUKnown(rcup) && cp->users->totalusers >= 3)
     rcp->lastactive=time(NULL);
+
+  /* Update last use time */
+  if (rcup)
+    rcup->usetime=getnettime();
   
   if (rcp->lastcountersync < (time(NULL) - COUNTERSYNCINTERVAL)) {
     csdb_updatechannelcounters(rcp);
@@ -179,36 +175,41 @@ void cs_handlejoin(int hooknum, void *arg) {
     isopped=iscreate=0;
   }  
 
-  /* Check for "Q ban" */
-  if (!IsService(np) && cs_bancheck(np,cp)) {
-    /* They got kicked.. */
-    return;
-  }
+  /* Various things that can ban the user on join.  Don't apply these to anyone
+   * with one of +k, +X, +o */
+  if (!IsService(np) && !IsOper(np) && !IsXOper(np)) {
+    /* Check for "Q ban" */
+    if (cs_bancheck(np,cp)) {
+      /* They got kicked.. */
+      return;
+    }
 
-  /* Check for other ban lurking on channel which we are enforcing */
-  if (!IsService(np) && CIsEnforce(rcp) && nickbanned(np,cp)) {
-    localkickuser(chanservnick,cp,np,"Banned.");
-    return;
-  }
+    /* Check for other ban lurking on channel which we are enforcing */
+    if (CIsEnforce(rcp) && nickbanned_visible(np,cp)) {
+      localkickuser(chanservnick,cp,np,"Banned.");
+      return;
+    }
 
-  /* Check for +b chanlev flag */
-  if (!IsService(np) && rcup && CUIsBanned(rcup)) {
-    cs_banuser(NULL, cip, np, NULL);
-    cs_timerfunc(cip);
-    return;
-  } 
-
-  /* Check for +k chan flag */
-  if (!IsService(np) && CIsKnownOnly(rcp) && !(rcup && CUKnown(rcup))) {
-    if (IsInviteOnly(cp) || (IsRegOnly(cp) && !IsAccount(np))) {
-      localkickuser(chanservnick,cp,np,"Authorised users only.");
-    } else {      
-      cs_banuser(NULL, cip, np, "Authorised users only.");
+    /* Check for +b chanlev flag */
+    if (rcup && CUIsBanned(rcup)) {
+      cs_banuser(NULL, cip, np, NULL);
       cs_timerfunc(cip);
+      return;
+    } 
+
+    /* Check for +k chan flag */
+    if (CIsKnownOnly(rcp) && !(rcup && CUKnown(rcup))) {
+      /* Don't ban if they are already "visibly" banned for some reason. */
+      if (IsInviteOnly(cp) || (IsRegOnly(cp) && !IsAccount(np))) {
+        localkickuser(chanservnick,cp,np,"Authorised users only.");
+      } else {      
+        cs_banuser(NULL, cip, np, "Authorised users only.");
+        cs_timerfunc(cip);
+      }
+      return;
     }
-    return;
   }
-
+  
   if (!rup || !rcup) {
     /* They're not a registered user, so deop if it is a create */
     if (isopped && !IsService(np)) {
@@ -224,8 +225,6 @@ void cs_handlejoin(int hooknum, void *arg) {
       dowelcome=2;  /* Send a generic warning */
     }
   } else {
-    /* Update last use time */
-    rcup->usetime=getnettime();
 
     /* DB update removed for efficiency..
      * csdb_updatelastjoin(rcup); */
@@ -236,6 +235,7 @@ void cs_handlejoin(int hooknum, void *arg) {
       /* Auto op */
       if (!isopped) {
         modes |= MC_OP;
+        cs_logchanop(rcp, np->nick, rup);
       }
     } else {
       /* Not auto op; deop them if they are opped and are not allowed them */
@@ -274,11 +274,15 @@ void cs_handlejoin(int hooknum, void *arg) {
           break;
   }        
 
-  if (rup && rcup && CIsInfo(rcp) && UIsInfo(rcup->user) && !CUIsHideInfo(rcup) && chanservnick) {
-    if (rcup->info) {
+  /* Display infoline if... (deep breath) user is registered, known on channel,
+   * user,channel,chanlev all +i and user,channel,chanlev all -s AND Q online */
+  if (rup && rcup && 
+      CIsInfo(rcp) && UIsInfo(rcup->user) && CUIsInfo(rcup) && 
+      !CIsNoInfo(rcp) && !UIsNoInfo(rcup->user) && !CUIsNoInfo(rcup) && chanservnick) {
+    if (rcup->info && *(rcup->info->content)) {
       /* Chan-specific info */
       sendmessagetochannel(chanservnick, cp, "[%s] %s",np->nick, rcup->info->content);
-    } else if (rup->info) {
+    } else if (rup->info && *(rup->info->content)) {
       /* Default info */
       sendmessagetochannel(chanservnick, cp, "[%s] %s",np->nick, rup->info->content);
     }
@@ -405,7 +409,7 @@ void cs_handlenewban(int hooknum, void *arg) {
          Error("chanserv",ERR_WARNING,"Found user on channel %s who doesn't exist!",cp->index->name->content);
          continue;
        }
-       if (!IsService(np) && nickmatchban(np,cbp)) {
+       if (!IsService(np) && nickmatchban_visible(np,cbp)) {
          localkickuser(chanservnick,cp,np,"Banned.");
        }
       }