use Data::Dumper;
use Encode;
-if (@ARGV < 1) {
- die "usage: $0 screen_name [number_of_pages|all [dump]]\n";
+if ($ARGV[0] && ($ARGV[0] eq '--help' || $ARGV[0] eq '-h') ) {
+ die <<EOM;
+usage: $0
+ [user_timeline(default)|retweeted_by_me|mentions
+ [screen_name
+ [number_of_pages|all
+ [dump]
+ ]
+ ]
+ ]
+EOM
}
-my $screen_name = $ARGV[0];
-my $pages = $ARGV[1] || 1;
+my $method = $ARGV[0] || 'user_timeline';
+my $screen_name = $ARGV[1] || '';
+my $pages = $ARGV[2] || 1;
if ($pages eq 'all') {
$pages = -1;
}
-my $dump = $ARGV[2] || 0;
+my $dump = $ARGV[3] || 0;
my $conf = loadconf("$Bin/config.yml");
if (! defined $conf) {
my $page = 0;
while ($pages - $page && $page <= 160) {
$page++;
- my $res = $bot->user_timeline(
- {
- screen_name => $screen_name,
- page => $page,
- }
- );
+
+ my $param = ($screen_name)
+ ? { page => $page, screen_name => $screen_name, }
+ : { page => $page, }
+ ;
+
+ my $res;
+ if ($method eq 'user_timeline') {
+ $res = $bot->user_timeline($param);
+ }
+ elsif ($method eq 'retweeted_by_me') {
+ $res = $bot->retweeted_by_me($param);
+ }
+ elsif ($method eq 'mentions') {
+ $res = $bot->mentions($param);
+ }
+ else {
+ die "$0: unknown method => $method\n";
+ }
if ($dump) {
foreach my $line (split /\n/, Dumper $res) {