Changeset f0a0980 in lab.git


Ignore:
Timestamp:
Oct 4, 2010 7:01:27 PM (13 years ago)
Author:
mitty <mitty@…>
Branches:
twitter-0.1, twitter-0.1@65, twitter-0.1@66
Children:
aa0e8a6
Parents:
1e8dd5e
Message:
  • add trace outputs for debugging

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • twitterbot.pl

    rabaa39c rf0a0980  
    1414use YAML::Tiny; 
    1515 
     16sub VERBOSE () { $ARGV[0] eq 'verbose' }; 
     17sub DEBUG   () { VERBOSE or $ARGV[0] eq 'debug' }; 
     18use Data::Dumper; 
     19 
     20DEBUG and warn "$0: debug mode"; 
     21 
    1622my $conf = loadconf("$Bin/config.yml"); 
    1723if (! defined $conf) { 
     
    4551        next; 
    4652    } 
    47     sleep($conf->{sleep}); 
     53    DEBUG or sleep($conf->{sleep}); 
    4854    # retweet found tweet 
    4955    #   $tweets->{$id} eq 'search'  => found by search API 
     
    5157    my $res; 
    5258    eval { 
    53         $res = $bot->retweet($id); 
     59        DEBUG  or $res = $bot->retweet($id); 
     60        DEBUG and warn "retweet($id) => ", Dumper($tweets{$id}); 
    5461    }; 
    5562    if ($@) { 
     
    6471if (%tweets) { 
    6572    # 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); 
    6775} 
    6876 
     
    121129        } 
    122130    } 
     131    DEBUG and warn "searching '$key'"; 
    123132     
    124133    my $res; 
     
    134143        } 
    135144        if ($res->{results}) { 
     145            VERBOSE and warn Dumper($res->{results}); 
    136146            foreach my $tweet (@{$res->{results}}) { 
    137147                my $res = $bot->show_status($tweet->{id}); 
     
    142152                    $ids->{$tweet->{id}} = 'search'; 
    143153                } 
     154                VERBOSE and warn Dumper($res); 
    144155            } 
    145156        } 
     
    149160    } 
    150161     
     162    DEBUG and warn "search result => ", Dumper($ids); 
    151163    return $ids; 
    152164} 
     
    168180            } 
    169181        ); 
     182        VERBOSE and warn Dumper($res); 
    170183    }; 
    171184    if ($@) { 
     
    173186    } 
    174187     
    175     my $ids; 
     188    my $ids = {}; 
    176189    if ($res && @{$res}) { 
    177190        $ids = { 
     
    180193    } 
    181194     
     195    DEBUG and warn "mentions result => ", Dumper($ids); 
    182196    return $ids; 
    183197} 
Note: See TracChangeset for help on using the changeset viewer.