Created
September 13, 2012 02:49
-
-
Save syed/3711525 to your computer and use it in GitHub Desktop.
This is a simple on[x] script that I wrote to remind my friend to bring tent, sleeping bag and anti leech powder for our trek
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
// Initializing variables | |
var message = "Tent + Sleeping bag le kar aana aur agar aapke paas " + | |
"anti leech hai woh jo powder etc woh be le kar aana"; | |
var contact = { name : "Dhiraj",phoneNumber : "+91123456789" } ; | |
var msg_time = new Date(2012,8,12,8,0,0,0); // Date(year, month, day, hours, minutes, seconds, milliseconds); | |
var msg_time_ms = msg_time.getTime(); | |
// End of variables initializing | |
console.log('Started script: Text a message ' + ' at ' + msg_time); | |
function sendTextMessage(){ | |
device.messaging.sendSms({ | |
to: contact.phoneNumber, | |
body: message | |
}, | |
function (err) { | |
if (err) { | |
console.error('Error sending text message: ' + JSON.stringify(err)); | |
} | |
} | |
); | |
console.log('Sent SMS to ' + contact.phoneNumber ); | |
} | |
// get the alarm every day at the given hou | |
device.scheduler.setTimer( | |
{ | |
name: 'messageTimer', | |
time: msg_time.getTime(), | |
repeat: false, | |
exact: true | |
}, | |
sendTextMessage); | |
console.log('Completed script: Text a message to y friends every ' + msg_time); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment