1 Attachment(s)
[Perl]Random Quote IRC Bot
First try at perl
Took some time to make this
because i never done perl before..
had some troubles with the array's
i automatically used the arrays like
im used to in php
but then i figured out arrays are used
with a @ in perl:P
Console Screen :
http://img129.imageshack.us/img129/4749/pingpong.png
Source :
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;
}
}
Re: [Perl]Random Quote IRC Bot
V-Good. Continue learning perl. It's very good and underground language.
Re: [Perl]Random Quote IRC Bot
Thnx:)
I added a screen but it doesent accept the image tags here for some reason
(probly board settings..)