]> jfr.im git - irc/quakenet/newserv.git/blobdiff - whowas/whowas.c
Update README.
[irc/quakenet/newserv.git] / whowas / whowas.c
index c2cece6d743f41be19dd10763a06871e9545faf4..5764ecac0bd154b3a9e5da11d1a6741796f77f53 100644 (file)
@@ -16,6 +16,7 @@ whowas *whowas_fromnick(nick *np, int standalone) {
   whowas *ww;
   nick *wnp;
   struct irc_in_addr ipaddress_canonical;
+  void *args[2];
 
   /* Create a new record. */
   if (standalone)
@@ -66,6 +67,10 @@ whowas *whowas_fromnick(nick *np, int standalone) {
   ww->timestamp = getnettime();
   ww->type = WHOWAS_USED;
 
+  args[0] = ww;
+  args[1] = np;
+  triggerhook(HOOK_WHOWAS_NEWRECORD, args);
+
   return ww;
 }
 
@@ -75,6 +80,8 @@ void whowas_clean(whowas *ww) {
   if (!ww || ww->type == WHOWAS_UNUSED)
     return;
 
+  triggerhook(HOOK_WHOWAS_LOSTRECORD, ww);
+
   np = &ww->nick;
   freesstring(np->host->name);
   freehost(np->host);
@@ -184,6 +191,32 @@ const char *whowas_format(whowas *ww) {
   return buf;
 }
 
+const char *whowas_formatchannels(whowas *ww) {
+  static char buf[512];
+  int i, first = 1;
+
+  strcpy(buf, "Channels: ");
+
+  for (i = 0; i < WW_MAXCHANNELS; i++) {
+    if (!ww->channels[i])
+      break;
+
+    if (!first)
+      strncat(buf, ", ", sizeof(buf));
+    else
+      first = 0;
+
+    strncat(buf, ww->channels[i]->name->content, sizeof(buf));
+  }
+
+  if (!ww->channels[0])
+    strncat(buf, "(No channels.)", sizeof(buf));
+
+  buf[sizeof(buf) - 1] = '\0';
+
+  return buf;
+}
+
 unsigned int nextwhowasmarker() {
   whowas *ww;
   int i;
@@ -205,6 +238,8 @@ unsigned int nextwhowasmarker() {
 }
 
 void _init(void) {
+  memset(whowasrecs, 0, sizeof(whowasrecs));
+
   registerhook(HOOK_NICK_QUIT, whowas_handlequitorkill);
   registerhook(HOOK_NICK_KILL, whowas_handlequitorkill);
   registerhook(HOOK_NICK_RENAME, whowas_handlerename);