]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/authtracker/authtracker_hooks.c
Fix various warnings.
[irc/quakenet/newserv.git] / chanserv / authtracker / authtracker_hooks.c
index 5e48c255546f4cd0d63a922169af6ad86698f8c2..536e1db0f653620cace9739796fcbd9a938914c3 100644 (file)
@@ -4,9 +4,13 @@
 #include "../chanserv.h"
 #include "../../core/hooks.h"
 #include "../../nick/nick.h"
+#include "../../lib/irc_string.h"
 
 #include <time.h>
 #include <string.h>
+#include <stdio.h>
+
+#define NTERFACER_AUTH "nterfacer"
 
 /* OK, we need to deal separately with users who have definitely gone (QUIT
  * or KILL) and those who has mysteriously vanished (lost in netsplit). 
@@ -21,20 +25,20 @@ time_t at_lastauthts;
 unsigned long at_lastuserid;
 
 unsigned long at_getuserid(nick *np) {
-  reguser *rup;
-  
   /* If they are not +r, forget it. */
   if (!IsAccount(np))
     return 0;
+
+  /* Ignore that pesky nterfacer */
+#ifdef NTERFACER_AUTH
+  if (!ircd_strcmp(np->authname, NTERFACER_AUTH))
+    return 0;
+#endif
     
-  /* Try getting it from np->auth */
+  /* Use the userid from authext only. */
   if (np->auth)
     return np->auth->userid;
   
-  /* Else use the chanserv nickext */
-  if ((rup=getreguserfromnick(np)))
-    return rup->ID;
-  
   Error("authtracker",ERR_WARNING,"Unable to get userID from IsAccount() user %s",np->nick);
   return 0;
 }
@@ -44,20 +48,21 @@ void at_handlequitorkill(int hooknum, void *arg) {
   nick *np=args[0];
   char *reason=args[1];
   char *rreason;
+  char resbuf[512];
   unsigned long userid;
   
   /* Ignore unauthed users, or those with no accountts */
   if (!(userid=at_getuserid(np)) || !np->accountts)
     return;
 
-  Error("authtracker",ERR_INFO,"KILL/QUIT: reason = %s",reason);
-  
   at_lastuserid=userid;
   at_lastauthts=np->accountts;
   at_lastnum=np->numeric;
 
-  if (hooknum==HOOK_NICK_KILL && (rreason=strchr(reason,'@')))
-    reason=rreason;
+  if (hooknum==HOOK_NICK_KILL && (rreason=strchr(reason,' '))) {
+    sprintf(resbuf,"Killed%s",rreason);
+    reason=resbuf;
+  }
   
   at_logquit(userid, np->accountts, time(NULL), reason);
 }
@@ -101,7 +106,8 @@ void at_hookinit() {
   registerhook(HOOK_NICK_QUIT, at_handlequitorkill);
   registerhook(HOOK_NICK_KILL, at_handlequitorkill);
   registerhook(HOOK_NICK_LOSTNICK, at_handlelostnick);
-  registerhook(HOOK_CHANSERV_SETUSERID, at_newnick);
+  registerhook(HOOK_NICK_NEWNICK, at_newnick);
+  registerhook(HOOK_NICK_ACCOUNT, at_newnick);
   registerhook(HOOK_SERVER_LINKED, at_serverlinked);
 }
 
@@ -109,6 +115,7 @@ void at_hookfini() {
   deregisterhook(HOOK_NICK_QUIT, at_handlequitorkill);
   deregisterhook(HOOK_NICK_KILL, at_handlequitorkill);
   deregisterhook(HOOK_NICK_LOSTNICK, at_handlelostnick);
-  deregisterhook(HOOK_CHANSERV_SETUSERID, at_newnick);
+  deregisterhook(HOOK_NICK_NEWNICK, at_newnick);
+  deregisterhook(HOOK_NICK_ACCOUNT, at_newnick);
   deregisterhook(HOOK_SERVER_LINKED, at_serverlinked);
 }