Эх сурвалжийг харах

actually fixed ntfy config

zehe 3 сар өмнө
parent
commit
f7184f7761
2 өөрчлөгдсөн 14 нэмэгдсэн , 6 устгасан
  1. 13 5
      main.py
  2. 1 1
      requirements.txt

+ 13 - 5
main.py

@@ -67,23 +67,31 @@ def send_ntfy_notification(backends: List[str], message: str, title: str = None)
         try:
         try:
             # Import ntfy here to avoid import issues during startup
             # Import ntfy here to avoid import issues during startup
             import ntfy
             import ntfy
+            from ntfy.config import load_config
 
 
             # Load the ntfy config file
             # Load the ntfy config file
-            ntfy_config = ntfy.config.load_config(config.ntfy_config_path)
+            ntfy_config = load_config(config.ntfy_config_path)
+
+            ntfy_config["backends"] = [backend]
 
 
             # Send notification using the backend name from our config file
             # Send notification using the backend name from our config file
             if title:
             if title:
-                ntfy.notify(message, title=title, backend=backend, config=ntfy_config)
+                ret = ntfy.notify(message, title=title, config=ntfy_config)
             else:
             else:
-                ntfy.notify(message, backend=backend, config=ntfy_config)
+                ret = ntfy.notify(message, config=ntfy_config, title="Note")
 
 
-            successful_backends.append(backend)
-            logger.info(f"Notification sent successfully via {backend}")
+            if ret == 0:
+                successful_backends.append(backend)
+                logger.info(f"Notification sent successfully via {backend}")
+            else:
+                logger.error(f"Failed to send notification via {backend}")
+                raise Exception(f"Failed to send notification via {backend}")
 
 
         except ImportError:
         except ImportError:
             logger.error(f"ntfy package not available for backend {backend}")
             logger.error(f"ntfy package not available for backend {backend}")
         except Exception as e:
         except Exception as e:
             logger.error(f"Failed to send notification to {backend}: {str(e)}")
             logger.error(f"Failed to send notification to {backend}: {str(e)}")
+            raise
 
 
     success = len(successful_backends) > 0
     success = len(successful_backends) > 0
     return success, successful_backends
     return success, successful_backends

+ 1 - 1
requirements.txt

@@ -1,4 +1,4 @@
 flask>=2.0,<3.0
 flask>=2.0,<3.0
-ntfy>=2.7.0
+ntfy[matrix,telegram]>=2.7.0
 pyyaml>=6.0
 pyyaml>=6.0
 gunicorn>=21.0
 gunicorn>=21.0