Changeset 102 in lab


Ignore:
Timestamp:
Jan 10, 2011 3:16:48 PM (13 years ago)
Author:
mitty
Message:
  • 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Dev/twitter/twitterbot.pl

    r69 r102  
    5050    #                      eq 'mention' => found by mention API 
    5151    if ($tweets->{$id}{type} eq 'retweet') { 
     52        DEBUG and warn "skipping $id that was already retweeted\n"; 
    5253        next; 
    5354    } 
     55    if (defined $conf->{allow}) { 
     56        my $flag; 
     57        foreach my $screen_name ( @{ $conf->{allow}{screen_name} } ) { 
     58            if ($tweets->{$id}{screen_name} eq $screen_name) { 
     59                DEBUG and warn "$id was allowed by screen_name\n"; 
     60                $flag = $id; 
     61                last; 
     62            } 
     63        } 
     64        foreach my $user_id ( @{ $conf->{allow}{user_id} } ) { 
     65            if ($tweets->{$id}{user_id} eq $user_id) { 
     66                DEBUG and warn "$id was allowed by user_id\n"; 
     67                $flag = $id; 
     68                last; 
     69            } 
     70        } 
     71        if (! $flag) { 
     72            next; 
     73        } 
     74    } 
     75     
    5476    DEBUG or sleep($conf->{sleep}); 
    5577     
     
    88110        warn "$0: '$file' $!\n"; 
    89111    } 
     112     
     113    DEBUG and warn "'$file' => ", Dumper($yaml); 
    90114     
    91115    return $yaml->[0]; 
Note: See TracChangeset for help on using the changeset viewer.