AI-CleverbotIO

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

SYNOPSIS

       use AI::CleverbotIO;
    
       my $cleverbot = AI::CleverbotIO->new(
          key => $ENV{CLEVERBOT_API_KEY},
          nick => $ENV{CLEVERBOT_NICK},
          user => $ENV{CLEVERBOT_API_USER},
       );
    
       # call to create() is mostly safe, you might get an error
       # back but still 200 OK. You can avoid this (and wasting one
       # API call) if you know the nick is already active for these
       # API credentials.
       $cleverbot->create();
    
       # then, it's just... ask()
       my $answer = $cleverbot->ask('Hello darling!');
       say $answer->{response};

DESCRIPTION

README  view on Meta::CPAN

    Send a create API request. The returned $answer is a hash reference
    derived by the JSON decoding of the response body, e.g.:

       {
          status => 'success',
          nick   => 'NickTheRobot',
       }

    If the current "nick" has already been used for creation, the API call
    will fail partially in that status 200 will be returned, but the status
    field in the answer will contain an error about the fact that the nick
    already exists (Error: reference name already exists). You can safely
    ignore this error.

    You can optionally pass a different other_nick. This will be set as
    "nick" and used for creation (this will overwrite whatever "nick"
    contains though).

 has_nick

       say $obj->nick if $obj->has_nick;
       say 'no nick yet' unless $obj->has_nick;

lib/AI/CleverbotIO.pod  view on Meta::CPAN

=head1 SYNOPSIS

   use AI::CleverbotIO;

   my $cleverbot = AI::CleverbotIO->new(
      key => $ENV{CLEVERBOT_API_KEY},
      nick => $ENV{CLEVERBOT_NICK},
      user => $ENV{CLEVERBOT_API_USER},
   );

   # call to create() is mostly safe, you might get an error
   # back but still 200 OK. You can avoid this (and wasting one
   # API call) if you know the nick is already active for these
   # API credentials.
   $cleverbot->create();

   # then, it's just... ask()
   my $answer = $cleverbot->ask('Hello darling!');
   say $answer->{response};

=head1 DESCRIPTION

lib/AI/CleverbotIO.pod  view on Meta::CPAN

Send a I<create> API request. The returned C<$answer> is a hash reference
derived by the JSON decoding of the response body, e.g.:

   {
      status => 'success',
      nick   => 'NickTheRobot',
   }

If the current L</nick> has already been used for creation, the API call
will fail partially in that status 200 will be returned, but the C<status>
field in the answer will contain an error about the fact that the nick
already exists (C<Error: reference name already exists>). You can safely
ignore this error.

You can optionally pass a different C<other_nick>. This will be set as
L</nick> and used for creation (this will overwrite whatever L</nick>
contains though).

=head2 has_nick

   say $obj->nick if $obj->has_nick;
   say 'no nick yet' unless $obj->has_nick;



( run in 0.451 second using v1.01-cache-2.11-cpan-bb97c1e446a )