]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/Schedulers.pl
ws
[infobot.git] / src / IRC / Schedulers.pl
index 3172e0b1a180fe5d57da14581acb9cf4ddd7640d..bf254ba6c6d46f85b2d92a68a8678df98bde668b 100644 (file)
@@ -60,7 +60,6 @@ sub setupSchedulers {
     &uptimeLoop(1);
     &randomQuote(2);
     &randomFactoid(2);
-    &randomFreshmeat(2);
     &logLoop(1);
     &chanlimitCheck(1);
     &netsplitCheck(1); # mandatory
@@ -75,7 +74,6 @@ sub setupSchedulers {
     &shmFlush(1);      # mandatory
     &slashdotLoop(2);
     &plugLoop(2);
-    &freshmeatLoop(2);
     &kernelLoop(2);
     &wingateWriteFile(2);
     &factoidCheck(2);  # takes a couple of seconds on a 486. defer it
@@ -178,29 +176,6 @@ sub randomFactoid {
     }
 }
 
-sub randomFreshmeat {
-    my $interval = &getChanConfDefault("randomFreshmeatInterval", 60);
-
-    if (@_) {
-       &ScheduleThis($interval, "randomFreshmeat");
-       return if ($_[0] eq "2");       # defer.
-    }
-
-    my @chans = &ChanConfList("randomFreshmeat");
-    return unless (scalar @chans);
-
-    &Forker("freshmeat", sub {
-       my $retval = &Freshmeat::randPackage();
-
-       foreach (@chans) {
-           next unless (&validChan($_));
-
-           &status("sending random Freshmeat to $_.");
-           &say($_, $line);
-       }
-    } );
-}
-
 sub logLoop {
     if (@_) {
        &ScheduleThis(60, "logLoop");
@@ -424,7 +399,7 @@ sub chanlimitCheck {
        }
 
        if (defined $limit and scalar keys %{ $channels{$chan}{''} } > $limit) {
-           &FIXME("LIMIT: set too low!!! FIXME");
+           &FIXME("LIMIT: set too low!!!");
            ### run NAMES again and flush it.
        }
 
@@ -442,7 +417,7 @@ sub chanlimitCheck {
        delete $cache{warn}{chanlimit}{$chan};
 
        if (!defined $limit) {
-           &status("chanlimit: setting for first time or from netsplit, for $chan");
+           &status("chanlimit: $chan: setting for first time or from netsplit.");
        }
 
        if (exists $cache{chanlimitChange}{$chan}) {
@@ -703,14 +678,14 @@ sub ircCheck {
     my $iconf  = scalar( @x );
     my $inow   = scalar( keys %channels );
     if ($iconf > 2 and $inow * 2 <= $iconf) {
-       &FIXME("ircCheck: current channels * 2 <= config channels. FIXME.");
-       &FIXME("ircCheck: iconf = $iconf");
-       &FIXME("ircCheck: inow  = $inow");
+       &FIXME("ircCheck: current channels ($inow) * 2 <= config channels ($iconf).");
 #      @joinchan       = @x;
        &joinNextChan();
     }
 
-    if (!$conn->connected or time() - $msgtime > 3600) {
+    # todo: fix on_disconnect()
+
+    if (time() - $msgtime > 3600) {
        # todo: shouldn't we use cache{connect} somewhere?
        if (exists $cache{connect}) {
            &WARN("ircCheck: no msg for 3600 and disco'd! reconnecting!");
@@ -786,13 +761,18 @@ sub miscCheck {
        my ($shmid, $size) = ($2,$5);
        next unless ($shmid != $shm and $size == 2000);
        my $z   = &shmRead($shmid);
-       if ($z =~ /^(\d+): /) {
-           my $time    = $1;
+       if ($z =~ /^(\S+):(\d+):(\d+): /) {
+           my $n       = $1;
+           my $pid     = $2;
+           my $time    = $3;
            next if (time() - $time < 60*60);
-
+           # FIXME remove not-pid shm if parent process dead
+           next if ($pid == $bot_pid);
+           # don't touch other bots, if they're running.
+           next unless ($param{ircNick} =~ /^\Q$n\E$/);
        } else {
-#          &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
-#          next;
+           &DEBUG("shm: $shmid is not ours or old blootbot => ($z)");
+           next;
        }
 
        &status("SHM: nuking shmid $shmid");
@@ -926,27 +906,6 @@ sub plugLoop {
     } );
 }
 
-sub freshmeatLoop {
-    if (@_) {
-       &ScheduleThis(60, "freshmeatLoop");
-       return if ($_[0] eq "2");
-    }
-
-    my @chans = &ChanConfList("freshmeatAnnounce");
-    return unless (scalar @chans);
-
-    &Forker("freshmeat", sub {
-       my $data = &Freshmeat::freshmeatAnnounce();
-
-       foreach (@chans) {
-           next unless (&::validChan($_));
-
-           &::status("sending freshmeat update to $_.");
-           &msg($_, $data);
-       }
-    } );
-}
-
 sub kernelLoop {
     if (@_) {
        &ScheduleThis(240, "kernelLoop");
@@ -1053,7 +1012,7 @@ sub factoidCheck {
     my $time   = time();
 
     foreach (@list) {
-       my $age = &getFactInfo($_, "modified_time");    
+       my $age = &getFactInfo($_, "modified_time");
 
        if (!defined $age or $age !~ /^\d+$/) {
            if (scalar @list > 50) {