For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > September 2006 > Net::IRC and ctcp ping response









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Net::IRC and ctcp ping response
Anders Ossowicki

2006-09-14, 6:57 pm

Hey,

As I am quite new to this mailing list, I apologize if this is asked often
(but I suppose not ;).
Anyway, I'm currently playing around with the Net::IRC module, trying to
automate some of the stuff I use IRC for. I have a single question though
and that concerns they way Net::IRC handles ctcp ping. From the
irctest-script included with Net::IRC I have:

sub on_ping {
my ($self, $event) = @_;
my $nick = $event->nick;

$self->ctcp_reply($nick, join (' ', ($event->args)));
print "*** CTCP PING request from $nick received\n";

}

My own approach resembles that:

sub on_ctcp_ping {
my ($self, $event) = @_;

$self->ctcp_reply($event->nick, join(' ', ($event->args)));
printf "[".print_time()."] *** CTCP PING request from %s recieved\n",
$event->nick if $verbose == 1;
}

If I understand the way ctcp-ping works, the pinger sends a request along
with a timestamp. The pinged client then returns this timestamp and the
pinger uses the difference between the returned timestamp and the current
timestamp to calculate ping times.

The problem here, is that $event->args is supposed to hold the timestamp
from a client, but this seems not to be the case.
This is an exerpt from irssi, where I've ctcp ping'ed the script:

23:59 [blitzed] [ctcp(bakabot)] PING
23:59 [blitzed] CTCP PING reply from bakabot:

So either irssi's ping-handling or my script is broken, I tend to believe in
the latter. This particular exerpt was from the blitzed network, but I've
tried on EFNet without any luck as well.

I've used Data::Dumper to try and locate the timestamp, but I've failed to
find anything to return. I've poured over the changelogs and old readmes
for Net::IRC, and I know that this has been a problem before, but I can't
see if it's been corrected.

Does anybody know what I need to do to make this work?

--
//anders
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com