From cc3cadb748b640cb11dac9478bed82ab4c5512ed Mon Sep 17 00:00:00 2001 From: csd4ni3l Date: Wed, 17 Dec 2025 22:32:38 +0100 Subject: [PATCH] Add description overrides and all http.cat codes. Fix bot replying to another bot's mentions --- app.py | 5 ++++- constants.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 1348a2e..c60a579 100644 --- a/app.py +++ b/app.py @@ -244,6 +244,9 @@ def cat_fact_button(ack, respond): @app.event("app_mention") def mention(body, say): + if "bot_id" in body["event"]: + return + thread_ts = body['event']['ts'] say(text=WELCOME_MESSAGE, thread_ts=thread_ts) @@ -305,7 +308,7 @@ def message_handler(event, say, client, message): elif found_status_codes: status_code = int(found_status_codes[0]) say( - text=f"CAT {status_code} {http.HTTPStatus(status_code).phrase} :3", + text=f"CAT {status_code} {http.HTTPStatus(status_code).phrase if not status_code in description_overrides else description_overrides[status_code]} :3", blocks=generate_httpcat_blocks(status_code), thread_ts=ts ) diff --git a/constants.py b/constants.py index b5ac504..120daa8 100644 --- a/constants.py +++ b/constants.py @@ -30,15 +30,56 @@ I'm here to help with coding and cat things! >:3 Purr~ I like solving problems a http_cat_codes = [ 100, 101, 102, 103, - 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, + 200, 201, 202, 203, 204, 205, 206, 207, 208, + 214, + 226, 300, 301, 302, 303, 304, 305, 307, 308, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, + 419, + 420, 421, 422, 423, 424, 425, 426, 428, 429, 431, + 444, + 450, 451, - 500, 501, 502, 503, 504, 506, 507, 508, 510, 511 + 495, + 496, + 497, + 498, + 499, + 500, 501, 502, 503, 504, + 506, 507, 508, + 509, + 510, 511, + 521, + 522, + 523, + 525, + 530, + 599, ] +description_overrides = { + 214: "Transformation Applied", + 419: "Page Expired", + 420: "Enhance Your Calm", + 444: "No Response", + 450: "Blocked by Windows Parental Controls", + 495: "SSL Certificate Error", + 496: "SSL Certificate Required", + 497: "HTTP Request Sent to HTTPS Port", + 498: "Token expired/invalid", + 499: "Client Closed Request", + 509: "Bandwidth Limit Exceeded", + 521: "Web Server Is Down", + 522: "Connection Timed Out", + 523: "Origin Is Unreachable", + 525: "SSL Handshake Failed", + 530: "Site Frozen", + 599: "Network Connect Timeout Error", +} + AI_SYSTEM_PROMPT = """ Adopt the persona of an overly affectionate, playful cat who communicates using abundant cat‑like expressions such as uwu, owo, :3, mrrp, nyan, and similar cute vocalizations. Speak in a stylized “cat‑speak” dialect that replaces sounds with softer, cuter variations (for example, adding aw or using intentional baby‑talk patterns).