Füge test_apprise.py für Verbindungstests hinzu
This commit is contained in:
99
test_apprise.py
Normal file
99
test_apprise.py
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Einfacher Test für Apprise Mattermost-Verbindung
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import apprise
|
||||||
|
|
||||||
|
# Lade .env Datei
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
def test_mattermost_connection():
|
||||||
|
"""Testet die Mattermost-Verbindung über Apprise"""
|
||||||
|
|
||||||
|
# Hole Apprise URL aus .env
|
||||||
|
apprise_url = os.getenv('APPRISE_URL')
|
||||||
|
|
||||||
|
if not apprise_url:
|
||||||
|
print("❌ APPRISE_URL nicht in .env gefunden!")
|
||||||
|
print("Bitte erstelle eine .env Datei mit deiner Apprise URL")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(f"🔗 Teste Apprise URL: {apprise_url}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Erstelle Apprise Objekt
|
||||||
|
apobj = apprise.Apprise()
|
||||||
|
|
||||||
|
# Füge die URL hinzu
|
||||||
|
apobj.add(apprise_url)
|
||||||
|
|
||||||
|
# Teste die Verbindung
|
||||||
|
print("📡 Sende Test-Nachricht...")
|
||||||
|
|
||||||
|
# Sende eine Test-Nachricht
|
||||||
|
result = apobj.notify(
|
||||||
|
title="🧪 TI-Status Test",
|
||||||
|
body="Dies ist eine Test-Nachricht von der TI-Status2Mattermost App.\n\n✅ Apprise-Verbindung funktioniert!",
|
||||||
|
body_format=apprise.NotifyFormat.MARKDOWN
|
||||||
|
)
|
||||||
|
|
||||||
|
if result:
|
||||||
|
print("✅ Test erfolgreich! Nachricht wurde gesendet.")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print("❌ Test fehlgeschlagen. Keine Nachricht gesendet.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Fehler beim Test: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def test_without_env():
|
||||||
|
"""Testet mit einer direkten Mattermost URL"""
|
||||||
|
|
||||||
|
print("\n🔧 Alternative: Teste mit direkter URL")
|
||||||
|
print("Beispiel für Mattermost Webhook:")
|
||||||
|
print("mattermost://username:password@mattermost.medisoftware.org/channel?webhook=your_webhook_id")
|
||||||
|
|
||||||
|
# Hier könntest du eine Test-URL direkt eingeben
|
||||||
|
test_url = input("Gib deine Apprise URL ein (oder Enter für Skip): ").strip()
|
||||||
|
|
||||||
|
if not test_url:
|
||||||
|
print("⏭️ Test übersprungen")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
apobj = apprise.Apprise()
|
||||||
|
apobj.add(test_url)
|
||||||
|
|
||||||
|
result = apobj.notify(
|
||||||
|
title="🧪 Direkter Test",
|
||||||
|
body="Direkter Apprise-Test erfolgreich!",
|
||||||
|
body_format=apprise.NotifyFormat.MARKDOWN
|
||||||
|
)
|
||||||
|
|
||||||
|
if result:
|
||||||
|
print("✅ Direkter Test erfolgreich!")
|
||||||
|
else:
|
||||||
|
print("❌ Direkter Test fehlgeschlagen")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Fehler beim direkten Test: {e}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print("🧪 Apprise Mattermost-Verbindungstest")
|
||||||
|
print("=" * 40)
|
||||||
|
|
||||||
|
# Test mit .env
|
||||||
|
success = test_mattermost_connection()
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
test_without_env()
|
||||||
|
|
||||||
|
print("\n📋 Nächste Schritte:")
|
||||||
|
print("1. Überprüfe deine .env Datei")
|
||||||
|
print("2. Stelle sicher, dass die Mattermost URL korrekt ist")
|
||||||
|
print("3. Teste das Hauptskript: python ti_status_checker.py")
|
Reference in New Issue
Block a user