From 3286cee43f3d1e089dcf4e55b47fe65c3ae30fe4 Mon Sep 17 00:00:00 2001 From: csd4ni3l Date: Thu, 11 Dec 2025 21:09:18 +0100 Subject: [PATCH] Update README with features and better , add reactions when saying meow or quack, fix phrases being used as markdown, make meow button threaded --- README.md | 11 ++++++++- app.py | 67 ++++++++++++++++++++++++++++++++++++--------------- manifest.json | 2 +- 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 25e6487..2e3024b 100644 --- a/README.md +++ b/README.md @@ -1 +1,10 @@ -Slack bot that gives you cute cat and duck pictures when you say meow or duck. \ No newline at end of file +Cat themed Slack bot which has cute cats and random stuff no one actually needs (also quacking ducks)! + +Features: +- Saves humanity +- Meow button (if you press it it will reply with a random cat-like word in a thread) +- Meow translation (for every word you get a random cat-like word instead) +- Cat pictures and reactions when you say meow or any cat-like word and duck pictures/reactions when you say quack/duck-like words! +- https://http.cat command which returns the image for the status code, and also replies to any message containing any valid status code with the cat image! +- Welcome message when you mention or DM the bot! +- Cat facts \ No newline at end of file diff --git a/app.py b/app.py index 61eef76..347096d 100644 --- a/app.py +++ b/app.py @@ -3,18 +3,32 @@ from slack_bolt import App from slack_bolt.adapter.socket_mode import SocketModeHandler MEOW_PHRASES = [ - ":3", " >:3", + ":3", ">:3", "meow", "mew", "meww", "mrrp", "mrrrp", "mrp", "mrrrow", "purr", "prr", "prrr", "nya", "nyan", "nyaa", "nyaaa", "nyanyanya", "nya~", "nya!", - "owo", "uwu", "qwq", " >w<", " ^_^", + "owo", "uwu", "qwq", ">w<", "^_^", "=^.^=", "(=^・^=)", "*meow*", "*purr*", "*mrrp*", "*nya*", "chirp", "eep", - "nyoom", "rawr" + "nyoom", "rawr", + "cat" ] -QUACK_PHRASES = ["quack", "duck", "gizzy"] +CAT_EMOJI = "cat" +DUCK_EMOJI = "duck" + +QUACK_PHRASES = ["quack", "duck"] + +WELCOME_MESSAGE = """ +mrrrp… hiii :3 +*arches back, tail wiggle* + +meow-meow, nyaaa~ I bring u cozy purrs and tiny toe-beans of chaos >:3c +sniff sniff… u smell like someone who needs a soft head-bonk *bonk* + +mew! I shall now sit on your keyboard for maximum inconvenience +""" http_cat_codes = [ 100, 101, 102, 103, @@ -77,7 +91,7 @@ def meow_translate(ack, say, command): user = command["user_id"] ack() say( - text=f"<@{user}> said " + " ".join([random.choice(MEOW_PHRASES) for _ in range(len(text.split(" ")))]) + text=f"<@{user}> said " + " ".join([random.choice(MEOW_PHRASES) for _ in range(len(text.split(" ")))], mrkdown=False) ) @app.command("/meow_button") @@ -101,9 +115,10 @@ def meow_button(ack, say): ) @app.action("meow_button") -def meow_action(ack, say): +def meow_action(ack, say, body): + ts = body["message"].get("thread_ts", body["message"]["ts"]) ack() - say(text=random.choice(MEOW_PHRASES)) + say(text=random.choice(MEOW_PHRASES), thread_ts=ts, mrkdown=False) @app.command("/meow") def meow(ack, say): @@ -199,22 +214,18 @@ def cat_fact_button(ack, respond): @app.event("app_mention") def mention(body, say): thread_ts = body['event']['ts'] - say( - text=""" -mrrrp… hiii :3 -*arches back, tail wiggle* - -meow-meow, nyaaa~ I bring u cozy purrs and tiny toe-beans of chaos >:3c -sniff sniff… u smell like someone who needs a soft head-bonk *bonk* - -mew! I shall now sit on your keyboard for maximum inconvenience -""", thread_ts=thread_ts) + say(text=WELCOME_MESSAGE, thread_ts=thread_ts) @app.event("message") -def message_handler(body, say): - event = body.get("event", {}) +def message_handler(event, say, client, message): ts = event.get('ts') message_text = event.get('text', '').lower() + channel_id = message["channel"] + message_ts = message["ts"] + + if event.get("channel_type") == "im" and "bot_id" not in event: + say(WELCOME_MESSAGE) + return found_status_codes = [status_code for status_code in http_cat_codes if str(status_code) in message_text.lower()] @@ -224,12 +235,24 @@ def message_handler(body, say): blocks=generate_meow_blocks(), thread_ts=ts ) + client.reactions_add( + channel=channel_id, + name=CAT_EMOJI, + timestamp=message_ts + ) elif any([phrase in message_text.lower().split() for phrase in QUACK_PHRASES]): say( text="Quack! :3", blocks=generate_quack_blocks(), thread_ts=ts ) + + client.reactions_add( + channel=channel_id, + name=DUCK_EMOJI, + timestamp=message_ts + ) + elif found_status_codes: status_code = found_status_codes[0] say( @@ -237,6 +260,12 @@ def message_handler(body, say): blocks=generate_httpcat_blocks(status_code), thread_ts=ts ) + + client.reactions_add( + channel=channel_id, + name=CAT_EMOJI, + timestamp=message_ts + ) if __name__ == "__main__": SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start() diff --git a/manifest.json b/manifest.json index 672a7f8..4110aa0 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ }, "oauth_config": { "scopes": { - "bot": ["channels:history", "chat:write", "im:history", "app_mentions:read"] + "bot": ["channels:history", "chat:write", "im:history", "app_mentions:read", "reactions:read", "reactions:write"] } }, "settings": {