Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've been all over the net::aim docs and looked at a few different pieces of sample bots and I have one quick silly question. Is there a way to get Aimbot to speak without it being spoken to first? I was trying to have an Aimbot IM me if a service on a server went down. But I don't want to have to ask Aimbot first.

Replies are listed 'Best First'.
Re: Quicky Aimbot question
by davido (Cardinal) on Jul 16, 2004 at 03:38 UTC
    It looks to me like you could connect, and then instead of using $aim->start(), just take control of the infinite loop yourself like this:

    while (1) { $aim->do_one_loop(); # Act on the results... # If you feel the need, now you can........ $aim->send_im($name, $message); }

    I don't use AIM, and haven't used this module, but it looks like $aim->start() is just an infinite loop of $aim->do_one_loop()


    Dave

      Yep, it is. Net::AIM's start is somewhat strangely implemented as:

      sub start { my $self = shift; while (1) { last unless $self->do_one_loop(); } }

      If you want to be particularly brave, you should be able to do it with threads too:

      use threads; ... my $thread = threads->new(sub { $aim->start }); $aim->send_im($victim, $msg);
Re: Quicky Aimbot question
by hossman (Prior) on Jul 16, 2004 at 07:10 UTC

    Well, the Net::AIM docs on the "start" method specificly say "This just starts an infinte loop of $aim->do_one_loop;". So it seems like they are encouraging you to do your own looping if you want.

    I would suggest that you don't even bother connecting to the AIM server untill the server goes down, and then don't bother calling start, just send your message and disconnect.

    Bear in mind, there are other modules that might have more intuitive APIs: Net::AIM and Net::AOLIM (which is much newer then the others)

      .oO( Why are there so many of these darn things? ) I've been using Net::OSCAR which works pretty well.. (I amended some things, but now I've forgotten what ,) - A quick glance at Net::AOLIM makes me thing I'll stick with Net::OSCAR for now..

      C.

        Well I got my aimbot written.

        I still had to rely on an event from the server to kick anything off, fortunately the act of logging on produces an event that I can use to kick off what I want.

        The do one loop command loops the serve to see if there's anything there for the client.

        As far as I can tell there is no way to simply initiate the client and send a message. You have to have an event from the server, like an IM, an error, a chat invitation, something, in order to to get the AimBot to do something.

        Anyways thanks for tips, here is my shempy code below. It aint pretty but it does what I want. Namely read an OpenNMS database for outages and then sametime those outages to me:

        #Aimbot to read outages in an OpenNMS database #http://opennms.org) and IM outages to myself.
        use DBI; use Net::AIM; $aim = new Net::AIM; $conn = $aim->newconn(Screenname => 'mybot', Password => 'mybotpassword'); $conn = $aim->getconn(); $conn->set_handler('config', \&on_config); $aim->start; sub on_config { my ($self, $event) = @_; my ($str) = $event->args; my @things = subONMS(); $self->set_config($str); foreach $things (@things){ $self->send_im($friend, $things); $self->send_im('sk1nums', $things); sleep(2); } exit; } sub subONMS{ my $dbh = DBI->connect("dbi:Pg:dbname=opennms;host=localhost", "uname", "pword") or die "Can't connect to postgres db: $!\n"; my $fullquery = "SELECT nodeid FROM outages where ifregainedse +rvice is null"; my $sth = $dbh->prepare($fullquery) or die "Can't prepare SQL statement: ", $dbh->errstr() +, "\n"; $sth->execute() or die "Can't execute SQL statement: ", $sth->errstr(), "\n" +; while(@rows = $sth->fetchrow_array()){ push(@data,@rows); } $sth->finish; $dbh->disconnect; return @data }