X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=Dev%2Ftwitter%2Fdump_timeline.pl;h=1fa8121771253ab32f38e54d053bf31ed2934bcb;hb=ee655ecc81f3c02cd73b34e19e0f4fbb51b4efdb;hp=246a1d49c31560f1dd44eeaf1b1abbc4c98afbd3;hpb=f1b126ae0a301c7164a1cbc401d79a0e49a5c215;p=lab.git diff --git a/Dev/twitter/dump_timeline.pl b/Dev/twitter/dump_timeline.pl index 246a1d4..1fa8121 100755 --- a/Dev/twitter/dump_timeline.pl +++ b/Dev/twitter/dump_timeline.pl @@ -15,7 +15,7 @@ use YAML::Tiny; use Data::Dumper; use Encode; -if ($ARGV[0] && ($ARGV[0] eq '--help' || $ARGV[0] eq '-h') ) { +my $help = sub { die <authorized) { - die "$0: this client is not yet authorized.\n"; + die "$0: this client is not yet authorized."; } @@ -67,7 +71,8 @@ eval { $res = $bot->mentions($param); } else { - die "$0: unknown method => $method\n"; + warn "$0: unknown method '$method'"; + &{$help}; } if ($dump) { @@ -79,12 +84,12 @@ eval { else { foreach my $status (@{$res}) { my $text = ""; + $text .= "(". $status->{id} . ") "; $text .= $status->{user}{name}; $text .= " [" . $status->{created_at} . "]"; - $text .= " (". $status->{id} . ")"; - $text .= " ". encode('utf8', $status->{text}); + $text .= " ". $status->{text}; $text =~ s/\n//; - print $text, "\n"; + print encode('utf8', $text), "\n"; } } } @@ -92,7 +97,6 @@ eval { if ($@) { evalrescue($@); } -print "done\n"; sub loadconf { @@ -105,7 +109,7 @@ sub loadconf { my $yaml = YAML::Tiny->read($file); if ($!) { - warn "$0: '$file' $!\n"; + warn "$0: '$file' $!"; } return $yaml->[0];