]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/authtracker/authtracker_hooks.c
Don't log kill paths when a user is killed.
[irc/quakenet/newserv.git] / chanserv / authtracker / authtracker_hooks.c
index 7ffc308c54ea6a3ba62e9912928fbf0a3cbc87b5..2b9ffc7dd1b636115b9311d383c5a94e334eeeeb 100644 (file)
@@ -4,10 +4,13 @@
 #include "../chanserv.h"
 #include "../../core/hooks.h"
 #include "../../nick/nick.h"
+#include "../../lib/irc_string.h"
 
 #include <time.h>
 #include <string.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). 
  * There are hooks for all these things, but sadly QUIT and KILL also
@@ -21,20 +24,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,6 +47,7 @@ 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 */
@@ -54,8 +58,10 @@ void at_handlequitorkill(int hooknum, void *arg) {
   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);
 }
@@ -99,7 +105,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);
 }
 
@@ -107,6 +114,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);
 }