[Perl]Random Quote IRC Bot

Results 1 to 3 of 3
  1. #1
    Account Upgraded | Title Enabled! shadow-xx is offline
    MemberRank
    Jan 2007 Join Date
    MegatonLocation
    804Posts

    [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 :


    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;
        }
    }
    Attached Files Attached Files
    Last edited by shadow-xx; 02-03-09 at 04:08 PM.


  2. #2
    Enthusiast x000x01 is offline
    MemberRank
    Jan 2009 Join Date
    EuropeLocation
    32Posts

    Re: [Perl]Random Quote IRC Bot

    V-Good. Continue learning perl. It's very good and underground language.

  3. #3
    Account Upgraded | Title Enabled! shadow-xx is offline
    MemberRank
    Jan 2007 Join Date
    MegatonLocation
    804Posts

    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..)



Advertisement