cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

Just been having a play with Net::ICQ.

It's still alpha, but seems to do the job.

I can make it send a message OK, but the trouble is I don't know how to (or if I can) connect to the client when running to send another event.

If I connect, send message, then disconnect, my UIN gets blocked after a while and a manual login gives me a "rate limit exceeded" message (ie, trying to connect to ICQ too many times in a short period is naughty).

My guess is I have to run the client continuously, and pipe messages to it as and when needed, but I have no idea how to do this. I want to be able to do something like this from another script on the server:

use ICQsend; # my prog below, amended my $message = "whatever i want to send"; ICQsend::message( uin => 12345678, content => $message);

Has anyone actually written a Perl shell ICQ client that can be called painlessly from an external script? If so, how did you approach it?

cLive ;-)

Here's my hacked-from-the-docs example that sends one message and quits (but only if you reply to it?!?), in case you're interested.

- apologies if it looks messy, but I only started looking at the protocol this morning, and have yet to find a good description of what each function does...

#!/usr/bin/perl use strict; use Net::ICQ; use Data::Dumper; my ( $icq, $ready ); # my uin and password go here $icq = Net::ICQ->new('12345678','*******'); # register dump_event as the handler for ALL (!) events foreach (values(%Net::ICQ::srv_codes)) { $icq->add_handler($_, \&dump_event); } # amend events for these $icq->add_handler('SRV_X2', \&handle_x2); $icq->add_handler('SRV_LOGIN_REPLY', \&handle_login_reply); $icq->add_handler('SRV_SYS_DELIVERED_MESS', \&on_msg); $icq->connect(); print "connecting...\n"; while (!$ready) { $icq->do_one_loop; } print "ready\n"; my $params = { 'type' => 1, 'text' => 'this is a test message', 'receiver_uin' => 23406993}; $icq->send_event('CMD_SEND_MESSAGE', $params); $icq->start; exit(0); # what to do when message sent sub on_msg { print "Message Sent\n"; \&disconnect; } # dump event contents sub dump_event { my ($icq, $event) = @_; print Dumper $event; } # send CMD_ACK_MESSAGES on X2 from server to keep it from # sending us any received offline msgs on next login sub handle_x2 { my ($icq, $event) = @_; print (":X2\n"); $icq->send_event('CMD_ACK_MESSAGES'); } # set ready to 1 to signal we can send events now sub handle_login_reply { my ($icq, $event) = @_; print (":LOGIN_REPLY\n"); $ready = 1; } sub disconnect { $icq->disconnect(); exit(); }

Replies are listed 'Best First'.
Re: Working Net::ICQ client anyone?
by raptor (Sexton) on Oct 06, 2001 at 19:42 UTC
    interesting.. i was also just playing with this module.... and I got the same rate-limit errors !! 'cause I'm on ADSL with dynamic IP-address I want to use it so that when connection-drops and later recconnect, on reconnection I modify httpd.conf(virtual-hosts-IP's), restart the apache and finally want to send ICQ message to interested party......

    The documentation of the module is very skiny :"(... I'm setting
    $icq->{_debug} = 1
    Thanx for the code... (i was doing very simply tests) ..
    And keep us informed for your progress... at least I'm interested
    Meanwhile there is one more module called Net::ICQV5, u can't find it on CPAN, do a search on Google
    ==========
    raptor@unacs.bg

    PS. Also will be good if after my Linux makes me a cooffe (there is such HOW-to in linux-docs :") ) to send me message that it is ready...