#!/usr/bin/perl use IO::Socket; $curchan = "#ipi"; $chanpass = ""; $curnick = "JJ[idle]"; $curname = "JJ JJ JJ :JJ's idlebot"; $i = 0; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "goldorak", PeerPort => "6667", ); unless ($remote) { die "cannot connect to ircd on $host" } $remote->autoflush(1); print $remote "nick :$curnick\n"; print $remote "user $curname\n"; while($line = <$remote>) { my @tab = split(" ", $line); if($tab[1] eq "376") { print $remote "join $curchan $chanpass\n"; while ($line = <$remote>) { @tab = split(" ", $line); if($tab[1] eq "PRIVMSG") { $_ = $tab[3]; s/://; my $cmd = $_; #FONCTION ctcp version if ($cmd eq "\001VERSION\001") { $_ = $tab[0]; s/:(.*)!.*/\1/; #on isole le nick de l'auteur print $remote "NOTICE $_ :\001VERSION jj's idlebot 0.01\001\n"; } if ($tab[2] !~ /^#/) { # privmsg perso $_ = $tab[0]; s/\@.*$//; my $sender = $_; shift; shift; shift; print "<".$sender."> ".@tab; } } if($tab[0] eq "PING") { print $remote "PONG $tab[1]\n"; } } } } close $remote;