From abaa39c4501e1618a042955c2a97e9f356138aba Mon Sep 17 00:00:00 2001 From: mitty Date: Mon, 13 Sep 2010 14:02:26 +0000 Subject: [PATCH] * different since_id options on mentions, search git-svn-id: https://lab.mitty.jp/svn/lab/trunk/twitter@52 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- twitterbot.pl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/twitterbot.pl b/twitterbot.pl index e4d1b62..ccd2c5a 100755 --- a/twitterbot.pl +++ b/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 { -- 1.7.9.5