#!/usr/bin/perl -w # idlebot.pl - by nick84 # changes by dual # # Bot that idles in IRC # # Usage: nohup perl idlebot.pl & ################################ use IO::Socket; # Set variables $irc_server = 'irc.server.net'; $irc_name = 'nick'; $irc_passwd = 'password'; $irc_channel = '#channel'; # Create a raw socket $sock = IO::Socket::INET->new( PeerAddr => "$irc_server", PeerPort => 6667, Proto => 'tcp') or die "Cannot make connection: $!"; # Set nick while ($line = <$sock>) { print $line; if ( ($line =~ /(NOTICE AUTH).*(checking ident)/i) || ($line =~ /Found your hostname/i) ){ print $sock "NICK $irc_name\nUSER idle 0 0 :not-a-bot\n"; last; } } # Identify to the server while ($line = <$sock>) { print $line; if ($line =~ /^PING/) { print $sock "PONG :" . (split(/ :/, $line))[1]; } if ($line =~ /(376|422)/i) { print $sock "PRIVMSG NickServ :IDENTIFY $irc_passwd\n"; last; } } sleep 3; # Join the channel and stay on print $sock "JOIN $irc_channel\n"; while ($line = <$sock>) { ($command, $text) = split(/ :/, $line); if ($command eq 'PING') { while ( (index($text,"\r") >= 0) || (index($text,"\n") >= 0) ){ chop($text); } print $sock "PONG $text\n"; next; } }