Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Net::IRC - how to check is user online?

by VoLAnD (Initiate)
on Jun 09, 2007 at 05:40 UTC ( [id://620147]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Net::IRC - how to check is user online?
in thread Net::IRC - how to check is user online?

Yes, you're right.
I've found event 'ison'.
In console output all is OK, but on IRC-channel I have delay in one request. Example
>isonline John
>OFFLINE
>isonline John
>ONLINE

In console:
Find:
ONLINE
Find:
ONLINE


This is script:
#!/usr/bin/perl -w

use Net::IRC;
use strict;

my $irc = new Net::IRC;

my $global_name = 'Test'; my $global_search = 0;

my $channel = '#TEST';
my $globalconn = $irc->newconn(
Server => 'servername',
Port => '6667',
Nick => 'IBot',
Ircname => 'Bot',
Username => 'IRC-Bot'
);

$globalconn->{channel} = shift || $channel;

sub on_connect {

my $conn = shift;
$conn->join($conn->{channel});
$conn->{connected} = 1;
print "connected\n";
}

sub on_ison_reply {
my $self = shift;
my $event = shift;
print "ISON $global_name: ";
if ($event->{args}->\1\ eq $global_name) {
$global_search = 1;
print "ONLINE: $global_search\n";
}
else {
$global_search = 0;
print "OFFLINE: $global_search\n";
}
}

sub on_public {

my ($conn, $event) = @_;

my $text = $event->{args}\0\;

if ($text =~ /isonline (.+)/) {
my $test_text = test($1, $event->{nick});
$conn->privmsg($event->{to}\0\, $test_text);
}


}

sub test {

my $input = shift;
my $nick = shift;

print "Found: $input\n";
$global_name = $input;
$globalconn->ison($input);

if ($global_search == 1) {
return "ONLINE";}
else {return "OFFLINE";}

return "wrong request";
}

$globalconn->add_handler('422', \&on_connect);
$globalconn->add_handler('public', \&on_public);
$globalconn->add_handler('ison', \&on_ison_reply);

$irc->start();

  • Comment on Re^4: Net::IRC - how to check is user online?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found