Browse Source

sender.sh# Please enter the commit message for your changes. Lines starting

master
Eddie 2 years ago
parent
commit
012f07eff2
  1. 20
      chatbot.py
  2. 5
      mailParse.py
  3. 7
      sender.sh

20
chatbot.py

@ -1,19 +1,3 @@
import requests, os
from dotenv import load_dotenv
load_dotenv()
pw = os.getenv('BOT')
import subprocess
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'OCS-APIRequest': 'true',
}
data = '{"token": "xzntzmuh", "message": "test"}'
response = requests.post('https://cloud1.sommerschein.de/ocs/v2.php/apps/spreed/api/v1/chat/xzntzmuh', headers=headers, data=data, auth=('Maily', 'pw'))
print(response.content)
subprocess.call(['sh','./sender.sh', 'Aus Python'])

5
mailParse.py

@ -1,7 +1,8 @@
import imaplib, email, os
from dotenv import load_dotenv
complexSearch1 = "UNANSWERED SENTSINCE 01-Sep-2022"
searchUnawnsered = "UNANSWERED SENTSINCE 01-Sep-2022"
searchAll = 'ALL'
load_dotenv()
pw = os.getenv('PASSWORD')
@ -16,7 +17,7 @@ imap_server.select() # Default is `INBOX`
contacts = []
# Find all emails in inbox
_, message_numbers_raw = imap_server.search(None, complexSearch1)
_, message_numbers_raw = imap_server.search(None, searchAll)
for message_number in message_numbers_raw[0].split():
_, msg = imap_server.fetch(message_number, '(RFC822)')

7
sender.sh

@ -0,0 +1,7 @@
#!/bin/bash
API=https://cloud1.sommerschein.de/ocs/v1.php/apps/spreed/api/v1/chat/xzntzmuh
LOGIN="Maily:Gtjik-qP48b-y62bC-r8yos-qJT9Y"
MESSAGE=$1
curl -d '{"token":"xzntzmuh", "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