-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslackclient.py
35 lines (33 loc) · 1.07 KB
/
slackclient.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
import os
import slack
import slack.errors as e
def notify(data):
print(data)
client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])
try:
message_pre = "The following _published_ URLs cannot be accessed. Please examine and unpublish if necessary:\n\n"
response = client.chat_postMessage(
channel='#arrival-support-bot-alerts',
blocks=[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "URL Liveness Probe: Failed Links"
}
},
{
"type": "divider",
"block_id": "divider1"
},
{
"type": "section", "text":
{
"type": "mrkdwn",
"text": message_pre + data,
}
},
])
assert response["ok"]
except e.SlackApiError as error:
print(f"Error: {error}")