-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslack_msg.py
More file actions
134 lines (126 loc) · 3.29 KB
/
Copy pathslack_msg.py
File metadata and controls
134 lines (126 loc) · 3.29 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import os
from slack import WebClient
def send_register_finish_msg(user_id):
client = WebClient(token=os.environ['SLACK_TOKEN'])
user_id = [user['id'] for user in client.users_list()['members'] if user['id'] == user_id][0]
response = client.conversations_open(users=user_id)
client.chat_postMessage(channel=response['channel']['id'], blocks=[
{
"type":"divider"
},
{
"type":"section",
"text":{
"type" : "mrkdwn",
"text": ":tada: Connect finished!\n\n평가 시작 15분 전에 알려드릴게요. 편안히 코딩하세요 :pray:"
},
},
{
"type":"divider"
}
])
return ""
def send_msg(user_id, text):
client = WebClient(token=os.environ['SLACK_TOKEN'])
user_id = [user['id'] for user in client.users_list()['members'] if user['id'] == user_id][0]
response = client.conversations_open(users=user_id)
client.chat_postMessage(channel=response['channel']['id'], blocks=[
{
"type":"divider"
},
{
"type":"section",
"text":{
"type" : "mrkdwn",
"text": text
},
},
{
"type":"divider"
}
])
return ""
def send_register_update_msg(user_id):
client = WebClient(token=os.environ['SLACK_TOKEN'])
user_id = [user['id'] for user in client.users_list()['members'] if user['id'] == user_id][0]
response = client.conversations_open(users=user_id)
client.chat_postMessage(channel=response['channel']['id'], blocks=[
{
"type":"divider"
},
{
"type":"section",
"text":{
"type" : "mrkdwn",
"text": ":tada: Token reissued!\n\n평가 시작 15분 전에 알려드릴게요. 편안히 코딩하세요 :pray:"
},
},
{
"type":"divider"
}
])
return ""
def send_scale_message(user_id, scale_info):
client = WebClient(token=os.environ['SLACK_TOKEN'])
response = client.conversations_open(users=user_id)
scale_text = ":fire: :runner: *평가가 왔어요* :runner: :fire:\n\n"
for i,(k,v) in enumerate(scale_info.items()):
scale_text += k
scale_text += " : *"
scale_text += v
scale_text += "*\n\n"
client.chat_postMessage(
channel=response['channel']['id'],
blocks=[
{"type":"divider"},
{
"type":"section",
"text":{
"type" : "mrkdwn",
"text":scale_text
},
},
{"type":"divider"}
]
)
return ""
def send_register_btn(url, user_id, is_update):
client = WebClient(token=os.environ['SLACK_TOKEN'])
response = client.conversations_open(users=user_id)
user_name = [user['real_name'] for user in client.users_list()['members'] if user['id'] == user_id][0]
if is_update:
message = ":exclamation: *Token expired* :exclamation:\nPlease update your intra access-token :)"
button_text = "Update token"
else:
message = ":wave: Hello " + user_name + "!\nPlease connect with Intra account to get your evaluation info :)"
button_text = "Connect Intra account"
res = client.chat_postMessage(channel=response['channel']['id'], attachments=[
{
"color": "#000000",
"blocks" : [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": message
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"emoji": True,
"text": button_text
},
"style": "primary",
"value": "click_me_123",
"url" : url
}
]
}]
}]
)
return ""