| 1 | package Net::AIML; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '0.0.5'; | |||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use HTTP::Request::Common qw(POST); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use LWP::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use LWP::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use XML::Smart; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use constant BOTURL => 'http://www.pandorabots.com/pandora/talk-xml'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 16 | 0 | my $class = shift; | |||||||||
| 17 | 0 | return bless {@_}, $class; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub tell { | ||||||||
|
Subroutine
tell: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 21 | 0 | my ( $self, $input, $custid ) = @_; | |||||||||
| 22 | 0 | my $ua = LWP::UserAgent->new(); | |||||||||
| 23 | 0 | $ua->env_proxy(); | |||||||||
| 24 | my $req = POST BOTURL, | ||||||||||
| 25 | 0 | [ botid => $self->{botid}, custid => $custid, input => $input ]; | |||||||||
| 26 | 0 | my $res = $ua->request($req); | |||||||||
| 27 | 0 | ▶ | if ( ! $res->is_success ) { return "sorry, I'm having connection problems"; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | my $xs = XML::Smart->new( $res->content ); # or whatever | |||||||||
| 29 | 0 | my $error = qq[$xs->{result}{status}]; | |||||||||
| 30 | 0 | ▶ | if ($error) { warn $error; return; } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | return wantarray | ||||||||||
| 32 | 0 | ▶ | ? ( qq[$xs->{result}{that}], qq[$xs->{result}{custid}] ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | : qq[$xs->{result}{that}]; | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | 1; | |||||||||
| 37 | __END__ | ||||||||||