-
Notifications
You must be signed in to change notification settings - Fork 0
/
libslackresponder.py
57 lines (51 loc) · 1.39 KB
/
libslackresponder.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
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
def delete_message(response_url, response_type='ephemeral'):
payload = {
"response_type": response_type,
"delete_original": True,
}
r = requests.post(
response_url,
json=payload,
)
scode = r.status_code
if not str(scode).startswith('2'):
raise Exception("Bad Error response: {}".format(
r.__dict__,
))
return str(r.__dict__)
def replace_msg(response_url, message, attachments=[], response_type='ephemeral'):
payload = {
"response_type": response_type,
"replace_original": True,
"attachments": attachments,
"text": message,
}
r = requests.post(
response_url,
json=payload,
)
scode = r.status_code
if not str(scode).startswith('2'):
raise Exception("Bad Error response: {}".format(
r.__dict__,
))
return str(r.__dict__)
def errresp(response_url, message, response_type='ephemeral'):
payload = {
"response_type": response_type,
"replace_original": False,
"text": message,
}
r = requests.post(
response_url,
json=payload,
)
scode = r.status_code
if not str(scode).startswith('2'):
raise Exception("Bad Error response: {}".format(
r.__dict__,
))
return str(r.__dict__)