AI-CleverbotIO

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME

    AI::CleverbotIO - A Perl wrapper for the cleverbot.io API

VERSION

    This document describes AI::CleverbotIO version 0.002.

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

    This module allows you to interact with the API served by
    https://cleverbot.io.

ACCESSORS

 key

       my $api_key = $obj->key;

    Read-only accessor to the API key. MUST be provided upon instantiation.

 endpoints

       my $endpoints_hashref = $obj->endpoints;

    Read-only accessor to a hash reference whose keys are the strings ask
    and create and the corresponding values are the API endoints (URIs).
    The default is:

       {
          ask    => 'https://cleverbot.io/1.0/ask',
          create => 'https://cleverbot.io/1.0/create',
       }

 logger

       my $logger = $obj->logger;

    Read-only accessor to the logger object (Log::Any compatible). See
    "BUILD_logger" for the default value.

 nick

       $obj->nick($some_string);
       my $nick = $obj->nick;

    Read-write accessor to the nick for invoking API calls. If not set, it
    is set after a call to "create". See also "has_nick".

 ua

       my $ua = $obj->ua;

    Read-only accessor to the user agent object (HTTP::Tiny compatible).
    See BUILD_ua for the default value.

 user

       my $api_user = $obj->user;

    Read-only accessor to the API user. MUST be provided upon
    instantiation.



( run in 0.625 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )