Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It's been a while since I've done anything useful with Net::AIM, but I remember that it needs to handle some config events before any messages can be sent. I also noticed that AIM will not send messages if the connection is closed too soon (thus the sleep).

This code below does the job. DEBUG is on to show some useful information, but I'd also suggest adding some print statements to gain an even better understanding of how Net::AIM functions.

#!/usr/bin/perl use strict; use Net::AIM; sub DEBUG() { 1 } my $aim = new Net::AIM; $aim->debug(1) if (DEBUG); # provides helpful information $aim->newconn( Screenname => 'my_name', Password => 'my_password' ) or + die "Can't connect to AIM server.\n"; my $conn = $aim->getconn(); $conn->set_handler('config', \&on_config); $aim->set('config_done', 0); my $done = 0; while (! $done) { $aim->do_one_loop(); if ($aim->get('config_done')) { $aim->send_im('my_buddy', 'my_message'); sleep 5; $done = 1; } else { $aim->do_one_loop(); } } sub on_config { my ($self, $evt, $from, $to) = @_; my $str = shift @{$evt->args()}; $self->set_config_str($str, 1); $self->send_config(); $self->set('config_done', 1); }

In reply to Re: Re: Re: Net::Aim (again) by sutch
in thread Net::Aim (again) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2021-10-22 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?