From 012f07eff21168354554e6f4eacde691d072c10e Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 9 Jan 2023 09:14:31 +0100 Subject: [PATCH] sender.sh# Please enter the commit message for your changes. Lines starting --- chatbot.py | 20 ++------------------ mailParse.py | 5 +++-- sender.sh | 7 +++++++ 3 files changed, 12 insertions(+), 20 deletions(-) create mode 100755 sender.sh diff --git a/chatbot.py b/chatbot.py index b56d398..7162a41 100644 --- a/chatbot.py +++ b/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) \ No newline at end of file +subprocess.call(['sh','./sender.sh', 'Aus Python']) \ No newline at end of file diff --git a/mailParse.py b/mailParse.py index d612015..b20ea07 100644 --- a/mailParse.py +++ b/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)') diff --git a/sender.sh b/sender.sh new file mode 100755 index 0000000..21dbe4e --- /dev/null +++ b/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 \ No newline at end of file