Changeset f72bb76 in lab.git for twitter/twitterbot.pl
- Timestamp:
- Oct 4, 2010 7:01:27 PM (14 years ago)
- Branches:
- master, trunk
- Children:
- 7e20eed
- Parents:
- b4d59be
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
twitter/twitterbot.pl
r35889d4 rf72bb76 14 14 use YAML::Tiny; 15 15 16 sub VERBOSE () { $ARGV[0] eq 'verbose' }; 17 sub DEBUG () { VERBOSE or $ARGV[0] eq 'debug' }; 18 use Data::Dumper; 19 20 DEBUG and warn "$0: debug mode"; 21 16 22 my $conf = loadconf("$Bin/config.yml"); 17 23 if (! defined $conf) { … … 45 51 next; 46 52 } 47 sleep($conf->{sleep});53 DEBUG or sleep($conf->{sleep}); 48 54 # retweet found tweet 49 55 # $tweets->{$id} eq 'search' => found by search API … … 51 57 my $res; 52 58 eval { 53 $res = $bot->retweet($id); 59 DEBUG or $res = $bot->retweet($id); 60 DEBUG and warn "retweet($id) => ", Dumper($tweets{$id}); 54 61 }; 55 62 if ($@) { … … 64 71 if (%tweets) { 65 72 # save last status to yaml file 66 YAML::Tiny::DumpFile("$Bin/status.yml", $stat); 73 DEBUG or YAML::Tiny::DumpFile("$Bin/status.yml", $stat); 74 DEBUG and warn "status.yml => ", Dumper($stat); 67 75 } 68 76 … … 121 129 } 122 130 } 131 DEBUG and warn "searching '$key'"; 123 132 124 133 my $res; … … 134 143 } 135 144 if ($res->{results}) { 145 VERBOSE and warn Dumper($res->{results}); 136 146 foreach my $tweet (@{$res->{results}}) { 137 147 my $res = $bot->show_status($tweet->{id}); … … 142 152 $ids->{$tweet->{id}} = 'search'; 143 153 } 154 VERBOSE and warn Dumper($res); 144 155 } 145 156 } … … 149 160 } 150 161 162 DEBUG and warn "search result => ", Dumper($ids); 151 163 return $ids; 152 164 } … … 168 180 } 169 181 ); 182 VERBOSE and warn Dumper($res); 170 183 }; 171 184 if ($@) { … … 173 186 } 174 187 175 my $ids ;188 my $ids = {}; 176 189 if ($res && @{$res}) { 177 190 $ids = { … … 180 193 } 181 194 195 DEBUG and warn "mentions result => ", Dumper($ids); 182 196 return $ids; 183 197 }
Note: See TracChangeset
for help on using the changeset viewer.