From 2eb5a45055b042c6ee10e3d21461a1f23c7d0ff3 Mon Sep 17 00:00:00 2001 From: fra9001 Date: Tue, 1 Dec 2015 17:01:35 +0100 Subject: [PATCH 1/2] coffeescript implementation, tested --- coffee/smack-my-bitch-up.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 coffee/smack-my-bitch-up.coffee diff --git a/coffee/smack-my-bitch-up.coffee b/coffee/smack-my-bitch-up.coffee new file mode 100644 index 0000000..9785f91 --- /dev/null +++ b/coffee/smack-my-bitch-up.coffee @@ -0,0 +1,23 @@ +sys = require 'util' +exec = require('child_process').exec + +usr = process.env.USER + +reasons = [ + 'Working hard', + 'Gotta ship this feature', + 'Someone fucked the system again' +] + +rand = (ary) -> + i = Math.floor Math.random() * ary.length + ary[i] + +child = exec 'whoami', (e, stdin) -> + if stdin.match new RegExp usr, 'i' + excuse = "Late at work. #{rand reasons}" + require('twilio')().sendSms + to: '+xxx' #her_num + from: '+xxx' #my_num + body: excuse + , (err) -> console.log if err then err else "EXCUSE: #{excuse}" \ No newline at end of file From 9c2e68d743467da3addd776d6f8199c5cc1150a0 Mon Sep 17 00:00:00 2001 From: fra9001 Date: Tue, 1 Dec 2015 17:03:23 +0100 Subject: [PATCH 2/2] modified test bash command --- coffee/smack-my-bitch-up.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coffee/smack-my-bitch-up.coffee b/coffee/smack-my-bitch-up.coffee index 9785f91..4a93d45 100644 --- a/coffee/smack-my-bitch-up.coffee +++ b/coffee/smack-my-bitch-up.coffee @@ -13,7 +13,7 @@ rand = (ary) -> i = Math.floor Math.random() * ary.length ary[i] -child = exec 'whoami', (e, stdin) -> +child = exec 'who -q', (e, stdin) -> if stdin.match new RegExp usr, 'i' excuse = "Late at work. #{rand reasons}" require('twilio')().sendSms