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 ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |