#-------------------Connect to IRC Server------------------- sub connecting { # Connect to the IRC server. $sock = new IO::Socket::INET( PeerAddr => $irc, PeerPort => 6667, Proto => 'tcp', ) or die "Can't connect\n"; print $sock "NICK $nick\r\n"; print $sock "USER $login 8 * :CoCoNUE Member $nick\r\n"; $sel->add($sock); ################################################# #Timeout my $timer_chat = Glib::Timeout->add(1, \&incoming_data); #################################################\ return 1; } #-------------------Watch for IRC Inputs------------------- sub incoming_data { if ($sel->can_read(1)){ my $input = <$sock>; $input =~ s/\r\n//g; my $hashref = $parser->parse( $input ); SWITCH: { my $type = lc $hashref->{command}; my @args; push @args, $hashref->{prefix} if $hashref->{prefix}; push @args, @{ $hashref->{params} }; if ( defined $dispatch{$type} ) { $dispatch{$type}->(@args); last SWITCH; } print STDOUT join( ' ', "irc_$type:", @args ), "\n"; } } return 1; }