]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nick/nickhandlers.c
NICK: send oldnick as part of HOOK_NICK_RENAME.
[irc/quakenet/newserv.git] / nick / nickhandlers.c
index 4f208a48c6983d258bad6fd779f2efa775356810..4b280cc6f450441db2ab4aacf0550e55f03128a9 100644 (file)
@@ -34,6 +34,9 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
   unsigned long userid;
   
   if (cargc==2) { /* rename */
+    char oldnick[NICKLEN+1];
+    void *harg[2];
+
     /* Nyklon 1017697578 */
     timestamp=strtol(cargv[1],NULL,10);
     np=getnickbynumericstr(sender);
@@ -41,6 +44,12 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
       Error("nick",ERR_ERROR,"Rename from non-existent sender %s",sender);
       return CMD_OK;
     }
+
+    strncpy(oldnick,np->nick,NICKLEN);
+    oldnick[NICKLEN]='\0';
+    harg[0]=(void *)np;
+    harg[1]=(void *)oldnick;
+
     np2=getnickbynick(cargv[0]);
     if (np==np2) {
       /* The new and old nickname have the same hash, this means a rename to the same name in 
@@ -53,7 +62,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
       }
       strncpy(np->nick,cargv[0],NICKLEN);
       np->nick[NICKLEN]='\0';
-      triggerhook(HOOK_NICK_RENAME,np);        
+      triggerhook(HOOK_NICK_RENAME,harg);
       return CMD_OK;
     }
     if (np2!=NULL) {
@@ -84,7 +93,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     strncpy(np->nick,cargv[0],NICKLEN);
     np->nick[NICKLEN]='\0';
     addnicktohash(np);
-    triggerhook(HOOK_NICK_RENAME,np);
+    triggerhook(HOOK_NICK_RENAME,harg);
   } else if (cargc>=8) { /* new nick */
     /* Jupiler 2 1016645147 ~Jupiler www.iglobal.be +ir moo [FUTURE CRAP HERE] DV74O] BNBd7 :Jupiler */
     timestamp=strtol(cargv[2],NULL,10);
@@ -143,6 +152,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     np->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS);
     node_increment_usercount(np->ipnode);
 
+    np->away=NULL;
     np->shident=NULL;
     np->sethost=NULL;
     np->opername=NULL;
@@ -489,7 +499,10 @@ int handlestatsmsg(void *source, int cargc, char **cargv) {
   case 'P':
     irc_send(":%s 217 %s P none 0 :0x2000",fromstring,replytarget);
     break;
-    
+   
+  case 'm':
+    stats_m(fromstring, replytarget);
+    break; 
   }
 
   irc_send(":%s 219 %s %c :End of /STATS report",fromstring,replytarget,cargv[0][0]);
@@ -524,3 +537,22 @@ int handleprivmsg(void *source, int cargc, char **cargv) {
   return CMD_OK;
 }
 
+int handleawaymsg(void *source, int cargc, char **cargv) {
+  nick *sender;
+    
+  /* Check source is a valid user */ 
+  if (!(sender=getnickbynumericstr(source))) {
+    return CMD_OK;
+  }
+
+  /* Done with the old away message either way */
+  freesstring(sender->away);
+  sender->away=NULL;
+  
+  /* If we have an arg and it isn't an empty string, this sets a new message */
+  if (cargc > 0 && *(cargv[0])) {
+    sender->away=getsstring(cargv[0], AWAYLEN);
+  }
+
+  return CMD_OK;
+}