chiark
/
gitweb
/
~cjwatson
/
bin.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bsmtp-pull: drop -2; avoid connection sharing
[bin.git]
/
irccat
diff --git
a/irccat
b/irccat
old mode 100644
(file)
new mode 100755
(executable)
index
5febfb0
..
3c92777
--- a/
irccat
+++ b/
irccat
@@
-20,6
+20,7
@@
Available commands (with arguments) are:
who #channel List the visible users on a channel.
whois username ... Query information about particular users.
who #channel List the visible users on a channel.
whois username ... Query information about particular users.
+ list List channels.
EOF
exit 1;
EOF
exit 1;
@@
-37,32
+38,47
@@
GetOptions(\%options,
);
usage if $options{help};
);
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 $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;
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;
}
}
elsif ($command eq 'whois')
{
scalar @ARGV > 0 or usage;
}
-els
e
+els
if ($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
}
sub on_whoreply
@@
-80,8
+96,14
@@
sub on_endofwho
exit;
}
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('352', \&on_whoreply);
$conn->add_handler('315', \&on_endofwho);
+$conn->add_handler('322', \&on_list);
$irc->start;
$irc->start;