]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chandump/chandump.c
Merge pull request #1 from meeb/meeb
[irc/quakenet/newserv.git] / chandump / chandump.c
index 1a4a3228f8e840b5052ecfbf5cc82807b74d5366..6f37fd434016009783c9b4289ad6f3df9b2098d0 100644 (file)
@@ -1,22 +1,34 @@
 #include <stdio.h>
+#include <string.h>
 
 #include "../core/schedule.h"
 #include "../channel/channel.h"
+#include "../lib/version.h"
+
+MODULE_VERSION("");
 
 void *dumpsched;
 
 void dodump(void *arg) {
   chanindex *c;
   int i;
+  nick *n;
+  char buf[512];
 
   FILE *fp = fopen("chandump/chandump.txt.1", "w");
   if(!fp)
     return;
 
+  fprintf(fp, "M T %lld\n", (unsigned long long)time(NULL));
+
   for(i=0;i<CHANNELHASHSIZE;i++)
     for(c=chantable[i];c;c=c->next)
       if(c->channel && !IsSecret(c->channel))
-        fprintf(fp, "%s %d%s%s\n", c->name->content, c->channel->users->totalusers, (c->channel->topic&&c->channel->topic->content)?" ":"", (c->channel->topic&&c->channel->topic->content)?c->channel->topic->content:"");
+        fprintf(fp, "C %s %d%s%s\n", c->name->content, c->channel->users->totalusers, (c->channel->topic&&c->channel->topic->content)?" ":"", (c->channel->topic&&c->channel->topic->content)?c->channel->topic->content:"");
+
+  for(i=0;i<NICKHASHSIZE;i++)
+    for(n=nicktable[i];n;n=n->next)
+      fprintf(fp, "N %s %s %s %s %s\n", n->nick, n->ident, strchr(visibleuserhost(n, buf), '@') + 1, (IsAccount(n) && n->authname) ? n->authname : "0", n->realname->name->content);
 
   fclose(fp);
 
@@ -24,7 +36,7 @@ void dodump(void *arg) {
 } 
 
 void _init() {
-  dumpsched = (void *)schedulerecurring(time(NULL), 0, 300, &dodump, NULL);
+  dumpsched = (void *)schedulerecurring(time(NULL), 0, 60, &dodump, NULL);
 }
 
 void _fini() {