Created
April 16, 2014 21:45
-
-
Save antonyfairport/10936316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// Set your app and user token here. Note that you can, on the | |
// PushOver site, create delivery groups so you can deliver a single | |
// notice to multiple users. The delivery group key is then used as | |
// the user key. | |
string APP_TOKEN = "<paste your app token here>"; | |
string APP_USER = "<paste your user token here>"; | |
////////////////////////////////////////////////////////////////////// | |
// Constants for the PushOver parameters. | |
string PUSHOVER_DEVICE = "device"; | |
string PUSHOVER_TITLE = "title"; | |
string PUSHOVER_URL = "url"; | |
string PUSHOVER_URL_TITLE = "url_title"; | |
string PUSHOVER_PRIORITY = "priority"; | |
string PUSHOVER_TIMESTAMP = "timestamp"; | |
string PUSHOVER_SOUND = "sound"; | |
////////////////////////////////////////////////////////////////////// | |
// Send a push message via PushOver. | |
key SendPushMessage( string sToken, string sUser, string sMessage, list lExtra ) | |
{ | |
// Main part of the data. | |
string sData = "token=" + APP_TOKEN + | |
"&user=" + APP_USER + | |
"&message=" + llEscapeURL( sMessage ); | |
// Add any optional parameters. | |
integer iExtra = llGetListLength( lExtra ); | |
integer i; | |
for ( i = 0; i < iExtra; i += 2 ) | |
{ | |
sData += "&" + llList2String( lExtra, i ) + "=" + | |
llEscapeURL( llList2String( lExtra, i + 1 ) ); | |
} | |
// Send the push message. | |
return llHTTPRequest( "https://api.pushover.net/1/messages.json", [ | |
HTTP_METHOD, "POST", | |
HTTP_MIMETYPE, "application/x-www-form-urlencoded" | |
], sData ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Default state. | |
default | |
{ | |
///////////////////////////////////////////////////////////////// | |
// Respond to touch. | |
touch_start( integer _ ) | |
{ | |
SendPushMessage( APP_TOKEN, APP_USER, | |
"I was just touched by " + llDetectedName( 0 ) + ".\n\n" + | |
"They were " + (string) llVecDist( llDetectedPos( 0 ), llGetPos() ) + "m away.", [ | |
PUSHOVER_TITLE, "Touch alert!", | |
PUSHOVER_SOUND, "bugle", | |
PUSHOVER_URL, "http://antonyfairport.blogspot.com/", | |
PUSHOVER_URL_TITLE, "Antony Fairport" | |
] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment