From: dms Date: Fri, 13 Apr 2001 16:45:28 +0000 (+0000) Subject: another round of changes, damn it was hard to figure out why news wasn't X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6dcefdabdc90ff77f2fd36ed84f6097d0d2a00ef;p=infobot.git another round of changes, damn it was hard to figure out why news wasn't 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@439 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/blootbot/src/IRC/IrcHelpers.pl b/blootbot/src/IRC/IrcHelpers.pl index c4e4530..6358aea 100644 --- a/blootbot/src/IRC/IrcHelpers.pl +++ b/blootbot/src/IRC/IrcHelpers.pl @@ -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!"); diff --git a/blootbot/src/IRC/IrcHooks.pl b/blootbot/src/IRC/IrcHooks.pl index d217fc5..2b73053 100644 --- a/blootbot/src/IRC/IrcHooks.pl +++ b/blootbot/src/IRC/IrcHooks.pl @@ -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(); ### } diff --git a/blootbot/src/IRC/Schedulers.pl b/blootbot/src/IRC/Schedulers.pl index e3e224c..c63ee26 100644 --- a/blootbot/src/IRC/Schedulers.pl +++ b/blootbot/src/IRC/Schedulers.pl @@ -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); diff --git a/blootbot/src/Modules/News.pl b/blootbot/src/Modules/News.pl index 6a4d30f..fda441d 100644 --- a/blootbot/src/Modules/News.pl +++ b/blootbot/src/Modules/News.pl @@ -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; diff --git a/blootbot/src/core.pl b/blootbot/src/core.pl index 1c7b6d4..20be5c2 100644 --- a/blootbot/src/core.pl +++ b/blootbot/src/core.pl @@ -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; }