admin notifications erweitert

This commit is contained in:
2026-04-04 15:37:22 +02:00
parent c0b8355301
commit ec74a66862

View File

@@ -6,6 +6,7 @@ import time
import sys
import logging
import re
import requests
from datetime import datetime
from dotenv import load_dotenv
@@ -16,6 +17,19 @@ DEBUG_LOG = os.getenv("DEBUG_LOG", "false").lower() == "true"
LOG_LEVEL = logging.DEBUG if DEBUG_LOG else logging.INFO
MY_PID = os.getpid()
def sende_admin(titel, nachricht):
admin_url = f"{os.getenv('NTFY_BASE')}/polit-scraper-admin"
try:
requests.post(
admin_url,
data=nachricht.encode("utf-8"),
headers={"Title": titel.encode("utf-8"), "Priority": "4"},
auth=(os.getenv("ADMIN_USER"), os.getenv("ADMIN_PW")),
timeout=5
)
except: pass
logging.basicConfig(
level=LOG_LEVEL,
format='%(asctime)s [%(levelname)s] [%(process)d] %(message)s',