Download src/protocol/security/alert_webhook.py from TTOPM/belel-protocol: direct link, hf CLI and curl.
- Browser
- Download file 599 Bytes
-
https://huggingface.co/TTOPM/belel-protocol/resolve/main/src/protocol/security/alert_webhook.py
- Command line
-
hf download hf://TTOPM/belel-protocol/src/protocol/security/alert_webhook.py
-
curl -L -o alert_webhook.py https://huggingface.co/TTOPM/belel-protocol/resolve/main/src/protocol/security/alert_webhook.py
599 Bytes
| # src/protocol/security/alert_webhook.py | |
| import requests | |
| from datetime import datetime | |
| class WebhookAlerter: | |
| def __init__(self, webhook_url: str): | |
| self.webhook_url = webhook_url | |
| def send_alert(self, title: str, message: str): | |
| payload = { | |
| "content": f"🚨 **{title}**\n🕒 {datetime.now().isoformat()}\n```\n{message}\n```" | |
| } | |
| try: | |
| response = requests.post(self.webhook_url, json=payload) | |
| response.raise_for_status() | |
| except Exception as e: | |
| print(f"[ALERT FAILURE] Could not send webhook alert: {e}") | |