line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Generatus; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
611
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
4
|
use base qw/Net/; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
493
|
|
6
|
1
|
|
|
1
|
|
714
|
use URI::Escape; |
|
1
|
|
|
|
|
1176
|
|
|
1
|
|
|
|
|
52
|
|
7
|
1
|
|
|
1
|
|
6797
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
43030
|
|
|
1
|
|
|
|
|
240
|
|
8
|
|
|
|
|
|
|
#use Carp; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
11
|
|
|
|
|
|
|
#http://search.twitter.com/search.json?q= |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub Status { |
14
|
2
|
|
|
2
|
1
|
307
|
my $self = shift; |
15
|
|
|
|
|
|
|
#$self->set_user_agent("Net::Generatus-$VERSION (PERL)"); |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
100
|
|
|
18
|
my $params = shift || {}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#grab the params |
20
|
2
|
|
50
|
|
|
16
|
my $gender = $params->{'gender'} || 'F'; |
21
|
2
|
|
50
|
|
|
13
|
my $name = $params->{'name'} || ''; |
22
|
2
|
|
100
|
|
|
11
|
my $tag = $params->{'tag'} || ''; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#build URL |
25
|
2
|
|
|
|
|
5
|
my $url = 'http://www.generatus.com/AJAXStatus.asp?'; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
12
|
$url .= 'G=' . URI::Escape::uri_escape($gender); |
28
|
2
|
|
|
|
|
82
|
$url .= '&N=' . URI::Escape::uri_escape($name);# if ($name); |
29
|
2
|
|
|
|
|
29
|
$url .= '&K=' . URI::Escape::uri_escape($tag); # if ($tag); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#do request |
32
|
2
|
|
|
|
|
41
|
my $ua = LWP::UserAgent->new(); |
33
|
|
|
|
|
|
|
#my $req = $self->{ua}->get($url); |
34
|
2
|
|
|
|
|
141852
|
my $response = $ua->post($url); |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
320170
|
my $raw; |
37
|
2
|
50
|
|
|
|
11
|
if ($response->is_success) { |
38
|
2
|
|
|
|
|
38
|
$raw = $response->decoded_content; # or whatever |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
0
|
die $response->status_line; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
50644
|
my @bits = split(/\#\#\#/, $raw); |
45
|
2
|
|
|
|
|
6
|
my $status = $bits[0]; |
46
|
2
|
|
|
|
|
5
|
chomp $status; |
47
|
2
|
|
|
|
|
113
|
return $status; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# sub set_user_agent { |
51
|
|
|
|
|
|
|
# my $self = shift; |
52
|
|
|
|
|
|
|
# my $agent = shift; |
53
|
|
|
|
|
|
|
# $self->{ua}->agent($agent); |
54
|
|
|
|
|
|
|
# } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Net::Generatus - Get random status message from generatus.com |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSYS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use Net::Generatus; |
65
|
|
|
|
|
|
|
#get an interesting yet rude status message |
66
|
|
|
|
|
|
|
$status = Net::Generatus::Status({tag => 'insults'}); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Pulls a random and potentially witty status message from generatus.com which could be used to update twitter or one of it's clones |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 Status |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
params |
79
|
|
|
|
|
|
|
tag - (optional) select the status message from message with this tag |
80
|
|
|
|
|
|
|
name - (your name, optional, will be prepended to status message) |
81
|
|
|
|
|
|
|
gender - either M or F (defaults to F) |
82
|
|
|
|
|
|
|
returns: string |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 EXAMPLE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#get a insults status message |
87
|
|
|
|
|
|
|
$status = Net::Generatus::Status({tag => 'insults'}); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$status = Net::Generatus::Status({gender => 'M'}); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Brenda Wallace |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
(based on Net::Twitter::Search and Net::Twitter::Diff) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |