AnyEvent-SparkBot

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  -- $self->run_lookup Retry-After header is now correctly supported
  -- true non blocking unit testing added
  -- Got advice from cisco about listMessages, apparently bots can only list messages that in rooms that refer to themselves.
  -- Added far more extensive unit testing
1.008
  -- AnyEvent::HTTP::Spark, added support properly handling 429 response in both blocking and non blocking context, IE full Retry-After support has been added
  -- AnyEvent::HTTP::Spark, documented new constructor arguments
  -- AnyEvent::SparkBot $self->run_lookup is now just a shortcut, it is no longer a wrapper, but works just fine.
  -- t/AnyEvent-SparkBot.t no longer tries to get to the internet without $ENV{RUN_HTTP_TESTS} being true
1.009
  -- Changed min version of Data::Dumper to 2.161
1.010
  -- Changed min version of Carp to 1.38
1.011 
  -- Removed old vendor doc links
  -- Added missing meetings api and pod
1.012
  -- Added uploadFile interface
1.013
  -- Fixed the readme file
1.014

META.json  view on Meta::CPAN

      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "AnyEvent::WebSocket::Client" : "0.39",
            "B" : "1.68",
            "Carp" : "1.38",
            "Data::Dumper" : "2.161",
            "Data::Result" : "1.0",
            "Exporter" : "5.72",
            "HTTP::MultiGet" : "1.008",
            "HTTP::Request" : "6.13",
            "HTTP::Request::Common" : "6.13",
            "IO::Scalar" : "2.111",
            "IO::Socket::SSL" : "1.968",
            "JSON" : "2.90",
            "LWP::UserAgent" : "6.26",
            "Log::Dispatch::Handle" : "2.65",

META.yml  view on Meta::CPAN

  version: '1.4'
name: AnyEvent-SparkBot
no_index:
  directory:
    - t
    - inc
requires:
  AnyEvent::WebSocket::Client: '0.39'
  B: '1.68'
  Carp: '1.38'
  Data::Dumper: '2.161'
  Data::Result: '1.0'
  Exporter: '5.72'
  HTTP::MultiGet: '1.008'
  HTTP::Request: '6.13'
  HTTP::Request::Common: '6.13'
  IO::Scalar: '2.111'
  IO::Socket::SSL: '1.968'
  JSON: '2.90'
  LWP::UserAgent: '6.26'
  Log::Dispatch::Handle: '2.65'

Makefile.PL  view on Meta::CPAN

    LICENSE=>'perl_5',
    PREREQ_PM         => {
    qw(
      IO::Socket::SSL 1.968
      Moo  2.003002
      overload 1.28
      Modern::Perl 1.20170117
      MooX::Types::MooseLike::Base 0.29
      Carp 1.38
      namespace::clean 0.27
      Data::Dumper  2.161
      Test::More    1.302073
      Data::Result  1.0
      Log::Log4perl 1.49
      Time::HiRes   1.9741
      B             1.68
      Scalar::Util  1.48
      Ref::Util     0.203
      Log::Dispatch::Handle  2.65
      IO::Scalar    2.111
      Exporter      5.72

README.md  view on Meta::CPAN

| AnyEvent::HTTP::Spark | Dual Nature Syncrnous/Asyncrnous AnyEvent friendly Spark v1 HTTP Client library |
| AnyEvent::SparkBot::SharedRole | Shared library used by AnyEvent::SparkBot and AnyEvent::HTTP::Spark |

Once installed it you should be able to use perldoc to view the pod.

## Basic Example

This example shows how to connect to spark and respond to text messages.
```
use Modern::Perl;
use Data::Dumper;
use AnyEvent::SparkBot;
use AnyEvent::Loop;
$|=1;

my $obj=new AnyEvent::SparkBot(token=>$ENV{SPARK_TOKEN},on_message=>\&cb);

$obj->que_getWsUrl(sub { $obj->start_connection});
$obj->agent->run_next;
AnyEvent::Loop::run;

lib/AnyEvent/HTTP/Spark.pm  view on Meta::CPAN

package AnyEvent::HTTP::Spark;

use Modern::Perl;
use Moo;
use MooX::Types::MooseLike::Base qw(:all);
use Data::Dumper;
use JSON qw(to_json from_json);
use HTTP::Request::Common qw(POST);
use Ref::Util qw(is_plain_arrayref is_plain_hashref);
use URI::Escape qw(uri_escape_utf8);
use namespace::clean;
use Scalar::Util qw(looks_like_number);
use AnyEvent;

BEGIN { 
  no namespace::clean;

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

package AnyEvent::SparkBot;

our $VERSION='1.015';
use Modern::Perl;
use Moo;
use MooX::Types::MooseLike::Base qw(:all);
use Scalar::Util qw( looks_like_number);
use Data::Dumper;
use namespace::clean;
use AnyEvent::HTTP::MultiGet;
use AnyEvent::WebSocket::Client;
use MIME::Base64;
use JSON;
use AnyEvent::HTTP::Spark;

BEGIN { 
  no namespace::clean;
  with 'HTTP::MultiGet::Role', 'AnyEvent::SparkBot::SharedRole';
}

=head1 NAME

AnyEvent::SparkBot - Cisco Spark WebSocket Client for the AnyEvent Loop

=head1 SYNOPSIS

  use Modern::Perl;
  use Data::Dumper;
  use AnyEvent::SparkBot;
  use AnyEvent::Loop;
  $|=1;

  our $obj=new AnyEvent::SparkBot(token=>$ENV{SPARK_TOKEN},on_message=>\&cb);

  $obj->que_getWsUrl(sub { 
    my ($agent,$id,$result)=@_;

    # start here if we got a valid connection

t/AnyEvent-HTTP-Spark-nonBLock.t  view on Meta::CPAN

use Modern::Perl;
use Log::LogMethods::Log4perlLogToString;
use Carp qw(confess);
use Data::Dumper;
use JSON qw(to_json from_json);
use AnyEvent::Loop;
#BEGIN { $SIG{__DIE__} = sub { confess @_ }; }
use Test::More qw(no_plan);

my $class='AnyEvent::SparkBot';
require_ok($class);
use_ok($class);

my $string;

t/AnyEvent-HTTP-Spark.t  view on Meta::CPAN

use Modern::Perl;
use Log::LogMethods::Log4perlLogToString;
use Carp qw(confess);
use Data::Dumper;
use JSON qw(to_json from_json);
#BEGIN { $SIG{__DIE__} = sub { confess @_ }; }
use Test::More qw(no_plan);

my $class='AnyEvent::HTTP::Spark';
require_ok($class);
use_ok($class);

my $string;
my $logger=LoggerToString($class,$string);

t/AnyEvent-SparkBot.t  view on Meta::CPAN

use Modern::Perl;
use Log::LogMethods::Log4perlLogToString;
use Carp qw(confess);
use AnyEvent::Loop;
use Data::Dumper;
#BEGIN { $SIG{__DIE__} = sub { confess @_ }; }
use Test::More qw(no_plan);

my $class='AnyEvent::SparkBot';
require_ok($class);
use_ok($class);

my $string='';
my $logger=LoggerToString($class,$string);
my $token=exists $ENV{SPARK_TOKEN} ? $ENV{SPARK_TOKEN} : 'this is not a valid token';



( run in 0.618 second using v1.01-cache-2.11-cpan-4d50c553e7e )