Spaces:
Sleeping
Sleeping
Download integrations/slack_notifier.py from anil988/SentinelFin-AI-Backend: direct link, hf CLI and curl.
- Browser
- Download file 819 Bytes
-
https://huggingface.co/spaces/anil988/SentinelFin-AI-Backend/resolve/main/integrations/slack_notifier.py
- Command line
-
hf download hf://spaces/anil988/SentinelFin-AI-Backend/integrations/slack_notifier.py
-
curl -L -o slack_notifier.py https://huggingface.co/spaces/anil988/SentinelFin-AI-Backend/resolve/main/integrations/slack_notifier.py
819 Bytes
| import os | |
| import requests | |
| import json | |
| class SlackNotifier: | |
| """Real Slack Notifier for sending alerts to compliance channels.""" | |
| def send_alert(message: str) -> bool: | |
| """Send a real Slack message via Webhook.""" | |
| webhook_url = os.getenv("SLACK_WEBHOOK_URL") | |
| if not webhook_url: | |
| print(f"[SLACK MOCK] Webhook URL not set. Message: {message}") | |
| return True | |
| print(f"[SLACK] Dispatching real alert to workspace...") | |
| try: | |
| payload = {"text": message} | |
| response = requests.post(webhook_url, json=payload) | |
| response.raise_for_status() | |
| return True | |
| except Exception as e: | |
| print(f"[SLACK ERROR] Failed to send message: {e}") | |
| return False | |