]> jfr.im git - irc/quakenet/newserv.git/blobdiff - patrol/patrol_commands.c
TRUSTS: use correct socket opt...
[irc/quakenet/newserv.git] / patrol / patrol_commands.c
index 262734941a6be84e8739a9e3f9557fd093ae5599..d4cd6a5f80f3abb1b08f3cff29c6d8f9aa11e66e 100644 (file)
@@ -17,7 +17,16 @@ typedef struct patrolchannel {
 static patrolchannel *patrolchannels;
 
 static void patroluserhandler(nick *np, int event, void **args) {
-  /* Nothing to do here. */
+  patrolchannel *pc;
+
+  if (event == LU_KILLED) {
+    for (pc = patrolchannels; pc; pc = pc->next) {
+      if (pc->nick == np) {
+        pc->nick = NULL;
+        break;
+      }
+    }
+  }
 }
 
 static void pc_check(void) {
@@ -25,10 +34,7 @@ static void pc_check(void) {
   channel *cp;
 
   for (pc = patrolchannels; pc; pc = pc->next) {
-    if (pc->nick)
-      patrol_nickchange(pc->nick);
-
-    if (pc->nick && pc->nick->channels && pc->nick->channels->cursi > 0)
+    if (pc->nick && pc->nick->timestamp > getnettime() - 900)
       continue;
 
     if (pc->nick)
@@ -84,7 +90,9 @@ static int pc_part(char *name) {
 
     if (ircd_strcmp(pc->channel->content, name) == 0) {
       freesstring(pc->channel);
-      deregisterlocaluser(pc->nick, NULL);
+
+      if (pc->nick)
+        deregisterlocaluser(pc->nick, NULL);
 
       *pnext = pc->next;
       free(pc);
@@ -147,7 +155,7 @@ void _init(void) {
   registercontrolhelpcmd("patrolpart", NO_OPER, 1, &pc_cmd_patrolpart, "Usage: patrolpart <#id>\nRemoves a patrol client from a channel.");
   registercontrolhelpcmd("patrollist", NO_OPER, 0, &pc_cmd_patrollist, "Usage: patrollist\nLists patrol channels.");
 
-  schedulerecurring(time(NULL) + 5, 0, 300, &pc_sched_check, NULL);
+  schedulerecurring(time(NULL) + 5, 0, 10, &pc_sched_check, NULL);
 }
 
 void _fini(void) {