From 641934fed10bc9bc8c4b4f2e0c00f0c184a2802c Mon Sep 17 00:00:00 2001 From: mitty Date: Mon, 10 Jan 2011 06:16:48 +0000 Subject: [PATCH] * add more debug output * NEW: retweet only allowed users' tweets * like this {{{ allow: screen_name: - mittyorz user_id: - 211556294 }}} * this feature only works when "allow:" entry exists git-svn-id: https://lab.mitty.jp/svn/lab/trunk@102 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- Dev/twitter/twitterbot.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Dev/twitter/twitterbot.pl b/Dev/twitter/twitterbot.pl index 406ee12..870873c 100755 --- a/Dev/twitter/twitterbot.pl +++ b/Dev/twitter/twitterbot.pl @@ -49,8 +49,30 @@ foreach my $id (sort keys %$tweets) { # $tweets->{$id}{type} eq 'search' => found by search API # eq 'mention' => found by mention API if ($tweets->{$id}{type} eq 'retweet') { + DEBUG and warn "skipping $id that was already retweeted\n"; next; } + if (defined $conf->{allow}) { + my $flag; + 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"; + $flag = $id; + 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"; + $flag = $id; + last; + } + } + if (! $flag) { + next; + } + } + DEBUG or sleep($conf->{sleep}); # do retweet found tweets @@ -88,6 +110,8 @@ sub loadconf { warn "$0: '$file' $!\n"; } + DEBUG and warn "'$file' => ", Dumper($yaml); + return $yaml->[0]; } -- 1.7.9.5