Add a little bit of functionality.... in theory it should be able to run.... in theory, not yet tested

This commit is contained in:
2020-05-24 12:46:58 +02:00
parent ca4f0ab6ee
commit a05456cda4
4 changed files with 71 additions and 0 deletions
+22
View File
@@ -1,6 +1,12 @@
import email
import imaplib
import time
from SubjectHandler import SubjectHandler
SubHandler = SubjectHandler()
mail_addr = None
mail_pwd = None
"""
CONFIG SECTION
@@ -8,6 +14,13 @@ CONFIG SECTION
imap_port = 993
imap_server = "imap.gmail.com"
mail_domain = "gmail.com"
mail_time_delta = 30 # in seconds
secrets_file = "./secrets.txt"
# add all nodes here in this(↓) pattern
# SubHandler += SubjectHandler.Node(regex, function)
SubHandler += SubjectHandler.Node("Test[0-9]*", lambda x: print(str(x)))
"""
END OF CONFIG SECTION
@@ -20,6 +33,8 @@ def import_secrets(file):
:param file: path to file: content is '[MAIL]\n[PWD]'
:return: secrets, that can be saved to global variables
"""
global mail_addr
global mail_pwd
with open(file) as f:
mail_addr = f.readline()
mail_pwd = f.readline()
@@ -53,5 +68,12 @@ def mail_handling():
return messages
import_secrets(secrets_file)
while True:
SubHandler.run(mail_handling())
time.sleep(mail_time_delta)