Games-Lacuna-Client

 view release on metacpan or  search on metacpan

lib/Games/Lacuna/Client/Captcha.pm  view on Meta::CPAN

package Games::Lacuna::Client::Captcha;
{
  $Games::Lacuna::Client::Captcha::VERSION = '0.003';
}
use 5.0080000;
use strict;
use warnings;
use Carp 'croak';

use Browser::Open qw( open_browser );
use Games::Lacuna::Client;
use Games::Lacuna::Client::Module;
our @ISA = qw(Games::Lacuna::Client::Module);

use Class::XSAccessor {
    getters => [qw(guid url)],
};

sub api_methods {
    return {
        fetch => { default_args => [qw(session_id)] },
        solve => { default_args => [qw(session_id guid)] },
    };
}

sub new {
    my $class = shift;
    my %opt = @_;
    my $self = $class->SUPER::new(@_);
    bless $self => $class;
    return $self;
}

sub fetch {
    my $self = shift;
    my $result = $self->_fetch(@_);
    $self->{guid} = $result->{guid};
    return $result;
}

sub open_in_browser {
    my $self = shift;
    my $result = $self->fetch;
    my $ok = open_browser( $result->{url} );
    return 1 if defined $ok && $ok == 0;
    
    return;
}

sub print_url {
    my $self = shift;
    my $result = $self->fetch;
    print "URL: $result->{url}\n";
}

sub prompt_for_solution {
    my $self = shift;
    print "Answer? ";
    my $answer = <STDIN>;
    chomp($answer);
    return $answer;
}

__PACKAGE__->init();

1;
__END__

=head1 NAME

Games::Lacuna::Client::Captcha - The captcha module

=head1 SYNOPSIS

  use Games::Lacuna::Client;

=head1 DESCRIPTION

=head1 AUTHOR

<<<<<<< HEAD
Steffen Mueller, E<lt>smueller@cpan.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010 by Steffen Mueller
=======
Dave Olszewski, E<lt>cxreg@pobox.com<gt>

=head1 COPYRIGHT AND LICENSE

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.666 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )