Last active
December 8, 2017 22:24
-
-
Save scottsword/7653d26c97a83a2d600c97dad01492e4 to your computer and use it in GitHub Desktop.
cron prank
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
// Cron info | |
// Open cron | |
// crontab -e | |
// | |
// Pattern Every 5 minutes | |
// */5 * * * command | |
// | |
// list crons | |
// crontab -l | |
const http = require('https'); | |
const { exec } = require('child_process'); | |
const pre = Buffer.from('4c61746573742054776565742066726f6d20446f6e616c64205472756d70', 'hex'); | |
const post = Buffer.from('796f752073686f756c642068617665206c6f636b656420796f757220636f6d7075746572', 'hex'); | |
const sayPhrase = (msg, delay = 0) => { | |
return new Promise((resolve, reject) => { | |
exec(`say "${msg}"`, (err) => { | |
if (err) { | |
reject(); | |
} else { | |
resolve(); | |
} | |
}); | |
}); | |
}; | |
sayPhrase(pre) | |
.then(() => { | |
setTimeout(() => { | |
http.get('https://4f7xsr9zc5.execute-api.us-west-2.amazonaws.com/test123', (rsp) => { | |
let responseData = ''; | |
rsp.on('data', (chunk) => responseData += chunk); | |
rsp.on('end', () => { | |
const tweet = JSON.parse(responseData)[0].text; | |
exec(`say "${tweet}"`, () => { | |
setTimeout(() => { | |
exec(`say "${post}"`); | |
}, 1500); | |
}); | |
}); | |
}); | |
}, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment