""" 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 from chatbot import sendMessage from config import today, yesterday #! This function reads the response text-file def getResponseText(): with open('responses/bookingResponse.txt', 'r') as file: data = file.read() return data responseText = getResponseText() lastExecutionDate = lastExecutionDate_Load() chatTextIntro = f"Hey! ich wurde Heute ({today}) ausgeführt und suche für Gestern({yesterday}) nach neuen Kontakten auf der booking@" chatTextNone = f"Ich habe keine neuen Kontakte gefunden" 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)) else: sendMessage(chatTextNone) else: jsonCreateContacts() print("I created the Contacts, run me again.")