From: djmcgrath Date: Mon, 29 Oct 2007 10:00:02 +0000 (+0000) Subject: * Undo "less verbose" patch from r1153 to properly display Chans: in console logs X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=eb6c2c4db5e4384a3a16a26a1046e6ea4df8ed75;p=infobot.git * Undo "less verbose" patch from r1153 to properly display Chans: in console logs * Added code to control frequency of displaying Chans: to prevent spam. (Default 900 seconds) git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1597 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index 12aa203..ae22920 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -26,6 +26,9 @@ $nickserv = 0; # It's probably closer to 510, but let's be cautious until we calculate it extensively. my $maxlinelen = 490; +# Keep track of last time we displayed Chans: to avoid spam in logs +my $lastChansTime = 0; + sub ircloop { my $error = 0; my $lastrun = 0; @@ -839,12 +842,21 @@ sub clearIRCVars { } sub getJoinChans { - my($show) = @_; + # $show should contain the min number of seconds between display + # of the Chans: status line. Use 0 to disable + my $show = shift; my @in; my @skip; my @join; + # Display "Chans:" only if more than $show seconds since last display + if (time() - $lastChansTime > $show) { + $lastChansTime = time(); + } else { + $show = 0; # Don't display since < 15min since last + } + # can't join any if not connected return @join if (!$conn); @@ -880,8 +892,8 @@ sub getJoinChans { } my $str; - #$str .= ' in:' . join(',', sort @in) if scalar @in; - #$str .= ' skip:' . join(',', sort @skip) if scalar @skip; + $str .= ' in:' . join(',', sort @in) if scalar @in; + $str .= ' skip:' . join(',', sort @skip) if scalar @skip; $str .= ' join:' . join(',', sort @join) if scalar @join; &status("Chans: ($nick)$str") if ($show); diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 2e6bc8f..4e9bb9c 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -681,7 +681,7 @@ sub ircCheck { $conn=$conns{$_}; my $mynick=$conn->nick(); &DEBUG("ircCheck for $_"); - my @join = &getJoinChans(1); + my @join = &getJoinChans(900); # Display with min of 900sec delay between redisplay if (scalar @join) { &FIXME('ircCheck: found channels to join! ' . join(',',@join)); &joinNextChan();