Changeset 641934f in lab.git for Dev/twitter/twitterbot.pl


Ignore:
Timestamp:
Jan 10, 2011 3:16:48 PM (14 years ago)
Author:
mitty <mitty@…>
Branches:
master, trunk
Children:
702399e
Parents:
5fa546f
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

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@102 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/twitter/twitterbot.pl

    r8333ea0 r641934f  
    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.