admin notifications erweitert
This commit is contained in:
14
analyzer.py
14
analyzer.py
@@ -6,6 +6,7 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import requests
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dotenv import load_dotenv
|
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
|
LOG_LEVEL = logging.DEBUG if DEBUG_LOG else logging.INFO
|
||||||
MY_PID = os.getpid()
|
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(
|
logging.basicConfig(
|
||||||
level=LOG_LEVEL,
|
level=LOG_LEVEL,
|
||||||
format='%(asctime)s [%(levelname)s] [%(process)d] %(message)s',
|
format='%(asctime)s [%(levelname)s] [%(process)d] %(message)s',
|
||||||
|
|||||||
Reference in New Issue
Block a user