File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-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
+ #DO NOT FORGET TO ADD CREDENTIALS.JSON AND TOKEN.JSON TO .GITIGNORE!!!
4
+
5
+ import ezgmail , re , time
6
+
7
+ check = True
8
+ while check :
9
+ recThreads = ezgmail .recent ()
10
+ findEmail = re .compile (r'<(.*)@(.*)>' )
11
+ i = 0
12
+ for msg in recThreads :
13
+ subEval = recThreads [i ].messages [0 ].subject .split (' ' )
14
+ sender = recThreads [i ].messages [0 ].sender
15
+ if subEval [0 ] == 'Simon' and subEval [1 ] == 'says:' :
16
+ subEval .remove ('Simon' )
17
+ subEval .remove ('says:' )
18
+ replyAddress = findEmail .search (sender ).group (0 ).replace ('<' ,'' ).replace ('>' ,'' )
19
+ replyContent = 'I am now doing ' + ' ' .join (subEval )
20
+ ezgmail .send (replyAddress , replyContent , replyContent )
21
+ ezgmail ._trash (recThreads [i ])
22
+ if subEval [0 ] == 'ENDTASK' : #remote kill command
23
+ check = False
24
+ i += 1
25
+ time .sleep (60 ) #change check frquency; default every minute
You can’t perform that action at this time.
0 commit comments