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
|
||||||
67
app.py
67
app.py
@@ -3,18 +3,32 @@ from slack_bolt import App
|
|||||||
from slack_bolt.adapter.socket_mode import SocketModeHandler
|
from slack_bolt.adapter.socket_mode import SocketModeHandler
|
||||||
|
|
||||||
MEOW_PHRASES = [
|
MEOW_PHRASES = [
|
||||||
":3", " >:3",
|
":3", ">:3",
|
||||||
"meow", "mew", "meww", "mrrp", "mrrrp", "mrp", "mrrrow",
|
"meow", "mew", "meww", "mrrp", "mrrrp", "mrp", "mrrrow",
|
||||||
"purr", "prr", "prrr",
|
"purr", "prr", "prrr",
|
||||||
"nya", "nyan", "nyaa", "nyaaa", "nyanyanya", "nya~", "nya!",
|
"nya", "nyan", "nyaa", "nyaaa", "nyanyanya", "nya~", "nya!",
|
||||||
"owo", "uwu", "qwq", " >w<", " ^_^",
|
"owo", "uwu", "qwq", ">w<", "^_^",
|
||||||
"=^.^=", "(=^・^=)",
|
"=^.^=", "(=^・^=)",
|
||||||
"*meow*", "*purr*", "*mrrp*", "*nya*",
|
"*meow*", "*purr*", "*mrrp*", "*nya*",
|
||||||
"chirp", "eep",
|
"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 = [
|
http_cat_codes = [
|
||||||
100, 101, 102, 103,
|
100, 101, 102, 103,
|
||||||
@@ -77,7 +91,7 @@ def meow_translate(ack, say, command):
|
|||||||
user = command["user_id"]
|
user = command["user_id"]
|
||||||
ack()
|
ack()
|
||||||
say(
|
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")
|
@app.command("/meow_button")
|
||||||
@@ -101,9 +115,10 @@ def meow_button(ack, say):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@app.action("meow_button")
|
@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()
|
ack()
|
||||||
say(text=random.choice(MEOW_PHRASES))
|
say(text=random.choice(MEOW_PHRASES), thread_ts=ts, mrkdown=False)
|
||||||
|
|
||||||
@app.command("/meow")
|
@app.command("/meow")
|
||||||
def meow(ack, say):
|
def meow(ack, say):
|
||||||
@@ -199,22 +214,18 @@ def cat_fact_button(ack, respond):
|
|||||||
@app.event("app_mention")
|
@app.event("app_mention")
|
||||||
def mention(body, say):
|
def mention(body, say):
|
||||||
thread_ts = body['event']['ts']
|
thread_ts = body['event']['ts']
|
||||||
say(
|
say(text=WELCOME_MESSAGE, thread_ts=thread_ts)
|
||||||
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)
|
|
||||||
|
|
||||||
@app.event("message")
|
@app.event("message")
|
||||||
def message_handler(body, say):
|
def message_handler(event, say, client, message):
|
||||||
event = body.get("event", {})
|
|
||||||
ts = event.get('ts')
|
ts = event.get('ts')
|
||||||
message_text = event.get('text', '').lower()
|
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()]
|
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(),
|
blocks=generate_meow_blocks(),
|
||||||
thread_ts=ts
|
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]):
|
elif any([phrase in message_text.lower().split() for phrase in QUACK_PHRASES]):
|
||||||
say(
|
say(
|
||||||
text="Quack! :3",
|
text="Quack! :3",
|
||||||
blocks=generate_quack_blocks(),
|
blocks=generate_quack_blocks(),
|
||||||
thread_ts=ts
|
thread_ts=ts
|
||||||
)
|
)
|
||||||
|
|
||||||
|
client.reactions_add(
|
||||||
|
channel=channel_id,
|
||||||
|
name=DUCK_EMOJI,
|
||||||
|
timestamp=message_ts
|
||||||
|
)
|
||||||
|
|
||||||
elif found_status_codes:
|
elif found_status_codes:
|
||||||
status_code = found_status_codes[0]
|
status_code = found_status_codes[0]
|
||||||
say(
|
say(
|
||||||
@@ -238,5 +261,11 @@ def message_handler(body, say):
|
|||||||
thread_ts=ts
|
thread_ts=ts
|
||||||
)
|
)
|
||||||
|
|
||||||
|
client.reactions_add(
|
||||||
|
channel=channel_id,
|
||||||
|
name=CAT_EMOJI,
|
||||||
|
timestamp=message_ts
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()
|
SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"oauth_config": {
|
"oauth_config": {
|
||||||
"scopes": {
|
"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": {
|
"settings": {
|
||||||
|
|||||||
Reference in New Issue
Block a user