The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;

use Getopt::Std;
use Exobrain::Bus;
use Exobrain::Config;
use Exobrain::Intent::HabitRPG;
use Data::Dumper;

# PODNAME: bee-habit
# ABSTRACT: Update HabitRPG events from Beeminder

use constant DEBUG => 1;

my $bus       = Exobrain::Bus->new( type => 'SUB' );
my $responder = Exobrain::Bus->new( type => 'PUB' );

my $config = Exobrain::Config->new;

# Habits are in the config file in 'bmndr-id = hrpg-uuid' pairs
my $hrpg_task = $config->{'Beeminder-Habits'};

while (my $event = $bus->get) {
    if ($event->source eq "BEEMINDER") {
        if (my $task = $hrpg_task->{ $event->data->{goal} }) {
            Exobrain::Intent::HabitRPG->new(
                task => $task,
                direction => 'up',
                public => 1,
            )->send_msg( $responder->_socket );
        }
    }
}

__END__

=pod

=head1 NAME

bee-habit - Update HabitRPG events from Beeminder

=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