]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nick/nickhandlers.c
NICK: Add "away" functionality.
[irc/quakenet/newserv.git] / nick / nickhandlers.c
index 62ef2b801d7d407f943b66b9232dd73497096c82..282139f3070696df4583b82346e34c13b8a08265 100644 (file)
@@ -13,6 +13,7 @@
 #include "../parser/parser.h"
 #include <stdlib.h>
 #include <string.h>
+#include <stdint.h>
 
 /*
  * handlenickmsg:
@@ -46,8 +47,8 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
        * different case, e.g. Flash -> flash.  In this case the timestamp for the change should
        * match the existing timestamp, and we can bypass all the collision checking and hash fettling. */
       if (np->timestamp!=timestamp) {
-        Error("nick",ERR_WARNING,"Rename to same nickname with different timestamp (%s(%d) -> %s(%d))",
-                            np->nick,np->timestamp,cargv[0],timestamp);
+        Error("nick",ERR_WARNING,"Rename to same nickname with different timestamp (%s(%jd) -> %s(%jd))",
+                            np->nick,(intmax_t)np->timestamp,cargv[0], (intmax_t)timestamp);
         np->timestamp=timestamp;
       }
       strncpy(np->nick,cargv[0],NICKLEN);
@@ -142,6 +143,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;
@@ -388,7 +390,7 @@ int handleaccountmsg(void *source, int cargc, char **cargv) {
   nick *target;
   unsigned long userid;
   time_t accountts;
-  u_int64_t accountflags, oldflags;
+  u_int64_t accountflags=0, oldflags;
 
   if (cargc<4) {
     return CMD_OK;
@@ -488,7 +490,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]);
@@ -523,3 +528,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;
+}