diff --git a/aastatus_to_webhook.py b/aastatus_to_webhook.py index 83ce9ba..79506c5 100644 --- a/aastatus_to_webhook.py +++ b/aastatus_to_webhook.py @@ -17,17 +17,11 @@ FEED_URL = "https://aastatus.net/atom.cgi" WEBHOOK_URL = "https://discord.com/api/webhooks/XXXXXXX" # Discord webhook URL STATE_FILE = Path("/tmp/aaisp_atom_state.json") -# Severity colors -COLOR_MINOR = 16763904 -COLOR_MSO = 16711680 -COLOR_PEW = 65535 -COLOR_DEFAULT = 3092790 - -# Status colors -COLOR_STATUS_OPEN = 0x3498DB # blue -COLOR_STATUS_CLOSED = 0x2ECC71 # green -COLOR_STATUS_UNKNOWN = 0x95A5A6 # grey - +# Event colors +COLOR_MINOR_OPEN = 0xFFFF00 # yellow +COLOR_MAJOR_OPEN = 0xFF0000 # red +COLOR_CLOSED = 0x2ECC71 # green +COLOR_UNKNOWN = 0x95A5A6 # grey ### STATE MANAGEMENT ### @@ -65,7 +59,6 @@ def get_first_valid_entry(feed_xml): atom_ns = "{http://www.w3.org/2005/Atom}" for entry in root.findall(f"{atom_ns}entry"): - id_elem = entry.find(f"{atom_ns}id") if id_elem is None: continue @@ -142,19 +135,14 @@ def html_to_markdown(html_content): ### COLOR LOGIC ### -def get_embed_color(severity): - return { - "Minor": COLOR_MINOR, - "MSO": COLOR_MSO, - "PEW": COLOR_PEW - }.get(severity, COLOR_DEFAULT) - - -def get_status_color(status): - return { - "Open": COLOR_STATUS_OPEN, - "Closed": COLOR_STATUS_CLOSED - }.get(status, COLOR_STATUS_UNKNOWN) +def get_event_color(status, severity): + if status == "Closed": + return COLOR_CLOSED + if status == "Open" and severity == "Minor": + return COLOR_MINOR_OPEN + if status == "Open" and severity in ("Major", "MSO", "PEW"): + return COLOR_MAJOR_OPEN + return COLOR_UNKNOWN ### DISCORD FORMAT ### @@ -167,10 +155,7 @@ def build_discord_payload(entry, change_type="New entry"): except Exception: updated_ts = entry["updated"] - # PRIORITY: Status color > Severity color - color = get_status_color(entry["status"]) - if color == COLOR_STATUS_UNKNOWN: - color = get_embed_color(entry["severity"]) + color = get_event_color(entry["status"], entry["severity"]) embed = { "title": f"{entry['title']} ({change_type})", @@ -224,21 +209,17 @@ def main(): if prev is None: must_post = True change_type = "New Incident Detected" - else: # Compare important fields if entry["status"] != prev.get("status"): must_post = True change_type = f"Status changed: {prev.get('status')} → {entry['status']}" - elif entry["severity"] != prev.get("severity"): must_post = True change_type = f"Severity changed: {prev.get('severity')} → {entry['severity']}" - elif entry["updated"] != prev.get("updated"): must_post = True change_type = "Feed updated" - elif entry["content"] != prev.get("content"): must_post = True change_type = "Content updated" @@ -260,4 +241,3 @@ def main(): if __name__ == "__main__": main() -