File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments