* change skip flag logic
[lab.git] / Dev / twitter / twitterbot.pl
index 406ee12..9b9e2d8 100755 (executable)
@@ -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];
 }