X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FIRC%2FIrc.pl;h=7b962c8ad23e0b9e13c9c1ef6cb2cd54257087ea;hb=69174f9dabbb89bfc95c0bc7aacc5a4ef59d01b7;hp=ced6f28e5ab81b4c5de1c4b1a12f2fd4f9b4cb50;hpb=fe72cf90a57acfd7ebdf9f297e76b6005912e1fe;p=infobot.git diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index ced6f28..7b962c8 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -19,9 +19,6 @@ use vars qw($notcount $nottime $notsize $msgcount $msgtime $msgsize use vars qw($b_blue $ob); use vars qw(@ircServers); -#use open ':utf8'; -#use open ':std'; - $nickserv = 0; # It's probably closer to 510, but let's be cautious until we calculate it extensively. @@ -105,12 +102,13 @@ sub irc { my %args = ( Nick => $param{'ircNick'}, - Server => $server, + Server => $resolve, Port => $port, Ircname => $param{'ircName'}, ); $args{'LocalAddr'} = $param{'ircHost'} if ( $param{'ircHost'} ); $args{'Password'} = $param{'ircPasswd'} if ( $param{'ircPasswd'} ); + $args{'SSL'} = $param{'ircSSL'} if ( $param{'ircSSL'} ); foreach my $mynick ( sort split ',', $param{'ircNick'} ) { if (!defined $conns{$mynick}) { @@ -128,6 +126,14 @@ sub irc { &ERROR('If this is still a problem, please contact the maintainer.'); } if (defined $conns{$mynick}) { + # explicit binmode for socket as "use open" does not seem to work here + #binmode $conns{$mynick}->{_socket}, ":utf8"; + # This will bomb on non-utf8 input + #binmode $conns{$mynick}->{_socket}, ":encoding(UTF-8)"; + # TODO: need to input bytes, but output utf8 + binmode $conns{$mynick}->{_socket}, ":bytes"; + binmode $conns{$mynick}->socket, ":bytes"; + $conns{$mynick}->maxlinelen($maxlinelen); # handler stuff. @@ -151,15 +157,12 @@ sub irc { $conns{$mynick}->add_global_handler( 'nick', \&on_nick ); $conns{$mynick}->add_global_handler( 'quit', \&on_quit ); $conns{$mynick}->add_global_handler( 'notice', \&on_notice ); - $conns{$mynick} - ->add_global_handler( 'whoischannels', \&on_whoischannels ); - $conns{$mynick} - ->add_global_handler( 'useronchannel', \&on_useronchannel ); + $conns{$mynick}->add_global_handler( 'whoischannels', \&on_whoischannels ); + $conns{$mynick}->add_global_handler( 'useronchannel', \&on_useronchannel ); $conns{$mynick}->add_global_handler( 'whois', \&on_whois ); $conns{$mynick}->add_global_handler( 'other', \&on_other ); $conns{$mynick}->add_global_handler( 'disconnect', \&on_disconnect ); - $conns{$mynick} - ->add_global_handler( [ 251, 252, 253, 254, 255 ], \&on_init ); + $conns{$mynick}->add_global_handler( [ 251, 252, 253, 254, 255 ], \&on_init ); # $conns{$mynick}->add_global_handler(302, \&on_init); # userhost $conns{$mynick}->add_global_handler( 303, \&on_ison ); # notify. @@ -738,23 +741,20 @@ sub invite { # Usage: &joinNextChan(); sub joinNextChan { my $joined = 0; - #foreach ( sort keys %conns ) { - #$conn = $conns{$mynick}; - if (defined $conn) { - my $mynick = $conn->nick(); - my @join = getJoinChans(1); - - if ( scalar @join ) { - my $chan = shift @join; - &joinchan($chan); - - if ( my $i = scalar @join ) { - &status("joinNextChan: $mynick $i chans to join."); - } - $joined = 1; + if (defined $conn) { + my $mynick = $conn->nick(); + my @join = getJoinChans(1); + + if ( scalar @join ) { + my $chan = shift @join; + &joinchan($chan); + + if ( my $i = scalar @join ) { + &status("joinNextChan: $mynick $i chans to join."); } + $joined = 1; } - #} + } return if $joined; if ( exists $cache{joinTime} ) { @@ -888,7 +888,8 @@ sub clearChanVars { } sub clearIRCVars { - undef %channels; + # FIXME: only remove channels for current bot! + #undef %channels; undef %floodjoin; $cache{joinTime} = time(); @@ -907,9 +908,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 @@ -932,28 +933,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);