From d2f87ccd1d5f93afedc8f9f13b9f35260328614a Mon Sep 17 00:00:00 2001 From: timriker Date: Thu, 20 Oct 2011 17:17:11 +0000 Subject: [PATCH] join debugging git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1904 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/IRC/Irc.pl | 19 ++++++++----------- src/IRC/Schedulers.pl | 21 +++++++++++++-------- src/UserExtra.pl | 16 ++++++---------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index 21a31fe..51b35a9 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -905,9 +905,9 @@ sub getJoinChans { # 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 + } else { + # Don't display since < 15min since last + $show = 0; } # can't join any if not connected @@ -930,28 +930,25 @@ sub getJoinChans { $chanconf{$_}{autojoin} = $val; } $skip++ if ( lc $val ne lc $nick ); - } - else { + } else { $skip++; } if ($skip) { push( @skip, $_ ); - } - else { + } else { if ( defined $channels{$_} or exists $channels{$_} ) { push( @in, $_ ); - } - else { + } else { push( @join, $_ ); } } } my $str; - $str .= ' in:' . join( ',', sort @in ) if scalar @in; - $str .= ' skip:' . join( ',', sort @skip ) if scalar @skip; $str .= ' join:' . join( ',', sort @join ) if scalar @join; + $str .= ' in:' . join( ',', sort @in ) if scalar @in; + $str .= ' skip:' . scalar @skip if scalar @skip; &status("Chans: ($nick)$str") if ($show); diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 3c7056f..5c95b67 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -713,22 +713,26 @@ sub ignoreCheck { } sub ircCheck { + my $retval = 0; if (@_) { &ScheduleThis( 300, 'ircCheck' ); # every 5 minutes - return if ( $_[0] eq '2' ); # defer. + return $retval if ( $_[0] eq '2' ); # defer. } $cache{statusSafe} = 1; + # save current connection + my $saveconn = $conn; foreach ( sort keys %conns ) { $conn = $conns{$_}; - next if (!defined $conn); - my $mynick = $conn->nick(); + next if (!defined $myconn); + my $nick = $myconn->nick(); &DEBUG("ircCheck for $_"); # Display with min of 900sec delay between redisplay # FIXME: should only use 900sec when we are on the LAST %conns my @join = &getJoinChans(900); if ( scalar @join ) { - &FIXME( 'ircCheck: found channels to join! ' . join( ',', @join ) ); + &FIXME( 'ircCheck: found ' . scalar @join . 'channels to join! ' . join( ',', @join ) ); + $retval += scalar @join; &joinNextChan(); } @@ -751,6 +755,8 @@ sub ircCheck { } } } + # restore connection we were called from + $conn = $saveconn; if ( grep /^\s*$/, keys %channels ) { &WARN('ircCheck: we have a NULL chan in hash channels? removing!'); @@ -776,17 +782,16 @@ sub ircCheck { $cache{statusSafe} = 0; ### USER FILE. - if ( $utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600 ) - { + if ($utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600) { &writeUserFile(); $wtime_userfile = time(); } ### CHAN FILE. - if ( $utime_chanfile > $wtime_chanfile and time() - $wtime_chanfile > 3600 ) - { + if ($utime_chanfile > $wtime_chanfile and time() - $wtime_chanfile > 3600) { &writeChanFile(); $wtime_chanfile = time(); } + return $retval; } sub miscCheck { diff --git a/src/UserExtra.pl b/src/UserExtra.pl index 5215bb0..fe28e79 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -21,7 +21,6 @@ sub chaninfo { if ( $chan eq '' ) { # all channels. my $i = keys %channels; - my $reply = "I'm on \002$i\002 " . &fixPlural( 'channel', $i ); my $tucount = 0; # total user count. my $uucount = 0; # unique user count. my %chans; @@ -42,7 +41,6 @@ sub chaninfo { foreach $chan ( sort { $chans{$b} <=> $chans{$a} } keys %chans ) { push( @array, "$chan/" . $chans{$chan} ); } - &performStrictReply( $reply . ': ' . join( ', ', @array ) ); ### total user count. foreach $chan ( keys %channels ) { @@ -60,14 +58,12 @@ sub chaninfo { $uucount = scalar( keys %nicks ); my $chans = scalar( keys %channels ); - &performStrictReply( "i've cached \002$tucount\002 " - . &fixPlural( 'user', $tucount ) - . ", \002$uucount\002 unique " - . &fixPlural( 'user', $uucount ) - . ", distributed over \002$chans\002 " - . &fixPlural( 'channel', $chans ) - . '.' ); - &ircCheck(); + my $join = &ircCheck(); + &performStrictReply( + "\002$chans/".($chans+$join)."\002 " . &fixPlural('channel', $chans) + . ", \002$tucount\002 " . &fixPlural('user', $tucount) + . ", \002$uucount\002 unique: " + . join(', ', @array)); return; } -- 2.39.2