forked from NARKOZ/hacker-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkumar_asshole.py
executable file
·44 lines (29 loc) · 997 Bytes
/
kumar_asshole.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import gmail
import yagmail
from hackerutils import get_dotenv
dotenv = get_dotenv()
GMAIL_USERNAME = dotenv['GMAIL_USERNAME']
GMAIL_PASSWORD = dotenv['GMAIL_PASSWORD']
KUMAR_EMAIL = '[email protected]'
KEYWORDS_REGEX = re.compile(r'sorry|help|wrong', re.IGNORECASE)
REPLY_BODY = "No problem. I've fixed it. \n\n Please be careful next time."
yagmail.register(GMAIL_USERNAME, GMAIL_PASSWORD)
def send_reply(subject):
yag = yagmail.SMTP(GMAIL_USERNAME)
yag.send(
to=KUMAR_EMAIL,
subject='RE: {}'.format(subject),
contents=REPLY_BODY,
)
def main():
g = gmail.login(GMAIL_USERNAME, GMAIL_PASSWORD)
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.
mail.add_label('Database fixes')
send_reply(mail.subject)
if __name__ == '__main__':
main()