Perl AIM bot not working correctly...

Discussion in 'Programming' started by DemoIXI, Dec 18, 2006.

  1. #1
    The problem that I keep running into is that when I run this file to load the aim bot, the file just continues to load. I understand that it has something to do with the "while(1)" loop, but I'm not sure how to fix it. Here's my code below.
    
    #!/usr/bin/perl
    
    use warnings;
    use strict;
    use Net::OSCAR qw(:standard);
    
    # Config
    my $screenname = '';
    my $password   = '';
    
    my $oscar;
    $oscar = Net::OSCAR->new();
    $oscar->set_callback_im_in(&im_in);
    $oscar->signon($screenname, $password);
    
    while(1)
    {
        $oscar->do_one_loop();
    }
    
    sub im_in {
        my($oscar, $sender, $message, $is_away) = @_;
        # Some AIM clients send HTML, we need
        # to convert it to plain text
        $message =~ s/<(.|n)+?>//g;
        
        $oscar->send_im($sender, "Hello");
        sleep(1);
        if ($message eq "signoff[code]") {
            sleep(1);
            $oscar->send_im($sender, "Signing Off...");
            sleep(1);
            $oscar->signoff();
        } else {
            sleep(1);
            $oscar->send_im($sender, "Hmm...");
        }
    }
    PHP:
    Thanks for the help in advanced.
     
    DemoIXI, Dec 18, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    I don't think it needs fixing, the loop will never stop and so it will always load :S

    Syntax of any loop

    while(condition is true)
    {

    }

    1 is true .....

    i'm not perl expert at all, but I'm not wrong about the loop thing, if you have copied and example it's doing exactly what it's supposed to
     
    krakjoe, Dec 18, 2006 IP
  3. DemoIXI

    DemoIXI Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Okay, thanks for the help.
     
    DemoIXI, Dec 18, 2006 IP
  4. lv211

    lv211 Peon

    Messages:
    168
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't understand this line:

    my $oscar;
    $oscar = Net::OSCAR->new();
    Code (markup):
    You declared a variable and then made an new oscar object. ... and then you made the $oscar variable local to the im_in subroutine.

    Try deleting the
    my $oscar
    Code (markup):
    part.
     
    lv211, Dec 20, 2006 IP