diff --git a/code/public/Pushover-test.pl b/code/public/Pushover-test.pl new file mode 100644 index 000000000..76f77c402 --- /dev/null +++ b/code/public/Pushover-test.pl @@ -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}); + } +} + diff --git a/lib/Pushover.pm b/lib/Pushover.pm index 4e9e1b8ec..a7301ce1a 100644 --- a/lib/Pushover.pm +++ b/lib/Pushover.pm @@ -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', @@ -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 @@ -88,14 +89,19 @@ Creates a new Pushover object. The parameter hash is optional. Defaults will be B - 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_"