/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
automail.py
25 строк
1 KB
Killian Brunswick
add security warning comment to automail.py
15 апр 2023, 20:51
15 апр 2023, 20:51
104c79f
Код
Авторство
О чём код?
#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