2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-22 18:37:10 +00:00
hacker-scripts/kumar_asshole.rb
2015-11-21 23:04:28 +04:00

31 lines
650 B
Ruby
Executable File

#!/usr/bin/env ruby
require 'dotenv'
require 'gmail'
Dotenv.load
GMAIL_USERNAME = ENV['GMAIL_USERNAME']
GMAIL_PASSWORD = ENV['GMAIL_PASSWORD']
gmail = Gmail.connect(username, password)
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 = reply_to(email.subject)
gmail.deliver(reply)
end
end
def reply_to(subject)
gmail.compose do
to "email@example.com"
subject "RE: #{subject}"
body "No problem. I've fixed it. \n\n Please be careful next time."
end
end