Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync to hollie/master #2

Merged
merged 4 commits into from
Sep 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions code/public/Pushover-test.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Category=Pushover

# Sample code for sending Pushover notifications
# Brian Rudy (brudyNO@SPAMpraecogito.com)

# Pushover_token and Pushover_user must be defined in mh.private.ini

use Pushover;

$v_send_pushover_to_all = new Voice_Cmd 'Send pushover notification to [all,tusdroidrazrhd]';
my $push = new Pushover();


if ($state = said $v_send_pushover_to_all) {
if ($state eq "all") {
print_log "Sending Pushover notification to all devices";
$push->notify( "A low priority test message", { title => 'Test title', priority => -1 });
}
else {
print_log "Sending Pushover notification to $state";
$push->notify( "A low priority test message to $state", { title => 'Test title', priority => -1, device => $state});
}
}

24 changes: 15 additions & 9 deletions lib/Pushover.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Create a pushover instance in the .mht file, or in user code:

A user code file overriding parameters normally specified in mh.private.ini. All of the parameters are optional if properly configured in the ini file.

use Pushover;
my $push = new Pushover( {token => '1234qwer1234qewr1234qwer',
user => '2345wert2345wert2345qwer',
title => 'Home Notification',
Expand All @@ -36,7 +37,7 @@ Any of the parameters provided when initializing the Pushover instance may also
provided on the message send. They will be merged with and override the default
values provided on initialization. See the method documentation for below more details.

$push->send( "Some important message", { title => 'Security Alert', priority => 2 });
$push->notify( "Some important message", { title => 'Security Alert', priority => 2 });

=head2 DESCRIPTION

Expand Down Expand Up @@ -88,14 +89,19 @@ Creates a new Pushover object. The parameter hash is optional. Defaults will be

B<This must be excluded from the primary misterhouse loop, or the acknowledgment checking and duplicate message rate limiting will be lost>

my $push = Pushover->new( { priority => 0, # Set default Message priority, -1, 0, 1, 2
retry => 60, # Set default retry priority 2 notification every 60 seconds
expire => 3600, # Set default expration of the retry timer
title => "Some title", # Set default title for messages
token => "xxxx...", # Set the API Token
user => "xxxx...", # Set the target user or group id
speak => 1, # Enable or disable speak of notifications and acknowledgment
server => "...", # Override the Pushover server URL. Defaults to the public pushover server
my $push = Pushover->new( { priority => 0, # Set default Message priority, -1, 0, 1, 2
retry => 60, # Set default retry priority 2 notification every 60 seconds
expire => 3600, # Set default expration of the retry timer
title => "Some title", # Set default title for messages
token => "xxxx...", # Set the API Token
user => "xxxx...", # Set the target user or group id
device => "droid4", # Set the target device (leaving this unset goes to all devices)
url => "http://x..", # Set the URL
url_title => "A url", # Set the title for the URL
timestamp => "1331249662", # Set the timestamp
sound => "incoming", # Set the sound to be played
speak => 1, # Enable or disable speak of notifications and acknowledgment
server => "...", # Override the Pushover server URL. Defaults to the public pushover server
});

Any of these parameters may be specified in mh.private.ini by prefixing them with "Pushover_"
Expand Down