Spaces:
Sleeping
Sleeping
Update slack_bot.py
Browse files- slack_bot.py +15 -14
slack_bot.py
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
import requests
|
2 |
|
3 |
-
SLACK_BOT_TOKEN =
|
4 |
-
SLACK_BOT_CHANNEL_ID =
|
5 |
|
6 |
-
payload = {"channel": SLACK_BOT_CHANNEL_ID, "text": "This message was sent from Hugging Face demo workspace."}
|
7 |
|
8 |
-
|
9 |
-
"
|
10 |
-
|
11 |
-
}
|
|
|
|
|
12 |
|
13 |
-
response = requests.post(
|
14 |
-
|
15 |
-
)
|
16 |
|
17 |
-
if response.status_code == 200 and response.json().get("ok"):
|
18 |
-
|
19 |
-
else:
|
20 |
-
|
|
|
1 |
import requests
|
2 |
|
3 |
+
SLACK_BOT_TOKEN = "xoxb-7956608570179-8288868683413-szG80H8DCFQvTbQSxMgN0z3S"
|
4 |
+
SLACK_BOT_CHANNEL_ID = "C088D2NLN5C"
|
5 |
|
|
|
6 |
|
7 |
+
def send_slack_message(message: str):
|
8 |
+
payload = {"channel": SLACK_BOT_CHANNEL_ID, "text": message}
|
9 |
+
headers = {
|
10 |
+
"Authorization": f"Bearer {SLACK_BOT_TOKEN}",
|
11 |
+
"Content-Type": "application/json",
|
12 |
+
}
|
13 |
|
14 |
+
response = requests.post(
|
15 |
+
"https://slack.com/api/chat.postMessage", json=payload, headers=headers
|
16 |
+
)
|
17 |
|
18 |
+
if response.status_code == 200 and response.json().get("ok"):
|
19 |
+
print("Message sent successfully!")
|
20 |
+
else:
|
21 |
+
print("Failed to send message:", response.json())
|