The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use utf8::all;
use autodie qw(:all);

# PODNAME: twitter-send
# ABSTRACT: Sink process for exobrain/twitter

use Exobrain;
use Net::Twitter;

use constant DEBUG => 0;

my $exobrain = Exobrain->new;
my $config   = $exobrain->config->{TwitterSend};

my $twitter = Net::Twitter->new(
    traits   => [qw(API::RESTv1_1)],
    consumer_key        => $config->{consumer_key},
    consumer_secret     => $config->{consumer_secret},
    access_token        => $config->{access_token},
    access_token_secret => $config->{access_token_secret},
    ssl                 => 1,
);

$exobrain->watch_loop(
    class => 'Intent::Tweet',
    then => sub {
        my $event = shift;
        $twitter->update($event->tweet);
    },
);

__END__

=pod

=head1 NAME

twitter-send - Sink process for exobrain/twitter

=head1 VERSION

version 0.06

=head1 AUTHOR

Paul Fenwick <pjf@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Paul Fenwick.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut