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();
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.