]> jfr.im git - irc/quakenet/newserv.git/blobdiff - qabot/qabot.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / qabot / qabot.c
index 3134ebffbe1f74a78b662e2f8796b78cb54b8799..0f26afca1f304925a757e2aeadfc041c541b4a42 100644 (file)
 #include "../lib/base64.h"
 #include "../lib/irc_string.h"
 #include "../lib/splitline.h"
+#include "../lib/version.h"
 
 #include "qabot.h"
 
+MODULE_VERSION("");
+
 time_t qab_startime;
 int qabot_nickext;
 int qabot_spam_nickext;
@@ -66,6 +69,12 @@ void _init() {
   addcommandtotree(qabot_chancommands, "spam", QAC_QUESTIONCHAN|QAC_STAFFCHAN, 30, qabot_dochanspam);
   addcommandtotree(qabot_chancommands, "status", QAC_QUESTIONCHAN|QAC_STAFFCHAN, 0, qabot_dochanstatus);
   addcommandtotree(qabot_chancommands, "unblock", QAC_QUESTIONCHAN|QAC_STAFFCHAN, 2, qabot_dochanunblock);
+  addcommandtotree(qabot_chancommands, "record", QAC_STAFFCHAN, 1, qabot_dochanrecord);
+  addcommandtotree(qabot_chancommands, "play", QAC_STAFFCHAN, 1, qabot_dochanplay);
+  addcommandtotree(qabot_chancommands, "continue", QAC_STAFFCHAN, 0, qabot_dochancontinue);
+  addcommandtotree(qabot_chancommands, "stop", QAC_STAFFCHAN, 0, qabot_dochanstop);
+  addcommandtotree(qabot_chancommands, "delete", QAC_STAFFCHAN, 1, qabot_dochandelete);
+  addcommandtotree(qabot_chancommands, "list", QAC_STAFFCHAN, 0, qabot_dochanlist);
 
   if ((qabot_nickext = registernickext("QABOT")) == -1) {
     return;
@@ -138,6 +147,12 @@ void _fini() {
   deletecommandfromtree(qabot_chancommands, "spam", qabot_dochanspam);
   deletecommandfromtree(qabot_chancommands, "status", qabot_dochanstatus);
   deletecommandfromtree(qabot_chancommands, "unblock", qabot_dochanunblock);
+  deletecommandfromtree(qabot_chancommands, "record", qabot_dochanrecord);
+  deletecommandfromtree(qabot_chancommands, "play", qabot_dochanplay);
+  deletecommandfromtree(qabot_chancommands, "continue", qabot_dochancontinue);
+  deletecommandfromtree(qabot_chancommands, "stop", qabot_dochanstop);
+  deletecommandfromtree(qabot_chancommands, "delete", qabot_dochandelete);
+  deletecommandfromtree(qabot_chancommands, "list", qabot_dochanlist);
   destroycommandtree(qabot_chancommands);
 }
 
@@ -158,6 +173,17 @@ void qabot_lostnick(int hooknum, void* arg) {
       if (!b->lastspam)
         qabot_spamstored((void*)b);
     }
+    
+    if (b->recnumeric == np->numeric) {
+      b->recnumeric = 0;
+      
+      if (b->recfile) {
+        fclose(b->recfile);
+        b->recfile = NULL;
+      }
+      
+      sendmessagetochannel(b->np, b->staff_chan->channel, "Recorder deactivated.");
+    }
   }
 }
 
@@ -179,6 +205,17 @@ void qabot_channel_part(int hooknum, void* arg) {
       if (!b->lastspam)
         qabot_spamstored((void*)b);
     }
+    
+    if (b->recnumeric == np->numeric) {
+      b->recnumeric = 0;
+      
+      if (b->recfile) {
+        fclose(b->recfile);
+        b->recfile = NULL;
+      }
+      
+      sendmessagetochannel(b->np, b->staff_chan->channel, "Recorder deactivated.");
+    }
   }
 }
 
@@ -352,6 +389,11 @@ void qabot_child_handler(nick* me, int type, void** args) {
         }
       }
     }
+    else if ((*text != '!') && (bot->recnumeric == sender->numeric) && (cp->index == bot->staff_chan)) {
+      if (bot->recfile) {
+        fprintf(bot->recfile, "%s\n", text);
+      }
+    }
     break;
   
   case LU_PRIVMSG:
@@ -409,7 +451,7 @@ void qabot_child_handler(nick* me, int type, void** args) {
       }
       
       if (bot->flags & QAB_FLOODDETECT) {
-        crc = crc32i(text);
+        crc = irc_crc32i(text);
         if (crc == qab_lastq_crc) {
           qab_lastq_count++;
           if (qab_lastq_count >= 3) {