From 443bf49d248bd989df57eb0bfe75291561e1b8b9 Mon Sep 17 00:00:00 2001 From: Lysandro Carioca Date: Tue, 2 Jan 2024 18:33:35 -0500 Subject: [PATCH] Add support for notifications on NTFY --- config.ini.example | 2 ++ visa.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/config.ini.example b/config.ini.example index 4aca303..35a872b 100644 --- a/config.ini.example +++ b/config.ini.example @@ -21,6 +21,8 @@ HUB_ADDRESS = http://localhost:9515/wd/hub ; Get push notifications via https://pushover.net/ (optional) PUSHOVER_TOKEN = PUSHOVER_USER = +; Get push notifications via ntfy (optional) +PUSH_NTFY_TOPIC = ; Get email notifications via https://sendgrid.com/ (optional) SENDGRID_API_KEY = ; Get push notifications via PERSONAL WEBSITE http://yoursite.com (Optional) diff --git a/visa.py b/visa.py index e0fda82..e970295 100644 --- a/visa.py +++ b/visa.py @@ -42,6 +42,8 @@ # Get push notifications via https://pushover.net/ (Optional) PUSHOVER_TOKEN = config['NOTIFICATION']['PUSHOVER_TOKEN'] PUSHOVER_USER = config['NOTIFICATION']['PUSHOVER_USER'] +# Get push notifications via https://docs.ntfy.sh/ (Optional) +PUSH_NTFY_TOPIC = config['NOTIFICATION']['PUSH_NTFY_TOPIC'] # Get push notifications via PERSONAL WEBSITE http://yoursite.com (Optional) PERSONAL_SITE_USER = config['NOTIFICATION']['PERSONAL_SITE_USER'] PERSONAL_SITE_PASS = config['NOTIFICATION']['PERSONAL_SITE_PASS'] @@ -102,6 +104,9 @@ def send_notification(title, msg): "message": msg } requests.post(url, data) + if PUSH_NTFY_TOPIC: + url = f"https://ntfy.sh/{PUSH_NTFY_TOPIC}" + requests.post(url, data=msg.encode(encoding='utf-8')) if PERSONAL_SITE_USER: url = PERSONAL_PUSHER_URL data = {