mirror of
https://github.com/csd4ni3l/meow-bot.git
synced 2026-01-01 04:23:49 +01:00
Update README with features and better , add reactions when saying meow or quack, fix phrases being used as markdown, make meow button threaded
This commit is contained in:
11
README.md
11
README.md
@@ -1 +1,10 @@
|
||||
Slack bot that gives you cute cat and duck pictures when you say meow or duck.
|
||||
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
|
||||
63
app.py
63
app.py
@@ -11,10 +11,24 @@ MEOW_PHRASES = [
|
||||
"=^.^=", "(=^・^=)",
|
||||
"*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(
|
||||
@@ -238,5 +261,11 @@ def message_handler(body, say):
|
||||
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()
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user