Skip to content

Commit 147ba68

Browse files
add automail.py
1 parent e3e1af2 commit 147ba68

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

automail.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#find documentation for ezgmail module at https://pypi.org/project/EZGmail/
2+
#simple simon says module that interacts with google API to read the subject line of an email and respond to "Simon says:"
3+
4+
import ezgmail, re, time
5+
6+
check = True
7+
while check:
8+
recThreads = ezgmail.recent()
9+
findEmail = re.compile(r'<(.*)@(.*)>')
10+
i = 0
11+
for msg in recThreads:
12+
subEval = recThreads[i].messages[0].subject.split(' ')
13+
sender = recThreads[i].messages[0].sender
14+
if subEval[0] == 'Simon' and subEval[1] == 'says:':
15+
subEval.remove('Simon')
16+
subEval.remove('says:')
17+
replyAddress = findEmail.search(sender).group(0).replace('<','').replace('>','')
18+
replyContent = 'I am now doing ' + ' '.join(subEval)
19+
ezgmail.send(replyAddress, replyContent, replyContent)
20+
ezgmail._trash(recThreads[i])
21+
if subEval[0] == 'ENDTASK': #remote kill command
22+
check = False
23+
i += 1
24+
time.sleep(60) #change check frquency; default every minute

0 commit comments

Comments
 (0)