fisk/core/lib/notify.py

24 lines
492 B
Python

import requests
from django.conf import settings
from core.util import logs
NTFY_URL = "https://ntfy.sh"
log = logs.get_logger(__name__)
def sendmsg(msg, title=None, priority=None, tags=None):
headers = {"Title": "Fisk"}
if title:
headers["Title"] = title
if priority:
headers["Priority"] = priority
if tags:
headers["Tags"] = tags
requests.post(
f"{NTFY_URL}/{settings.NOTIFY_TOPIC}",
data=msg,
headers=headers,
)