#!perl use strict; use warnings; use 5.008001; use App::Tacochan; use Getopt::Long (); use LWP::UserAgent; my $parser = Getopt::Long::Parser->new( config => ['no_ignore_case', 'pass_through'], ); my $tacochan_server = 'http://127.0.0.1:4969/'; $parser->getoptions( 's|server=s' => \$tacochan_server, ); sub usage { print "tacochan_client $0 [-s tacochan_server] leave #chat $0 [-s tacochan_server] send #chat|user[, user, ...] message "; } my $command = shift @ARGV; my $chat = shift @ARGV; unless ($chat) { usage(); exit; } my @params; if ($command =~ /^leave|part$/) { @params = ( "${tacochan_server}leave", +{ chat => $chat, }, ); } elsif ($command =~ /^send|notice|privmsg$/) { my $message = shift @ARGV; unless ($message) { usage(); exit; } @params = ( "${tacochan_server}send", +{ chat => $chat, message => $message, }, ); } else { usage(); exit; } my $ua = LWP::UserAgent->new( agent => "TacochanClient/$App::Tacochan::VERSION", ); my $res = $ua->post(@params); print $res->content . "\n"; __END__ =head1 NAME tacochan_client - tacochan client =head1 SYNOPSIS # leave chat tacochan -s http://127.0.0.1:4969/ leave \#chat # sent message tacochan -s http://127.0.0.1:4969/ send \#chat|user[, user, ...] message =head1 OPTIONS =over 4 =item -s, --server tacochan server url. =cut