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

fix ruby script

closes #53
This commit is contained in:
Nihad Abbasov 2015-11-27 22:01:08 +04:00
parent 136636071a
commit a1716b803f

View File

@ -14,8 +14,16 @@ kumars_email = 'kumar.a@example.com'
DB_NAME_REGEX = /\S+_staging/
KEYWORDS_REGEX = /sorry|help|wrong/i
def create_reply(subject)
gmail.compose do
to kumars_email
subject "RE: #{subject}"
body "No problem. I've fixed it. \n\n Please be careful next time."
end
end
gmail.inbox.find(:unread, from: kumars_email).each do |email|
if email.body[KEYWORDS_REGEX] && (db_name = email.body[DB_NAME_REGEX])
if email.body.raw_source[KEYWORDS_REGEX] && (db_name = email.body.raw_source[DB_NAME_REGEX])
backup_file = "/home/backups/databases/#{db_name}-" + (Date.today - 1).strftime('%Y%m%d') + '.gz'
abort 'ERROR: Backup file not found' unless File.exist?(backup_file)
@ -29,11 +37,3 @@ gmail.inbox.find(:unread, from: kumars_email).each do |email|
gmail.deliver(reply)
end
end
def create_reply(subject)
gmail.compose do
to kumars_email
subject "RE: #{subject}"
body "No problem. I've fixed it. \n\n Please be careful next time."
end
end