AnyEvent-Lingr

 view release on metacpan or  search on metacpan

eg/lingr-stream.pl  view on Meta::CPAN


binmode STDOUT, ':utf8';

use AnyEvent;
use AnyEvent::Lingr;

use Config::Pit;

my $conf = pit_get 'lingr.com', require => {
    'user'     => 'lingr username',
    'password' => 'lingr password',
    'api_key'  => 'lingr api_key (optional)',
};

my $cv = AE::cv;

my $lingr = AnyEvent::Lingr->new(%$conf);
$lingr->on_error(sub {
    my ($msg) = @_;

    if ($msg =~ /^596:/) {

lib/AnyEvent/Lingr.pm  view on Meta::CPAN


use AnyEvent::HTTP;

use Carp;
use JSON;
use Log::Minimal;
use Scalar::Util ();
use Try::Tiny;
use URI;

has ['user', 'password'] => (
    is       => 'ro',
    required => 1,
);

has 'api_key' => (
    is => 'ro',
);

has 'endpoint' => (
    is      => 'ro',

lib/AnyEvent/Lingr.pm  view on Meta::CPAN

                $self->session(undef);
                $self->_on_error($res, $hdr);
            }
        });
    }
    else {
        debugf "create new session...";

        $self->post('session/create', {
            user     => $self->user,
            password => $self->password,
            $self->api_key ? (api_key => $self->api_key) : (),
        }, sub {
            my ($res, $hdr) = @_;
            return unless $self;

            if ($res and $res->{status} eq 'ok') {
                debugf "session created: %s", $res->{session};
                $self->session( $res->{session} );
                $self->_get_channels;
            }

lib/AnyEvent/Lingr.pm  view on Meta::CPAN


AnyEvent::Lingr - Asynchronous Lingr client.

=head1 SYNOPSIS

    use AnyEvent;
    use AnyEvent::Lingr;
    
    my $lingr = AnyEvent::Lingr->new(
        user     => 'your lingr username',
        password => 'your lingr password',
        api_key  => 'your lingr api_key', # optional
    );
    
    # error handler
    $lingr->on_error(sub {
        my ($msg) = @_;
        warn 'Lingr error: ', $msg;
    
        # reconnect after 5 seconds,
        my $t; $t = AnyEvent->timer(

lib/AnyEvent/Lingr.pm  view on Meta::CPAN

=head2 new(%options)

Create AnyEvent::Lingr object. Available %options are:

=over

=item * user => 'Str' (required)

Lingr username

=item * password => 'Str' (required)

Lingr password

=item * api_key => 'Str' (optional)

Lingr api_key.

=item * session => 'Str' (optional)

Lingr session key. If this parameter is passed, this module try to reuse this key for calling session/verify api, otherwise create new session.

=back

    my $lingr = AnyEvent::Lingr->new(
        user     => 'your lingr username',
        password => 'your lingr password',
        api_key  => 'your lingr api_key', # optional
    );

=head2 start_session

Start lingr chat session.

This method runs following sequences:

=over



( run in 0.557 second using v1.01-cache-2.11-cpan-49f99fa48dc )