Showing posts with label A very simple IRC Bot (modify source and add your commands) :. Show all posts
Showing posts with label A very simple IRC Bot (modify source and add your commands) :. Show all posts

Thursday, November 6, 2008

A very simple IRC Bot (modify source and add your commands) :

A very simple IRC Bot (modify source and add your commands) :


CODE
#!/usr/bin/perl -w

use IO::Socket;

my $server = $ARGV[1];

my $user = 'simplebot simpleb simpleot plotsim';

my $botnick = $ARGV[0];

my $nickservpass = $ARGV[2];

if(@ARGV < 2) {

print STDOUT "Usage: $0 [nick] [server] [nickserv pass] -- if nickname is not registered , leave it blank.n";

exit; }

$con = IO::Socket::INET->new(PeerAddr=>$server,

PeerPort=>'6667', # change this if needed..

Proto=>'tcp',

Timeout=>'30') || print "Error: Connectionn";



print $con "USER $userrn";

print $con "NICK $botnickrn";

if(@ARGV == 3) {

print $con "privmsg nickserv IDENTIFY $nickservpassrn"; } # if $ARGV[2] exists..

print $con "JOIN #channelrn"; # modify that ..



while($answer = <$con>) {



# #

# add code here #

# #



if($answer =~ m/^PING (.*?)$/gi) {

print $con "PONG ".$1."n"; # replying to pings..

}



print STDOUT $answer; # printing $answer to the terminal..

}