From 5a280b040d2c23fa0d3e8e9b0688eb3386c66b4f Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 9 Jan 2023 13:05:35 +0100 Subject: [PATCH] an sich fertig --- autoResponder.py | 18 +++++++++--------- chatbot.py | 2 +- contacts.json | 4 +++- mail_util.py | 6 +++++- sender2.sh | 7 +++++++ 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 sender2.sh diff --git a/autoResponder.py b/autoResponder.py index 9659b16..c5f3d99 100644 --- a/autoResponder.py +++ b/autoResponder.py @@ -1,5 +1,5 @@ import codecs -from mail_util import checkFor_unkownContacts, sendEmails +from mail_util import checkFor_unkownContacts, sendEmails, jsonAddContacts from chatbot import sendMessage from config import today, yesterday @@ -10,20 +10,20 @@ def getResponseText(): contacts = checkFor_unkownContacts() -testContacts = [] -testContacts.append('e.neug@icloud.com') +contacts.append('e.neug@icloud.com') responseText = getResponseText() print(responseText) -sendEmails(responseText, testContacts) - -chatTextIntro = f"Hey! ich wurde Heute ({today}) ausgeführt und suche für Gestern({yesterday}) nach neuen Kontakten" -chatTextAmmount = f"Ich habe {len(testContacts)} neue Kontakte gefunden" +sendEmails(responseText, contacts) +jsonAddContacts(contacts) +chatTextIntro = f"Hey! ich wurde Heute ({today}) ausgeführt und suche für Gestern({yesterday}) nach neuen Kontakten auf der booking@" +chatTextAmmount = f"Ich habe {len(contacts)} neue Kontakte gefunden und automatisch geschrieben" chatTextNone = f"Ich habe keine neuen Kontakte gefunden" sendMessage(chatTextIntro) -if len(testContacts) > 0: +if len(contacts) > 0: sendMessage(chatTextAmmount) - for c in testContacts: + for c in contacts: sendMessage(c) + else: sendMessage(chatTextNone) diff --git a/chatbot.py b/chatbot.py index ce381e2..2322a24 100644 --- a/chatbot.py +++ b/chatbot.py @@ -1,5 +1,5 @@ import subprocess def sendMessage(message): - subprocess.call(['sh','./sender.sh', message]) + subprocess.call(['sh','./sender2.sh', message]) diff --git a/contacts.json b/contacts.json index 684808c..1e371eb 100644 --- a/contacts.json +++ b/contacts.json @@ -696,5 +696,7 @@ "fadingsunday@gmail.com", "f.br82@icloud.com", "info@snippetupperlaser.com", - "plasmajet@gmx.net" + "plasmajet@gmx.net", + "nina_vietzke@hotmail.de", + "e.neug@icloud.com" ] \ No newline at end of file diff --git a/mail_util.py b/mail_util.py index a1788f8..4544ccd 100644 --- a/mail_util.py +++ b/mail_util.py @@ -70,12 +70,16 @@ def getContacts(search): return newContacts def jsonAddContacts(contacts): + knowContacts = loadKnownContacts() + for c in contacts: + knowContacts.append(c) + if os.path.isfile('./contacts.json'): print('Deleting Contacts') os.remove('contacts.json') with open('contacts.json', 'w', encoding='utf-8') as f: - json.dump(contacts, f, ensure_ascii=False, indent=4) + json.dump(knowContacts, f, ensure_ascii=False, indent=4) def jsonCreateContacts(): # Connect to inbox diff --git a/sender2.sh b/sender2.sh new file mode 100644 index 0000000..5d6a9bd --- /dev/null +++ b/sender2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +API=https://cloud1.sommerschein.de/ocs/v1.php/apps/spreed/api/v1/chat/onxr79pz +LOGIN="Maily:Gtjik-qP48b-y62bC-r8yos-qJT9Y" +MESSAGE=$1 + +curl -d '{"token":"onxr79pz", "message":"'"$MESSAGE"'"}' -H "Content-Type: application/json" -H "Accept:application/json" -H "OCS-APIRequest:true" -u "$LOGIN" $API 2> /dev/null | > /dev/null \ No newline at end of file