-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcat_button.py
38 lines (30 loc) · 841 Bytes
/
cat_button.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import random
from slackclient import SlackClient
TEST_CHANNEL = "C7M386WN8"
HOLLAND_CHANNEL = "G8TU9CA92"
MILOS = [":milo:", ":milo_glare:"]
LUNAS = [":luna_wat:", ":luna_derp:", ":luna_cat:"]
def handler(event, context):
slack_token = os.environ["SLACK_API_TOKEN"]
sc = SlackClient(slack_token)
milo = random.choice(MILOS)
luna = random.choice(LUNAS)
response = sc.api_call(
"chat.postMessage",
channel=HOLLAND_CHANNEL,
text=f"{milo} {luna} The cats have been fed!",
as_user=False,
username="CatBot"
)
if response["ok"]:
return {
'statusCode': 200
}
else:
return {
'statusCode':500,
'body': json.dumps(response)
}
if __name__ == "__main__":
handler("test", "test")