Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions automail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#find documentation for ezgmail module at https://pypi.org/project/EZGmail/
#simple simon says module that interacts with google API to read the subject line of an email and respond to "Simon says:"
#DO NOT FORGET TO ADD CREDENTIALS.JSON AND TOKEN.JSON TO .GITIGNORE!!!

import ezgmail, re, time

check = True
while check:
recThreads = ezgmail.recent()
findEmail = re.compile(r'<(.*)@(.*)>')
i = 0
for msg in recThreads:
subEval = recThreads[i].messages[0].subject.split(' ')
sender = recThreads[i].messages[0].sender
if subEval[0] == 'Simon' and subEval[1] == 'says:':
subEval.remove('Simon')
subEval.remove('says:')
replyAddress = findEmail.search(sender).group(0).replace('<','').replace('>','')
replyContent = 'I am now doing ' + ' '.join(subEval)
ezgmail.send(replyAddress, replyContent, replyContent)
ezgmail._trash(recThreads[i])
if subEval[0] == 'ENDTASK': #remote kill command
check = False
i += 1
time.sleep(60) #change check frquency; default every minute