- foreach (sort keys %conns) {
- $conn=$conns{$_};
- my $mynick=$conn->nick();
- &DEBUG("ircCheck for $_");
- my @join = &getJoinChans(1);
- if (scalar @join) {
- &FIXME('ircCheck: found channels to join! ' . join(',',@join));
- &joinNextChan();
- }
-
- # TODO: fix on_disconnect()
-
- if (time() - $msgtime > 3600) {
- # TODO: shouldn't we use cache{connect} somewhere?
- if (exists $cache{connect}) {
- &WARN("ircCheck: no msg for 3600 and disco'd! reconnecting!");
- $msgtime = time(); # just in case.
- &ircloop();
- delete $cache{connect};
- } else {
- &status('ircCheck: possible lost in space; checking.'.
- scalar(gmtime) );
- &msg($mynick, 'TEST');
- $cache{connect} = time();
- }
- }
-
- if (grep /^\s*$/, keys %channels) {
- &WARN('ircCheck: we have a NULL chan in hash channels? removing!');
- if (!exists $channels{''}) {
- &DEBUG('ircCheck: this should never happen!');
- }
-
- delete $channels{''};
- }
+ # save current connection
+ my $saveconn = $conn;
+ foreach ( sort keys %conns ) {
+ $conn = $conns{$_};
+ 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 ' . scalar @join . 'channels to join! ' . join( ',', @join ) );
+ $retval += scalar @join;
+ &joinNextChan();
+ }
+
+ # TODO: fix on_disconnect()
+
+ if ( time() - $msgtime > 3600 ) {
+
+ # TODO: shouldn't we use cache{connect} somewhere?
+ if ( exists $cache{connect} ) {
+ &WARN("ircCheck: no msg for 3600 and disco'd! reconnecting!");
+ $msgtime = time(); # just in case.
+ &ircloop();
+ delete $cache{connect};
+ }
+ else {
+ &status( 'ircCheck: possible lost in space; checking.'
+ . scalar(gmtime) );
+ &msg( $mynick, 'TEST' );
+ $cache{connect} = time();
+ }
+ }
+ }
+ # restore connection we were called from
+ $conn = $saveconn;
+
+ if ( grep /^\s*$/, keys %channels ) {
+ &WARN('ircCheck: we have a NULL chan in hash channels? removing!');
+ if ( !exists $channels{''} ) {
+ &DEBUG('ircCheck: this should never happen!');
+ }
+ }
+ if ( $ident !~ /^\Q$param{ircNick}\E$/ ) {
+
+ # this does not work unfortunately.
+ &WARN("ircCheck: ident($ident) != param{ircNick}($param{ircNick}).");
+
+ # this check is misleading... perhaps we should do a notify.
+ if ( !&IsNickInAnyChan( $param{ircNick} ) ) {
+ &DEBUG("$param{ircNick} not in use... changing!");
+ &nick( $param{ircNick} );
+ }
+ else {
+ &WARN("$param{ircNick} is still in use...");
+ }