-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack.py
44 lines (34 loc) · 1009 Bytes
/
slack.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
39
40
41
42
43
44
from config import slack_config
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
SETTINGS = slack_config()
CLIENT = WebClient(token=SETTINGS["slack_token"])
def post_message(channel, message):
try:
response = CLIENT.chat_postMessage(
channel=channel,
text=f"{message}"
)
except SlackApiError as e:
assert e.response['error']
return response
def post_thread(channel, timestamp, message):
try:
response = CLIENT.chat_postMessage(
channel=channel,
thread_ts=f"{timestamp}",
text=f"{message}"
)
except SlackApiError as e:
assert e.response['error']
return response
def post_update(channel, timestamp, message):
try:
response = CLIENT.chat_update(
channel=channel,
ts=f"{timestamp}",
text=f"{message}"
)
except SlackApiError as e:
assert e.response['error']
return response