#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie;
use Exobrain;
use WebService::Pushover;

# PODNAME: pushover
# ABSTRACT: Send exobrain notify events to Pushover

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

$exobrain->notify("Starting $0",
    priority => -1,
);

$exobrain->watch_loop(
    class => 'Intent::Notify',
    then  => \&send_notify,
);

sub send_notify {
    my ($event) = @_;
    state $pushover = WebService::Pushover->new;
    
    $pushover->message(
        token    => $config->{api_token},
        user     => $config->{user_token},
        message  => $event->summary,
        priority => $event->priority || 0,
    );

    return;
}

__END__

=pod

=head1 NAME

pushover - Send exobrain notify events to Pushover

=head1 VERSION

version 0.05

=head1 AUTHOR

Paul Fenwick <pjf@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 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
