Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Re: Net::Aim (again)

by sutch (Curate)
on Apr 12, 2003 at 16:58 UTC ( #250063=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Net::Aim (again)
in thread Net::Aim (again)

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); }


Comment on Re: Re: Re: Net::Aim (again)
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://250063]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-09-18 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (113 votes), past polls