]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nick/nickhandlers.c
Add server mask (/msg $*.quakenet.org) support.
[irc/quakenet/newserv.git] / nick / nickhandlers.c
index 110c80f43dcf32cfd43e064d743b619ba6f86229..0f341776cda20a497cdd07a3eb706ad95f685e18 100644 (file)
@@ -27,7 +27,10 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
   nick **nh;
   char *fakehost;
   char *accountts;
+  char *accountflags;
   struct irc_in_addr ipaddress;
+  char *accountid;
+  unsigned long userid;
   
   if (cargc==2) { /* rename */
     /* Nyklon 1017697578 */
@@ -138,6 +141,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     base64toip(cargv[cargc-3], &ipaddress);
     /* todo: use a single node for /64 prefixes */
     np->ipnode = refnode(iptree, &ipaddress, irc_in_addr_is_ipv4(&ipaddress) ? PATRICIA_MAXBITS : 64);
+    node_increment_usercount(np->ipnode);
 
     np->shident=NULL;
     np->sethost=NULL;
@@ -145,14 +149,31 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     np->marker=0;
     memset(np->exts, 0, MAXNICKEXTS * sizeof(void *));
     np->authname[0]='\0';
+    np->auth=NULL;
     if(cargc>=9) {
       setflags(&(np->umodes),UMODE_ALL,cargv[5],umodeflags,REJECT_NONE);
       if (IsAccount(np)) {
         if ((accountts=strchr(cargv[6],':'))) {
           *accountts++='\0';
-          np->accountts=strtoul(accountts,NULL,10);
+          np->accountts=strtoul(accountts,&accountid,10);
+          if(accountid) {
+            userid=strtoul(accountid + 1,&accountflags,10);
+            if(!userid) {
+              np->auth=NULL;
+            } else {
+              np->auth=findorcreateauthname(userid, cargv[6]);
+              np->auth->usercount++;
+              np->nextbyauthname=np->auth->nicks;
+              np->auth->nicks=np;
+              if(accountflags)
+                np->auth->flags=strtoul(accountflags + 1,NULL,10);
+            }
+          } else {
+            np->auth=NULL;
+          }
         } else {
           np->accountts=0;
+          np->auth=NULL;
         }        
         strncpy(np->authname,cargv[6],ACCOUNTLEN);
         np->authname[ACCOUNTLEN]='\0';
@@ -193,8 +214,8 @@ int handlequitmsg(void *source, int cargc, char **cargv) {
   nick *np;
   void *harg[2];
   
-  if (cargc>1) {
-    harg[1]=(void *)cargv[1];
+  if (cargc>0) {
+    harg[1]=(void *)cargv[0];
   } else {
     harg[1]="";
   } 
@@ -212,13 +233,24 @@ int handlequitmsg(void *source, int cargc, char **cargv) {
 
 int handlekillmsg(void *source, int cargc, char **cargv) {
   nick *np;
-  
+  void *harg[2];
+#warning Fix me to use source
+
   if (cargc<1) {
     Error("nick",ERR_WARNING,"Kill message with too few parameters");
     return CMD_ERROR;  
   }
+
+  if (cargc>1) {
+    harg[1]=(void *)cargv[1];
+  } else {
+    harg[1]="";
+  } 
+  
   np=getnickbynumericstr(cargv[0]);
   if (np) {
+    harg[0]=(void *)np;
+    triggerhook(HOOK_NICK_KILL, harg);
     deletenick(np);
   } else {
     Error("nick",ERR_WARNING,"Kill for non-existant numeric %s",cargv[0]);
@@ -337,6 +369,7 @@ int handlewhoismsg(void *source, int cargc, char **cargv) {
 
 int handleaccountmsg(void *source, int cargc, char **cargv) {
   nick *target;
+  unsigned long userid;
   
   if (cargc<2) {
     return CMD_OK;
@@ -353,7 +386,29 @@ int handleaccountmsg(void *source, int cargc, char **cargv) {
   SetAccount(target);
   strncpy(target->authname,cargv[1],ACCOUNTLEN);
   target->authname[ACCOUNTLEN]='\0';
-
+  
+  if (cargc>=3) {
+    target->accountts=strtoul(cargv[2],NULL,10);
+    if (cargc>=4) {
+      userid=strtoul(cargv[3],NULL,10);
+      if(!userid) {
+        target->auth=NULL;
+      } else {
+        target->auth=findorcreateauthname(userid, target->authname);
+        target->auth->usercount++;
+        target->nextbyauthname = target->auth->nicks;
+        target->auth->nicks = target;
+        if (cargc>=5)
+          target->auth->flags=strtoul(cargv[4],NULL,10);
+      }
+    } else {
+      target->auth=NULL;
+    }
+  } else {
+    target->accountts=0;
+    target->auth=NULL;
+  }
+  
   triggerhook(HOOK_NICK_ACCOUNT, (void *)target);
 
   return CMD_OK;
@@ -409,3 +464,31 @@ int handlestatsmsg(void *source, int cargc, char **cargv) {
 
   return CMD_OK;
 }
+
+int handleprivmsg(void *source, int cargc, char **cargv) {
+  nick *sender;
+  char *message;
+  void *args[3];
+
+  if (cargc<2)
+    return CMD_OK;
+
+  if (cargv[0][0]!='$')
+    return CMD_OK;
+
+  sender=getnickbynumericstr((char *)source);
+
+  if (!match2strings(cargv[0] + 1,myserver->content))
+    return CMD_OK;
+
+  message=cargv[0];
+
+  args[0]=sender;
+  args[1]=cargv[0];
+  args[2]=cargv[1];
+
+  triggerhook(HOOK_NICK_MASKPRIVMSG, (void *)args);
+
+  return CMD_OK;
+}
+