Browse Source

an sich fertig

master
Eddie 2 years ago
parent
commit
5a280b040d
  1. 18
      autoResponder.py
  2. 2
      chatbot.py
  3. 4
      contacts.json
  4. 6
      mail_util.py
  5. 7
      sender2.sh

18
autoResponder.py

@ -1,5 +1,5 @@
import codecs import codecs
from mail_util import checkFor_unkownContacts, sendEmails from mail_util import checkFor_unkownContacts, sendEmails, jsonAddContacts
from chatbot import sendMessage from chatbot import sendMessage
from config import today, yesterday from config import today, yesterday
@ -10,20 +10,20 @@ def getResponseText():
contacts = checkFor_unkownContacts() contacts = checkFor_unkownContacts()
testContacts = [] contacts.append('e.neug@icloud.com')
testContacts.append('e.neug@icloud.com')
responseText = getResponseText() responseText = getResponseText()
print(responseText) print(responseText)
sendEmails(responseText, testContacts) sendEmails(responseText, contacts)
jsonAddContacts(contacts)
chatTextIntro = f"Hey! ich wurde Heute ({today}) ausgeführt und suche für Gestern({yesterday}) nach neuen Kontakten" 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(testContacts)} neue Kontakte gefunden" chatTextAmmount = f"Ich habe {len(contacts)} neue Kontakte gefunden und automatisch geschrieben"
chatTextNone = f"Ich habe keine neuen Kontakte gefunden" chatTextNone = f"Ich habe keine neuen Kontakte gefunden"
sendMessage(chatTextIntro) sendMessage(chatTextIntro)
if len(testContacts) > 0: if len(contacts) > 0:
sendMessage(chatTextAmmount) sendMessage(chatTextAmmount)
for c in testContacts: for c in contacts:
sendMessage(c) sendMessage(c)
else: else:
sendMessage(chatTextNone) sendMessage(chatTextNone)

2
chatbot.py

@ -1,5 +1,5 @@
import subprocess import subprocess
def sendMessage(message): def sendMessage(message):
subprocess.call(['sh','./sender.sh', message]) subprocess.call(['sh','./sender2.sh', message])

4
contacts.json

@ -696,5 +696,7 @@
"fadingsunday@gmail.com", "fadingsunday@gmail.com",
"f.br82@icloud.com", "f.br82@icloud.com",
"info@snippetupperlaser.com", "info@snippetupperlaser.com",
"plasmajet@gmx.net" "plasmajet@gmx.net",
"nina_vietzke@hotmail.de",
"e.neug@icloud.com"
] ]

6
mail_util.py

@ -70,12 +70,16 @@ def getContacts(search):
return newContacts return newContacts
def jsonAddContacts(contacts): def jsonAddContacts(contacts):
knowContacts = loadKnownContacts()
for c in contacts:
knowContacts.append(c)
if os.path.isfile('./contacts.json'): if os.path.isfile('./contacts.json'):
print('Deleting Contacts') print('Deleting Contacts')
os.remove('contacts.json') os.remove('contacts.json')
with open('contacts.json', 'w', encoding='utf-8') as f: 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(): def jsonCreateContacts():
# Connect to inbox # Connect to inbox

7
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
Loading…
Cancel
Save