diff --git a/python3/kumar_asshole.py b/python3/kumar_asshole.py index c85155b..ffed43d 100755 --- a/python3/kumar_asshole.py +++ b/python3/kumar_asshole.py @@ -5,6 +5,7 @@ import gmail import yagmail +import os from hackerutils import get_dotenv @@ -16,6 +17,9 @@ KUMAR_EMAIL = 'kumar.a@example.com' KEYWORDS_REGEX = re.compile(r'sorry|help|wrong', re.IGNORECASE) +backup="~/PATH/backup.zip" +dbname="DBNAME" + REPLY_BODY = "No problem. I've fixed it. \n\n Please be careful next time." @@ -36,6 +40,7 @@ def main(): for mail in g.inbox().mail(unread=True, sender=KUMAR_EMAIL, prefetch=True): if KEYWORDS_REGEX.search(mail.body): # Restore DB and send a reply. + os.system('gunzip {} | psql {}'.format(backup,dbname)) mail.add_label('Database fixes') send_reply(mail.subject)