All pastes #205209 Raw Edit

Stuff

public text v1 · immutable
#205209 ·published 2006-10-16 17:02 UTC
rendered paste body
#!/usr/bin/perl

use IO::Socket;

my $host = $ARGV[0];   #setting variables needed for bot
my $port = $ARGV[1];
my $nick = $ARGV[2];
my $owner = $ARGV[3];
system("color 02"); # This sets the console window to green text (windows based systems)
print q(
                      [[ Welcome to Baboonbot v1.0! ]]
                      [[ Coded by: Tainted          ]]
                      [[ http://www.peatballs.org   ]]
                      [[ taintedbloop@gmail.com     ]]

       );

print "Arguments: [host: $host] [port: $port] [nick: $nick] [owner: $owner]\n\n"; #confirming arguments to the user



my $sock = new IO::Socket::INET (   # starting a socket connection
                                 PeerAddr => $host, # server
                                 PeerPort => $port, # port
                                 Proto => 'tcp',    # protocol
                                 );
                                 die "Could not open connection to $host\n $1";  # in case it fails to connect


print $sock "NICK $nick\r\n"; # Nickname to send to server
print $sock "USER $nick * 8 :BaboonBot v1.0\r\n"; # User to send to server


sleep(1); # sleep to avoid JOINing too early .. i think its a good idea. sleep(seconds)

print $sock "JOIN #bots\r\n"; # Joins channel #bots

while (my $data = <$sock>) {
       chop $data;

          if ($data =~ /^PING(.*)$/i) { #checks to see if the server sent the word PING, this is necessary to avoid being disconnected

          print $sock "PONG $1\r\n"; # PONG is the reply to PING
          } else {

          print "$data\n";  # print the raw data recieved from the server
         }
         }