Skip to content

Commit d006970

Browse files
committed
Merge pull request NARKOZ#88 from kashyapakshay/master
NodeJS for hangover and smack_my_bitch_up
2 parents 4518052 + 7c9a8e9 commit d006970

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

nodejs/hangover.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env node
2+
3+
/* Before running:
4+
npm install twilio
5+
*/
6+
7+
var exec = require('child_process').exec;
8+
9+
var me = 'my_username';
10+
11+
exec("who -q", function(error, stdout, stderr) {
12+
13+
// Exit if sessions with my username are found
14+
if(stdout.indexOf(me) > -1)
15+
process.exit(1);
16+
17+
var TWILIO_ACCOUNT_SID = process.env['TWILIO_ACCOUNT_SID'];
18+
var TWILIO_AUTH_TOKEN = process.env['TWILIO_AUTH_TOKEN'];
19+
20+
// Phone numbers
21+
var MY_NUMBER = '+xxx';
22+
var BOSS_NUMBER = '+xxx';
23+
24+
// Excuses
25+
var excuses = [
26+
'Locked out',
27+
'Pipes broke',
28+
'Food poisoning',
29+
'Not feeling well'
30+
];
31+
32+
// Generate BS message
33+
var excuse = excuses[Math.floor(Math.random() * excuses.length)];
34+
var textMessage = 'Gonna work from home. ' + excuse;
35+
36+
var client = require('twilio')(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);
37+
38+
// Shoot text
39+
client.messages.create({
40+
body: textMessage,
41+
to: BOSS_NUMBER,
42+
from: MY_NUMBER
43+
}, function(error, message) {
44+
if(error)
45+
console.log('Failed to send SMS: ' + error.message);
46+
else {
47+
var currentdate = new Date();
48+
49+
console.log('Message sent at: '+ (currentdate.getMonth() + 1) + '/'
50+
+ currentdate.getDate() + '/'
51+
+ currentdate.getFullYear() + ' '
52+
+ currentdate.getHours() + ':'
53+
+ currentdate.getMinutes() + ':'
54+
+ currentdate.getSeconds() + '| Excuse: ' + excuse);
55+
}
56+
});
57+
});

nodejs/smack_my_bitch_up.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env node
2+
3+
/* Before running:
4+
npm install twilio
5+
*/
6+
7+
var exec = require('child_process').exec;
8+
9+
var me = 'my_username';
10+
11+
exec("who -q", function(error, stdout, stderr) {
12+
13+
// Exit if no sessions with my username are found
14+
if(stdout.indexOf(me) == -1)
15+
process.exit(1);
16+
17+
var TWILIO_ACCOUNT_SID = process.env['TWILIO_ACCOUNT_SID'];
18+
var TWILIO_AUTH_TOKEN = process.env['TWILIO_AUTH_TOKEN'];
19+
20+
// Phone numbers
21+
var MY_NUMBER = '+xxx';
22+
var HER_NUMBER = '+xxx';
23+
24+
// Reasons
25+
var reasons = [
26+
'Working hard',
27+
'Gotta ship this feature',
28+
'Someone fucked the system again'
29+
];
30+
31+
// Generate BS message
32+
var reason = reasons[Math.floor(Math.random() * reasons.length)];
33+
var textMessage = 'Late at work. ' + reason;
34+
35+
var client = require('twilio')(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);
36+
37+
// Shoot text
38+
client.messages.create({
39+
body: textMessage,
40+
to: HER_NUMBER,
41+
from: MY_NUMBER
42+
}, function(error, message) {
43+
if(error)
44+
console.log('Failed to send SMS: ' + error.message);
45+
else {
46+
var currentdate = new Date();
47+
48+
console.log('Message sent at: '+ (currentdate.getMonth() + 1) + '/'
49+
+ currentdate.getDate() + '/'
50+
+ currentdate.getFullYear() + ' '
51+
+ currentdate.getHours() + ':'
52+
+ currentdate.getMinutes() + ':'
53+
+ currentdate.getSeconds() + '| Excuse: ' + reason);
54+
}
55+
});
56+
});

0 commit comments

Comments
 (0)