X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=twitter%2Ftwitterbot.pl;h=ccd2c5aa58ef1989e22152d00c5ce4292ec5c3fa;hb=ec2b7c9dc76edc1aaeb1471d1a74ef72f5199e1d;hp=e4d1b62f29690a0feacffc3dd3ca87d254af0924;hpb=ed4ab0c08455fcdc47ad056e4700b02615573087;p=lab.git diff --git a/twitter/twitterbot.pl b/twitter/twitterbot.pl index e4d1b62..ccd2c5a 100755 --- a/twitter/twitterbot.pl +++ b/twitter/twitterbot.pl @@ -19,10 +19,7 @@ if (! defined $conf) { } my $stat = loadconf("$Bin/status.yml"); if (! defined $stat) { - $stat = { - # do not set to 0 - since_id => 1, - }; + $stat = {}; } my $bot = login($conf); @@ -33,12 +30,12 @@ if (! $bot->authorized) { my %tweets; my $tweet; -$tweet = or_search($bot, $conf->{hashtag}, $stat->{since_id}); +$tweet = or_search($bot, $conf->{hashtag}, $stat->{search}); if ($tweet) { %tweets = (%tweets, %$tweet); } -$tweet = mentions_ids($bot, $stat->{since_id}); +$tweet = mentions_ids($bot, $stat->{mention}); if ($tweet) { %tweets = (%tweets, %$tweet); } @@ -61,7 +58,7 @@ foreach my $id (sort keys %tweets) { next; } - $stat->{since_id} = $id; + $stat->{$tweets{$id}} = $id; } if (%tweets) { @@ -112,7 +109,7 @@ sub or_search { my $bot = shift @_; my $keywords = shift @_; - my $since_id = shift @_; + my $since_id = shift @_ || 1; my $key = ""; foreach my $word (@$keywords) { @@ -161,7 +158,7 @@ sub mentions_ids { # or undef (none is found) my $bot = shift @_; - my $since_id = shift @_; + my $since_id = shift @_ || 1; my $res; eval {