]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanstats/chanstats.c
A4STATS: remove E style escapes and switch to createtable for indices
[irc/quakenet/newserv.git] / chanstats / chanstats.c
index 130191358c5944a5bb357cc93ca67d221ac4a781..b6c6402a93b1830451c09ff7c9337a3e3af12b60 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdint.h>
 
 MODULE_VERSION("");
 
@@ -42,6 +43,8 @@ void dohist_today(int *data, float *bounds, int cats);
 void dohist_days(int *data, float *bounds, int cats, int days);
 void dohist_namelen(int *data, float *bounds, int cats);
 
+#define EXPIREMIN 4
+
 void _init() {
   time_t now,when;
 
@@ -51,7 +54,6 @@ void _init() {
     Error("chanstats",ERR_ERROR,"Couldn't register channel extension");
     failedinit=1;
   } else {  
-    initchanstatsalloc();
     lastday=(getnettime()/(24*3600));
     uponehour=0;
     sampleindex=-1;
@@ -64,7 +66,7 @@ void _init() {
     /* Work out when to take the next sample */
     now=getnettime();
     if (now < chanstats_lastsample) {
-      Error("chanstats",ERR_WARNING,"Last sample time in future (%zu > %zu)",chanstats_lastsample,now);
+      Error("chanstats",ERR_WARNING,"Last sample time in future (%jd > %jd)",(intmax_t)chanstats_lastsample,(intmax_t)now);
       when=now;
     } else if (now<(chanstats_lastsample+SAMPLEINTERVAL)) {
       lastday=chanstats_lastsample/(24*3600);
@@ -77,10 +79,10 @@ void _init() {
     }
     
     lastsave=now;
-    registercontrolcmd("chanstats",10,1,&dochanstats);
-    registercontrolcmd("channelhistogram",10,13,&dochanhistogram);
-    registercontrolcmd("userhistogram",10,1,&douserhistogram);
-    registercontrolcmd("expirecheck",10,1,&doexpirecheck);
+    registercontrolhelpcmd("chanstats",NO_OPER,1,&dochanstats, "Show usage statistics for a channel");
+    registercontrolhelpcmd("channelhistogram",NO_OPER,13,&dochanhistogram, "Display a histogram of network channel sizes");
+    registercontrolhelpcmd("userhistogram",NO_OPER,1,&douserhistogram, "Display a user histogram of channel size");
+    registercontrolhelpcmd("expirecheck",NO_DEVELOPER,1,&doexpirecheck, "Check if channel has too few users for services");
     registercontrolhelpcmd("chanstatssave",NO_DEVELOPER,1, &dochanstatssave, "Usage: chanstatssave\nForce a save of chanstats data");
     schedulerecurring(when,0,SAMPLEINTERVAL,&doupdate,NULL);  
   }
@@ -424,8 +426,6 @@ int dochanstats(void *source, int cargc, char **cargv) {
   return CMD_OK;
 }
 
-#define EXPIREMIN 4
-
 int doexpirecheck(void *source, int cargc, char **cargv) {
   nick *sender=(nick *)source;
   chanindex *cip;
@@ -453,12 +453,14 @@ int doexpirecheck(void *source, int cargc, char **cargv) {
  
   /* Did they hit the minimum today? */
   if (csp->todaymax >= EXPIREMIN) {
+    controlreply(sender,"OK %s",cargv[0]);
     return CMD_OK;
   }
   
   /* Or recently? */
   for (i=0;i<HISTORYDAYS;i++) {
     if (csp->lastmax[i] >= EXPIREMIN) {
+      controlreply(sender,"OK %s",cargv[0]);
       return CMD_OK;
     }
   }