diff options
| author | EnricoGuccii <partyka.003@proton.me> | 2026-01-10 22:43:36 +0100 |
|---|---|---|
| committer | EnricoGuccii <partyka.003@proton.me> | 2026-01-10 22:43:36 +0100 |
| commit | 6d7410e286ce0fde31f89185c095fe90e85597f3 (patch) | |
| tree | 5092c99d353382a71f00d8fe18d53b8073cf3f58 /src/netmonitor/back/notification_service.py | |
| parent | c2f5fbe7fb93ce420caf23c5c0e06144cf953bb8 (diff) | |
bloat removed
Diffstat (limited to 'src/netmonitor/back/notification_service.py')
| -rw-r--r-- | src/netmonitor/back/notification_service.py | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/netmonitor/back/notification_service.py b/src/netmonitor/back/notification_service.py deleted file mode 100644 index e347faf..0000000 --- a/src/netmonitor/back/notification_service.py +++ /dev/null @@ -1,49 +0,0 @@ -import json -import requests -from pathlib import Path - -CONFIG_FILE = Path("data/global_config.json") - -class NotificationService: - def __init__(self): - self.webhook_url = "" - self.load_config() - - def load_config(self): - if CONFIG_FILE.exists(): - try: - with open(CONFIG_FILE, "r") as f: - data = json.load(f) - self.webhook_url = data.get("discord_webhook_url", "") - except Exception as e: - print(f"Error loading notification config: {e}") - - def save_config(self, webhook_url: str): - self.webhook_url = webhook_url - - CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True) - try: - with open(CONFIG_FILE, "w") as f: - json.dump({ - "discord_webhook_url": self.webhook_url - }, f, indent=4) - return True - except Exception as e: - print(f"Error saving config: {e}") - return False - - def send_message(self, message: str) -> bool: - if not self.webhook_url: - return False - - payload = { - "content": message - } - try: - response = requests.post(self.webhook_url, json=payload, timeout=5) - return response.status_code in [200, 204] - except Exception as e: - print(f"Discord send error: {e}") - return False - -notification_service = NotificationService() |