Changeset 61 in lab
- Timestamp:
- Oct 4, 2010 9:18:30 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/twitter/twitterbot.pl
r60 r61 34 34 } 35 35 36 my %tweets;36 my $tweets = {}; 37 37 my $tweet; 38 38 39 39 $tweet = or_search($bot, $conf->{hashtag}, $stat->{search}); 40 40 if ($tweet) { 41 % tweets = (%tweets, %$tweet);41 %$tweets = (%$tweets, %$tweet); 42 42 } 43 43 44 44 $tweet = mentions_ids($bot, $stat->{mention}); 45 45 if ($tweet) { 46 %tweets = (%tweets, %$tweet); 47 } 48 49 foreach my $id (sort keys %tweets) { 50 if ($tweets{$id} eq 'retweet') { 46 %$tweets = (%$tweets, %$tweet); 47 } 48 49 foreach my $id (sort keys %$tweets) { 50 # $tweets->{$id}{type} eq 'search' => found by search API 51 # eq 'mention' => found by mention API 52 if ($tweets->{$id}{type} eq 'retweet') { 51 53 next; 52 54 } 53 55 DEBUG or sleep($conf->{sleep}); 54 # retweet found tweet 55 # $tweets->{$id} eq 'search' => found by search API 56 # eq 'mention' => found by mention API 56 57 # do retweet found tweets 57 58 my $res; 58 59 eval { 59 60 DEBUG or $res = $bot->retweet($id); 60 DEBUG and warn "retweet($id) => ", Dumper($tweets {$id});61 DEBUG and warn "retweet($id) => ", Dumper($tweets->{$id}); 61 62 }; 62 63 if ($@) { … … 66 67 } 67 68 68 $stat->{$tweets {$id}} = $id;69 } 70 71 if ( %tweets) {69 $stat->{$tweets->{$id}{type}} = $id; 70 } 71 72 if ($tweets) { 72 73 # save last status to yaml file 73 74 DEBUG or YAML::Tiny::DumpFile("$Bin/status.yml", $stat); … … 147 148 my $res = $bot->show_status($tweet->{id}); 148 149 if ($res->{retweeted_status}) { 149 $ids->{$tweet->{id}} = 'retweet';150 $ids->{$tweet->{id}}{type} = 'retweet'; 150 151 } 151 152 else { 152 $ids->{$tweet->{id}} = 'search';153 $ids->{$tweet->{id}}{type} = 'search'; 153 154 } 154 155 VERBOSE and warn Dumper($res); … … 189 190 if ($res && @{$res}) { 190 191 $ids = { 191 map { $_->{id} => 'mention' } @{$res} 192 map { 193 $_->{id} => { 194 type => 'mention', 195 } 196 } @{$res} 192 197 }; 193 198 }
Note: See TracChangeset
for help on using the changeset viewer.