2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-28 21:27:54 +00:00

log to stdout

This commit is contained in:
Nihad Abbasov 2015-11-25 22:09:41 +04:00
parent 12c4f2dcfd
commit f9321f0f07
2 changed files with 8 additions and 27 deletions

View File

@ -3,13 +3,6 @@
# Skip on weekends
exit if Time.now.saturday? || Time.now.sunday?
log_file_name = File.dirname(__FILE__) + '/logs/hangover.txt'
# Be sure that logs dir always exists
Dir.mkdir('logs') unless File.exists?(log_file_name)
LOG_FILE = File.open(log_file_name, 'a+')
# Exit early if sessions with my username are found
exit if `who -q`.include? ENV['USER']
@ -27,19 +20,18 @@ TWILIO_AUTH_TOKEN = ENV['TWILIO_AUTH_TOKEN']
my_number = '+xxx'
number_of_boss = '+xxx'
excuses = [
excuse = [
'Locked out',
'Pipes broke',
'Food poisoning',
'Not feeling well'
]
].sample
# Send a text message
@twilio.messages.create(
from: my_number, to: number_of_boss,
body: 'Gonna work from home. ' + excuses.sample
body: "Gonna work from home. #{excuse}"
)
# Log this
LOG_FILE.puts("Message sent at: #{Time.now}")
LOG_FILE.close
puts "Message sent at: #{Time.now} | Excuse: #{excuse}"

View File

@ -3,13 +3,6 @@
# Skip on weekends
exit if Time.now.saturday? || Time.now.sunday?
log_file_name = File.dirname(__FILE__) + '/logs/smack_my_bitch_up.txt'
# Be sure that logs dir always exists
Dir.mkdir('logs') unless File.exists?(log_file_name)
LOG_FILE = File.open(log_file_name, 'a+')
# Exit early if no sessions with my username are found
exit if `who -q`.include? ENV['USER']
@ -27,20 +20,16 @@ TWILIO_AUTH_TOKEN = ENV['TWILIO_AUTH_TOKEN']
my_number = '+xxx'
her_number = '+xxx'
reasons = [
reason = [
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again'
]
sample = reasons.sample
].sample
# Send a text message
@twilio.messages.create(
from: my_number, to: her_number, body: 'Late at work. ' + sample
from: my_number, to: her_number, body: "Late at work. #{reason}"
)
# Log this
LOG_FILE.puts("Message sent at: #{Time.now}")
LOG_FILE.puts("Reason: #{sample}")
LOG_FILE.close
puts "Message sent at: #{Time.now} | Reason: #{reason}"