2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-23 19:07:33 +00:00
hacker-scripts/kumar_asshole.rb

31 lines
672 B
Ruby
Raw Normal View History

2015-11-21 23:04:28 +04:00
#!/usr/bin/env ruby
require 'dotenv'
require 'gmail'
Dotenv.load
GMAIL_USERNAME = ENV['GMAIL_USERNAME']
GMAIL_PASSWORD = ENV['GMAIL_PASSWORD']
2015-11-23 14:35:21 +02:00
gmail = Gmail.connect(GMAIL_USERNAME, GMAIL_PASSWORD)
2015-11-21 23:04:28 +04:00
KEYWORDS_REGEX = /sorry|help|wrong/i
gmail.inbox.find(:unread, from: 'kumar.a@example.com').each do |email|
if email.body[KEYWORDS_REGEX]
# Restore DB and send a reply
email.label('Database fixes')
reply = create_reply(email.subject)
2015-11-21 23:04:28 +04:00
gmail.deliver(reply)
end
end
def create_reply(subject)
2015-11-21 23:04:28 +04:00
gmail.compose do
to "kumar.a@example.com"
2015-11-21 23:04:28 +04:00
subject "RE: #{subject}"
body "No problem. I've fixed it. \n\n Please be careful next time."
end
end