- Clone https://github.com/sanzgiri/dash-sms (just for the dependencies)
- Run
npm install
- Find your cell provider and sub in the numbers you want to text: https://20somethingfinance.com/how-to-send-text-messages-sms-via-email-for-free/
- Modify the config.json (you will need to remove all comments)
- Run the script by typing this command in shell. This will run it in the background:
node /root/dash-sms/index.js > stout.txt 2> stderr.txt &
Otherwise just runnode index.js
Last active
April 28, 2017 21:39
-
-
Save dovy/3407588e06ffc7f582cd5eca6b225275 to your computer and use it in GitHub Desktop.
Sickie button
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
{ | |
"button": { | |
"id": "" // Your button ID | |
}, | |
"gmail": { | |
"user": "", // Gmail user/email | |
"pass": "" // Gmail pass | |
}, | |
"message": { | |
"from": "From Message", // Whatever you want the from to say | |
"to": [ "" ], // Put in as many "emails" as you want | |
"subject": "Sickie Button Pressed!" | |
} | |
} |
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
#! /usr/bin/env node | |
const config = require('./config.json'); | |
const dash_button = require('node-dash-button'); | |
const nodemailer = require('nodemailer'); | |
// TODO: accept and register an array of button MACs | |
const dash = dash_button(config.button.id); | |
const util = require('util'); | |
const _ = require('lodash'); | |
const when = require('when'); | |
// create reusable transporter object using the default SMTP transport | |
let transporter = nodemailer.createTransport({ | |
service: 'gmail', | |
auth: { | |
user: config.gmail.user, | |
pass: config.gmail.pass | |
} | |
}); | |
// setup email data with unicode symbols | |
let mailOptions = { | |
from: config.message.from, // sender address | |
to: config.message.to.toString(), // list of receivers | |
subject: config.message.subject, // Subject line | |
text: new Date().toISOString(). | |
replace(/T/, ' '). // replace T with a space | |
replace(/\..+/, '') // delete the dot and everything after | |
}; | |
console.log('waiting for dash button to be pressed...'); | |
dash.on('detected', () => { | |
console.log('Dash button detected!'); | |
transporter.sendMail(mailOptions, (error, info) => { | |
if (error) { | |
return console.log(error); | |
} | |
console.log('Message %s sent: %s', info.messageId, info.response); | |
}); | |
// for now we can ignore the promise as it handles any logging and we've no need to care about when it resolves or rejects | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment