X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=Dev%2Ftwitter%2Ftwitterbot.pl;h=9b9e2d888630eeff7d69bc37b2704320f30dfce8;hb=702399e09a32025f7dfed289735b064361263a6b;hp=406ee128f4ca5a883417a86dc12db8896903dafe;hpb=8333ea00a9fe608c90c20af12ea0c51548f66f4e;p=lab.git diff --git a/Dev/twitter/twitterbot.pl b/Dev/twitter/twitterbot.pl index 406ee12..9b9e2d8 100755 --- a/Dev/twitter/twitterbot.pl +++ b/Dev/twitter/twitterbot.pl @@ -48,9 +48,33 @@ my $tweets = {}; foreach my $id (sort keys %$tweets) { # $tweets->{$id}{type} eq 'search' => found by search API # eq 'mention' => found by mention API + my $skip; if ($tweets->{$id}{type} eq 'retweet') { + DEBUG and warn "skipping $id that was already retweeted\n"; + $skip = $id; + } + if (defined $conf->{allow}) { + $skip = $id; + foreach my $screen_name ( @{ $conf->{allow}{screen_name} } ) { + if ($tweets->{$id}{screen_name} eq $screen_name) { + DEBUG and warn "$id was allowed by screen_name\n"; + undef $skip; + last; + } + } + foreach my $user_id ( @{ $conf->{allow}{user_id} } ) { + if ($tweets->{$id}{user_id} eq $user_id) { + DEBUG and warn "$id was allowed by user_id\n"; + undef $skip; + last; + } + } + } + + if ($skip) { next; } + DEBUG or sleep($conf->{sleep}); # do retweet found tweets @@ -88,6 +112,8 @@ sub loadconf { warn "$0: '$file' $!\n"; } + DEBUG and warn "'$file' => ", Dumper($yaml); + return $yaml->[0]; }