line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Twitter::Queue; |
2
|
1
|
|
|
1
|
|
796
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
59
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
697
|
use Net::Twitter::Lite::WithAPIv1_1; |
|
1
|
|
|
|
|
68169
|
|
|
1
|
|
|
|
|
325
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.02; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
0
|
|
|
0
|
1
|
|
my ($class, $args) = @_; |
9
|
|
|
|
|
|
|
return bless { |
10
|
|
|
|
|
|
|
twitter => Net::Twitter::Lite::WithAPIv1_1->new(%$args), |
11
|
0
|
|
0
|
|
|
|
size => $args->{size} || 100, |
12
|
|
|
|
|
|
|
}, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub add { |
16
|
0
|
|
|
0
|
1
|
|
my ($self, $data) = @_; |
17
|
0
|
|
|
|
|
|
my $res = eval { $self->{twitter}->update($data) }; |
|
0
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if ($@) { |
19
|
0
|
0
|
|
|
|
|
die ref $@ eq 'Net::Twitter::Error' |
20
|
|
|
|
|
|
|
? sprintf 'Error tweeting %s %s %s', $@->code, $@->message, $@->error |
21
|
|
|
|
|
|
|
: sprintf 'Error tweeting %s', $@; |
22
|
|
|
|
|
|
|
} |
23
|
0
|
|
|
|
|
|
return $res; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub next { |
27
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
28
|
0
|
|
|
|
|
|
my $statuses = $self->{twitter}->home_timeline({ count => $self->{size} }); |
29
|
0
|
|
|
|
|
|
my $next = $statuses->[-1]; |
30
|
0
|
0
|
|
|
|
|
return undef unless $next; |
31
|
0
|
|
|
|
|
|
$self->{twitter}->destroy_status($next->{id}); |
32
|
0
|
|
|
|
|
|
return $next->{text}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |