]> git.donarmstrong.com Git - infobot.git/commitdiff
* Undo "less verbose" patch from r1153 to properly display Chans: in console logs
authordjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 29 Oct 2007 10:00:02 +0000 (10:00 +0000)
committerdjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 29 Oct 2007 10:00:02 +0000 (10:00 +0000)
* 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

src/IRC/Irc.pl
src/IRC/Schedulers.pl

index 12aa2038c95a8cd2a86696f2fbccab3116b35be9..ae22920b2695262d05e60f2241209a68f3d14829 100644 (file)
@@ -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);
index 2e6bc8f877589260222b2b2595218b3e598c114e..4e9bb9c4bb24ea004a33496d170037584f1993c6 100644 (file)
@@ -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();