]> git.donarmstrong.com Git - infobot.git/commitdiff
another round of changes, damn it was hard to figure out why news wasn't
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 13 Apr 2001 16:45:28 +0000 (16:45 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 13 Apr 2001 16:45:28 +0000 (16:45 +0000)
appearing properly - I think we still have that problem but it's semi
rare.
- Also fixed netsplit problems, forgot a next line.
- don't run all funky commands in on_join if netsplit is enabled.
- other tiny things not worth mentioning.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@439 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/IrcHelpers.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Modules/News.pl
src/core.pl

index c4e4530535f976193be07ef202227cc2a228c05e..6358aeafa4cbe780211e4d723699a1a2ac93922d 100644 (file)
@@ -258,10 +258,9 @@ sub chanLimitVerify {
     if (defined $l and &IsChanConf("chanlimitcheck")) {
        my $plus  = &getChanConfDefault("chanlimitcheckPlus", 5, $chan);
        my $count = scalar(keys %{ $channels{$chan}{''} });
-       &DEBUG("plus = $plus, count = $count");
-       my $delta       = $count + $plus - $l;
-       $delta          =~ s/^\-//;
-       &DEBUG("    delta => $delta");
+
+       my $delta = $count + $plus - $l;
+       $delta    =~ s/^\-//;
 
        if ($plus <= 3) {
            &WARN("clc: stupid to have plus at $plus, fix it!");
index d217fc5cfcd85549c841b17996e573e01057b9a2..2b73053ea96a19038f1a0567f0a243cc8e0edcae 100644 (file)
@@ -408,6 +408,8 @@ sub on_join {
     my ($user,$host) = split(/\@/, $event->userhost);
     $chan      = lc( ($event->to)[0] );        # CASING!!!!
     $who       = $event->nick();
+# doesn't work properly, for news :(
+#    $msgType  = "private";    # for &IsChanConf().
 
     $chanstats{$chan}{'Join'}++;
     $userstats{lc $who}{'Join'} = time() if (&IsChanConf("seenStats"));
@@ -474,6 +476,9 @@ sub on_join {
        last;
     }
 
+    # no need to go further.
+    return if ($netsplit);
+
     ### ROOTWARN:
     &rootWarn($who,$user,$host,$chan)
                if (&IsChanConf("rootWarn") &&
@@ -481,9 +486,14 @@ sub on_join {
                    $channels{$chan}{'o'}{$ident});
 
     ### NEWS:
+    # why isn't this "enabled" just as someone joins?
+
     if (&IsChanConf("news") && &IsChanConf("newsKeepRead")) {
-       # todo: what if it hasn't been loaded?
-       &News::latest($chan);
+       if (!&loadMyModule("news")) {   # just in case.
+           &DEBUG("could not load news.");
+       } else {
+           &News::latest($chan);
+       }
     }
 
     ### chanlimit check.
@@ -819,7 +829,7 @@ sub on_targettoofast {
 ###    .* wait (\d+) second/) {
        &status("on_ttf: X1 $msg") if (defined $msg);
        my $sleep = 5;
-       &status("going to sleep for $sleep...");
+       &status("targettoofast: going to sleep for $sleep...");
        sleep $sleep;
        &joinNextChan();
 ### }
index e3e224c8b97ebbfceb0c011a4451124e2a91bc27..c63ee2693cb25dcd45c87be91a946bce7417c163 100644 (file)
@@ -31,7 +31,7 @@ sub setupSchedulers {
     &seenFlushOld(2);
     &ircCheck(1);      # mandatory
     &miscCheck(1);     # mandatory
-    &miscCheck2(1);    # mandatory
+    &miscCheck2(2);    # mandatory
     &shmFlush(1);      # mandatory
     &slashdotLoop(2);
     &freshmeatLoop(2);
@@ -407,6 +407,7 @@ sub netsplitCheck {
        if (&IsNickInAnyChan($_)) {
            &DEBUG("netsplitC: $_ is in some chan; removing from netsplit list.");
            delete $netsplit{$_};
+           next;
        }
        next unless (time() - $netsplit{$_} > 60*10);
 
index 6a4d30f0d591a60d64f11493d531250d8a624cc1..fda441d8281108761fa1a8c672a72c1b8cf35e07 100644 (file)
@@ -52,8 +52,9 @@ sub Parse {
            return;
        }
 
-       $chan = $chans[0];
+       $chan   = $chans[0];
        &::DEBUG("Guessed $::who being on chan $chan");
+       $::chan = $chan;        # hack for IsChanConf().
     }
 
     if (!defined $what or $what =~ /^\s*$/) {
@@ -81,7 +82,6 @@ sub Parse {
        &read($2);
 
     } elsif ($what =~ /^(latest|new)(\s+(.*))?$/i) {
-       &::DEBUG("latest called... hrm");
        &latest($3 || $chan, 1);
 
     } elsif ($what =~ /^list$/i) {
@@ -660,13 +660,19 @@ sub latest {
        return;
     }
 
+    if (&::IsChanConf("newsNotifyAll") and !defined $t) {
+#      $::newsuser{$chan}{$::who} = 1;
+       $t = 1;
+    }
+
+    if (!defined $t) {
+       &::DEBUG("something went really wrong.");
+       &::msg($::who, "something went really wrong.");
+       return;
+    }
+
     my @new;
     foreach (keys %{ $::news{$chan} }) {
-       if (&::IsChanConf("newsNotifyAll") and !defined $t) {
-           &::DEBUG("setting time for $::who to 1...");
-           $::newsuser{$chan}{$::who} = 1;
-           $t = 1;
-       }
        next if (!defined $t);
        next if ($t > $::news{$chan}{$_}{Time});
 
@@ -692,14 +698,24 @@ sub latest {
        &::msg($::who, "+==== New news for \002$chan\002 (".
                scalar(@new)." new items):");
 
-       my $timestr = &::Time2String( time() - $::newsuser{$chan}{$::who} );
-       &::msg($::who, "|= Last time read $timestr ago");
+       if ($::newsuser{$chan}{$::who}) {
+           my $timestr = &::Time2String( time() - $::newsuser{$chan}{$::who} );
+           &::msg($::who, "|= Last time read $timestr ago");
+       }
 
+       my @sorted;
        foreach (@new) {
            my $i   = &newsS2N($_);
-           my $age = time() - $::news{$chan}{$_}{Time};
+           $sorted[$i] = $_;
+       }
+
+       for (my $i=0; $i<=scalar(@sorted); $i++) {
+           my $news = $sorted[$i];
+           next unless (defined $news);
+
+           my $age = time() - $::news{$chan}{$news}{Time};
            &::msg($::who, sprintf("\002[\002%2d\002]\002 %s",
-               $i, $_) );
+               $i, $news) );
 #              $i, $_, &::Time2String($age) ) );
        }
 
@@ -735,6 +751,7 @@ sub getNewsAll {
 
 sub newsS2N {
     my($what)  = @_;
+    my $item   = 0;
     my @items;
     my $no;
 
index 1c7b6d4ce63e62b5b255901fdb3263ad066cda9b..20be5c22e15c56c57f81af830237c0e4a57f7c37 100644 (file)
@@ -184,15 +184,32 @@ sub IsChanConf {
     ### TODO: VERBOSITY on how chanconf returned 1 or 0 or -1.
     my %chan   = &getChanConfList($param);
     if (!defined $msgType) {
+#      &DEBUG("icc: !def msgType...");
        return $chan{_default} || 0;
     }
 
     if ($msgType eq "public") {
+       if ($chan{lc $chan}) {
+#          &DEBUG("iCC: public: $chan/$param");
+       } elsif ($chan{_default}) {
+#          &DEBUG("iCC: public: _default/$param")
+       } else {
+#          &DEBUG("iCC: public: 0/$param");
+       }
+
        return $chan{lc $chan} || $chan{_default} || 0;
     }
 
     if ($msgType eq "private") {
-       return $chan{_default} || 0;
+       if ($chan{_default}) {
+#          &DEBUG("iCC: private: _default/$param");
+       } elsif ($chan{lc $chan}) {
+#          &DEBUG("iCC: private: $chan/$param");
+       } else {
+#          &DEBUG("iCC: private: 0/$param");
+       }
+
+       return $chan{lc $chan} || $chan{_default} || 0;
     }
 
 ### debug purposes only.
@@ -201,6 +218,8 @@ sub IsChanConf {
 #      &DEBUG("   $_ => $chan{$_}");
 #    }
 
+    &DEBUG("icc: returning 0...");
+
     return 0;
 }