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

In reply to Working Net::ICQ client anyone? by cLive ;-)

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.