From 692186c26855ed95d280d65a46592dfa914266cf Mon Sep 17 00:00:00 2001 From: mitty Date: Mon, 4 Oct 2010 12:56:16 +0000 Subject: [PATCH] * add new hash members to return value of or_search and mentions_ids git-svn-id: https://lab.mitty.jp/svn/lab/trunk/twitter@63 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- twitterbot.pl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/twitterbot.pl b/twitterbot.pl index 249c1bc..7da7ec8 100755 --- a/twitterbot.pl +++ b/twitterbot.pl @@ -12,6 +12,7 @@ use utf8; use Net::Twitter::Lite; use FindBin qw($Bin); use YAML::Tiny; +use Date::Parse qw(str2time); sub VERBOSE () { $ARGV[0] eq 'verbose' }; sub DEBUG () { VERBOSE or $ARGV[0] eq 'debug' }; @@ -142,17 +143,25 @@ sub or_search { } ); } + VERBOSE and warn Dumper($res); if ($res->{results}) { - VERBOSE and warn Dumper($res); foreach my $tweet (@{$res->{results}}) { my $res = $bot->show_status($tweet->{id}); + VERBOSE and warn Dumper($res); + + my $id = { + date => str2time($res->{created_at}), + screen_name => $res->{user}{screen_name}, + status_id => $res->{id}, + text => $res->{text}, + }; if ($res->{retweeted_status}) { - $ids->{$tweet->{id}}{type} = 'retweet'; + $id->{type} = 'retweet'; } else { - $ids->{$tweet->{id}}{type} = 'search'; + $id->{type} = 'search'; } - VERBOSE and warn Dumper($res); + $ids->{$tweet->{id}} = $id; } } }; @@ -191,7 +200,11 @@ sub mentions_ids { $ids = { map { $_->{id} => { - type => 'mention', + date => str2time($_->{created_at}), + screen_name => $_->{user}{screen_name}, + status_id => $_->{id}, + text => $_->{text}, + type => 'mention', } } @{$res} }; -- 1.7.9.5