-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (22 loc) · 940 Bytes
/
utils.py
File metadata and controls
24 lines (22 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from urllib.parse import quote
from datetime import datetime
import requests
import config
def normalize_isoformat(iso_string):
"""Normalize an ISO 8601 string to ensure compatibility with fromisoformat."""
if 'Z' in iso_string:
iso_string = iso_string.replace("Z", "+00:00")
if '.' in iso_string:
parts = iso_string.split('.')
parts[1] = (parts[1] + "000000")[:6] # Pad fractional seconds to six digits
iso_string = '.'.join(parts)
return iso_string
def send_discord_notification(content):
"""Send a notification to Discord."""
try:
webhook_url = config.DISCORD_WEBHOOK_URL
response = requests.post(webhook_url, json={"content": content})
if response.status_code != 200:
print(f"Failed to send Discord notification: {response.status_code} - {response.text}")
except Exception as e:
print(f"Error sending Discord notification: {e}")