#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;
use POSIX qw(strftime);
use Getopt::Std;
use Exobrain;
use Data::Dumper;
# PODNAME: tweet-ping
# ABSTRACT: Respond to tweets with `#ping`
use constant DEBUG => 1;
my $exobrain = Exobrain->new;
my $config = $exobrain->config;
$exobrain->intent('Tweet',
tweet => "Ping debugger started",
);
$exobrain->watch_loop(
class => 'Measurement::Tweet',
debug => sub { say Dumper $_[0] },
filter => sub { grep { /^ping$/ } @{ $_->tags } },
then => \&acknowledge,
);
sub acknowledge {
my ($event, $text) = @_;
$text ||= "Ack";
say "Source from [" . $event->source . "]" if DEBUG;
my $user = $event->from;
my $time = time();
my $content = "@".$user.": $text";
say "Responding: $content" if DEBUG;
$event->exobrain->intent('Tweet',
tweet => $content,
)->send_msg;
return;
}
__END__
=pod
=head1 NAME
tweet-ping - Respond to tweets with `#ping`
=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