Code:
#--------------------------------------#
# Perl Random quote IRC Bot #
# Made by shadow-xx #
#--------------------------------------#
# Read a random quote from text file #
# each time somone talks #
#--------------------------------------#
#!/usr/bin/perl
use IO::Socket;
# Settings
$host = 'irc.ragezone.com'; # IRC Server Addres
$port = 6667; # IRC Server Port
$chan = '#SXX_Bot'; # IRC Channel
$nick = 'SXX-QB0T'; # Bot Name
$file = 'quote.txt'; # Quote File
#-----------------------------
$con = IO::Socket::INET->new(
PeerAddr=>$host,
PeerPort=>$port,
Proto=>'tcp',
Timeout=>'30') or die "connection error\r\n";
print $con 'USER '.$nick.' 0 0 :SXX-QBot'."\r\n";
print $con 'NICK '.$nick."\r\n";
print $con 'JOIN '.$chan."\r\n";
open (FILE,$file);
@lines = <FILE>;
$arraysize = scalar(@lines);
while($response = <$con>) {
if($response =~ m/^PING/) {
@reciever = split(/PING :/,$response);
print $con 'PONG :'.$reciever[1]."\r\n";
print $response;
print 'PONG :'.$reciever[1];
}
if($response =~ m/PRIVMSG/) {
@message = split(/:/,$response);
@name = split(/!/,$message[1]);
print 'MSG : '.$name[0].' > '.$message[2];
$line = $lines[rand($arraysize)];
print $con 'PRIVMSG '.$chan.' :'.$line;
print 'BOT OUT > '.$line;
}
}