]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-age.c
LUA: add function for channel chanop notice
[irc/quakenet/newserv.git] / newsearch / ns-age.c
index 6e764b04b217a39f41bcffb20c9f99c23871ab12..9b318371a769fdaf5d11c5110889f7c28e78fd5a 100644 (file)
@@ -2,6 +2,7 @@
  * age functionality
  */
 
+#include "../irc/irc.h"
 #include "newsearch.h"
 
 #include <stdio.h>
@@ -28,9 +29,17 @@ struct searchNode *age_parse(searchCtx *ctx, int argc, char **argv) {
 
 void *age_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
-  whowas *ww = (whowas *)np->next;
+  whowas *ww;
+  time_t ts;
+
+  if (ctx->searchcmd == reg_nicksearch)
+    ts = np->timestamp;
+  else {
+    ww = (whowas *)np->next;
+    ts = ww->timestamp;
+  }
 
-  return (void *)(getnettime() - ww->timestamp);
+  return (void *)(getnettime() - ts);
 }
 
 void age_free(searchCtx *ctx, struct searchNode *thenode) {