who #channel List the visible users on a channel.
whois username ... Query information about particular users.
+ list List channels.
EOF
exit 1;
);
usage if $options{help};
+unless (defined $options{nick}) {
+ print STDERR "No nickname set; use --nick or IRCNICK.\n\n";
+ usage;
+}
+unless (defined $options{server}) {
+ print STDERR "No server set; use --server or IRCSERVER.\n\n";
+ usage;
+}
my $command = shift or usage;
$command = lc $command;
+my $irc = new Net::IRC;
+
+# TODO
+my $conn = $irc->newconn(Nick => $options{nick}, Server => $options{server})
+ or die "$0: can't connect to IRC server";
+
if ($command eq 'who')
{
scalar @ARGV == 1 or usage;
+ $conn->add_handler('376', sub {
+ my $self = shift;
+ $self->who($ARGV[1]);
+ });
}
elsif ($command eq 'whois')
{
scalar @ARGV > 0 or usage;
}
-else
+elsif ($command eq 'list')
{
- usage;
+ scalar @ARGV == 0 or usage;
+ $conn->add_handler('376', sub {
+ my $self = shift;
+ $self->list('-yes');
+ });
}
-
-my $irc = new Net::IRC;
-
-my $conn = $irc->newconn(Nick => $mynick, Server => $server)
- or die "$0: can't connect to IRC server";
-
-sub on_connect
+else
{
- my $self = shift;
- $self->who($targetchannel);
+ usage;
}
sub on_whoreply
exit;
}
-$conn->add_handler('376', \&on_connect);
+sub on_list
+{
+ my ($self, $event) = @_;
+ print $event->args, "\n";
+}
+
$conn->add_handler('352', \&on_whoreply);
$conn->add_handler('315', \&on_endofwho);
+$conn->add_handler('322', \&on_list);
$irc->start;