Kleies Utility programm für unsere Email verwaltung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB

2 years ago
"""
This file will run Maily.
It will try to scan for new Contacts and if it found any it will write them an email.
Also Maily will inform us about any written emails via Nextcloud-Talk
"""
import os
from mail_util import checkFor_unkownContacts, sendEmails, jsonAddContacts, lastExecutionDate_Load, jsonCreateContacts, lastExecutionDate_Safe
2 years ago
from chatbot import sendMessage
from config import today, yesterday
2 years ago
#! This function reads the response text-file
def getResponseText():
with open('responses/bookingResponse.txt', 'r') as file:
data = file.read()
return data
responseText = getResponseText()
2 years ago
lastExecutionDate = lastExecutionDate_Load()
2 years ago
chatTextIntro = f"Hey! ich wurde Heute ({today}) ausgeführt und suche für Gestern({yesterday}) nach neuen Kontakten auf der booking@"
2 years ago
chatTextNone = f"Ich habe keine neuen Kontakte gefunden"
2 years ago
chatTextNew = f"Hey! Ich wurde Heute ({today}) ausgeführt. Ich suche nach nicht beantworteten Emails, seit meiner letzten ausführung ({lastExecutionDate})"
if os.path.isfile('./contacts.json'):
contacts = checkFor_unkownContacts()
sendMessage(chatTextNew)
if len(contacts) > 0:
chatTextAmmount = f"Ich habe {len(contacts)} unbeantwortete Emails gefunden und automatisch geantwortet"
sendMessage(chatTextAmmount)
for c in contacts:
sendMessage(c)
sendEmails(responseText, contacts)
jsonAddContacts(contacts)
lastExecutionDate_Safe(str(today))
2 years ago
2 years ago
2 years ago
else:
sendMessage(chatTextNone)
2 years ago
else:
2 years ago
jsonCreateContacts()
print("I created the Contacts, run me again.")