|
@@ -14,7 +14,7 @@ from bs4 import BeautifulSoup
|
|
from telegram.error import BadRequest
|
|
from telegram.error import BadRequest
|
|
from imap_tools import MailBox, AND, OR
|
|
from imap_tools import MailBox, AND, OR
|
|
|
|
|
|
-#-> for python 3.10, the dh key too small problem
|
|
|
|
|
|
+# -> for python >=3.10, the dh key too small problem
|
|
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
|
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
|
context.set_ciphers('DEFAULT@SECLEVEL=1')
|
|
context.set_ciphers('DEFAULT@SECLEVEL=1')
|
|
|
|
|
|
@@ -26,6 +26,11 @@ mailbox = MailBox(host=config['email']['host'], ssl_context=context)
|
|
mailbox2 = MailBox(host=config['email']['host'], ssl_context=context)
|
|
mailbox2 = MailBox(host=config['email']['host'], ssl_context=context)
|
|
mailbox3 = MailBox(host=config['email']['host'], ssl_context=context)
|
|
mailbox3 = MailBox(host=config['email']['host'], ssl_context=context)
|
|
|
|
|
|
|
|
+mailbox.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='Inbox')
|
|
|
|
+mailbox2.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='bank_events')
|
|
|
|
+mailbox3.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='API')
|
|
|
|
+
|
|
|
|
+
|
|
def pretty_exc():
|
|
def pretty_exc():
|
|
exc_type, _exc_obj, exc_tb = sys.exc_info()
|
|
exc_type, _exc_obj, exc_tb = sys.exc_info()
|
|
# fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
|
# fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
|
@@ -46,10 +51,10 @@ def mask2(msg, to_):
|
|
to_ in msg.subject])
|
|
to_ in msg.subject])
|
|
|
|
|
|
|
|
|
|
-def mail_alert(event):
|
|
|
|
|
|
+def mail_alert(event=None):
|
|
'''mail alert Inbox'''
|
|
'''mail alert Inbox'''
|
|
container = deque(maxlen=500)
|
|
container = deque(maxlen=500)
|
|
- mailbox.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='Inbox')
|
|
|
|
|
|
+ # mailbox.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='Inbox')
|
|
while not event.is_set():
|
|
while not event.is_set():
|
|
try:
|
|
try:
|
|
sleep(15)
|
|
sleep(15)
|
|
@@ -83,14 +88,16 @@ def mail_alert(event):
|
|
except Exception:
|
|
except Exception:
|
|
mailbox.logout()
|
|
mailbox.logout()
|
|
pretty_exc()
|
|
pretty_exc()
|
|
- break
|
|
|
|
|
|
+ # break
|
|
except Exception:
|
|
except Exception:
|
|
mailbox.logout()
|
|
mailbox.logout()
|
|
- break
|
|
|
|
|
|
+ # break
|
|
|
|
+ # finally:
|
|
|
|
+ # mailbox.logout()
|
|
|
|
|
|
-def mail_alert2(event):
|
|
|
|
|
|
+def mail_alert2(event=None):
|
|
container = deque(maxlen=500)
|
|
container = deque(maxlen=500)
|
|
- mailbox2.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='bank_events')
|
|
|
|
|
|
+ # mailbox2.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='bank_events')
|
|
while not event.is_set():
|
|
while not event.is_set():
|
|
try:
|
|
try:
|
|
sleep(15)
|
|
sleep(15)
|
|
@@ -123,16 +130,18 @@ def mail_alert2(event):
|
|
except Exception:
|
|
except Exception:
|
|
mailbox2.logout()
|
|
mailbox2.logout()
|
|
pretty_exc()
|
|
pretty_exc()
|
|
- break
|
|
|
|
|
|
+ # break
|
|
except Exception:
|
|
except Exception:
|
|
# pretty_exc()
|
|
# pretty_exc()
|
|
mailbox2.logout()
|
|
mailbox2.logout()
|
|
- break
|
|
|
|
|
|
+ # break
|
|
|
|
+ # finally:
|
|
|
|
+ # mailbox2.logout()
|
|
|
|
|
|
-def mail_alert3(event):
|
|
|
|
|
|
+def mail_alert3(event=None):
|
|
'''mail alert Inbox'''
|
|
'''mail alert Inbox'''
|
|
container = deque(maxlen=500)
|
|
container = deque(maxlen=500)
|
|
- mailbox3.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='API')
|
|
|
|
|
|
+ # mailbox3.login(config['email']['user'], keyring.get_password('yagmail', 'levente.marton@mzk.ro'), initial_folder='API')
|
|
while not event.is_set():
|
|
while not event.is_set():
|
|
try:
|
|
try:
|
|
sleep(15)
|
|
sleep(15)
|
|
@@ -166,10 +175,12 @@ def mail_alert3(event):
|
|
except Exception:
|
|
except Exception:
|
|
mailbox3.logout()
|
|
mailbox3.logout()
|
|
pretty_exc()
|
|
pretty_exc()
|
|
- break
|
|
|
|
|
|
+ # break
|
|
except Exception:
|
|
except Exception:
|
|
mailbox3.logout()
|
|
mailbox3.logout()
|
|
- break
|
|
|
|
|
|
+ # break
|
|
|
|
+ # finally:
|
|
|
|
+ # mailbox3.logout()
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|