line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::AIML; |
2
|
1
|
|
|
1
|
|
51681
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1743
|
|
3
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.0.5'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
13699
|
use HTTP::Request::Common qw(POST); |
|
1
|
|
|
|
|
66994
|
|
|
1
|
|
|
|
|
81
|
|
9
|
1
|
|
|
1
|
|
1009
|
use LWP::Simple; |
|
1
|
|
|
|
|
92636
|
|
|
1
|
|
|
|
|
11
|
|
10
|
1
|
|
|
1
|
|
471
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
11
|
1
|
|
|
1
|
|
1131
|
use XML::Smart; |
|
1
|
|
|
|
|
42519
|
|
|
1
|
|
|
|
|
50
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
12
|
use constant BOTURL => 'http://www.pandorabots.com/pandora/talk-xml'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
365
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
17
|
0
|
|
|
|
|
|
return bless {@_}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub tell { |
21
|
0
|
|
|
0
|
1
|
|
my ( $self, $input, $custid ) = @_; |
22
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(); |
23
|
0
|
|
|
|
|
|
$ua->env_proxy(); |
24
|
0
|
|
|
|
|
|
my $req = POST BOTURL, |
25
|
|
|
|
|
|
|
[ botid => $self->{botid}, custid => $custid, input => $input ]; |
26
|
0
|
|
|
|
|
|
my $res = $ua->request($req); |
27
|
0
|
0
|
|
|
|
|
if ( ! $res->is_success ) { return "sorry, I'm having connection problems"; } |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $xs = XML::Smart->new( $res->content ); # or whatever |
29
|
0
|
|
|
|
|
|
my $error = qq[$xs->{result}{status}]; |
30
|
0
|
0
|
|
|
|
|
if ($error) { warn $error; return; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return wantarray |
32
|
0
|
0
|
|
|
|
|
? ( qq[$xs->{result}{that}], qq[$xs->{result}{custid}] ) |
33
|
|
|
|
|
|
|
: qq[$xs->{result}{that}]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |