-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonboarding.py
81 lines (72 loc) · 2.97 KB
/
onboarding.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class Onboarding:
"""Constructs the onboarding message and stores the state of which tasks were completed."""
# TODO: Create a better message builder:
# https://github.com/slackapi/python-slackclient/issues/392
# https://github.com/slackapi/python-slackclient/pull/400
WELCOME_BLOCK = {
"type": "section",
"text": {
"type": "mrkdwn",
"text": (
"Welcome to Slack! :wave: We're so glad you're here. :blush:\n\n"
"*Get started by completing the steps below:*"
),
},
}
DIVIDER_BLOCK = {"type": "divider"}
def __init__(self, channel):
self.channel = channel
self.username = "pythonboardingbot"
self.icon_emoji = ":robot_face:"
self.timestamp = ""
self.reaction_task_completed = False
self.pin_task_completed = False
def get_message_payload(self):
return {
"ts": self.timestamp,
"channel": self.channel,
"username": self.username,
"icon_emoji": self.icon_emoji,
"blocks": [
self.WELCOME_BLOCK,
self.DIVIDER_BLOCK,
*self._get_reaction_block(),
self.DIVIDER_BLOCK,
*self._get_pin_block(),
],
}
def _get_reaction_block(self):
task_checkmark = self._get_checkmark(self.reaction_task_completed)
text = (
f"{task_checkmark} *Add an emoji reaction to this message* :thinking_face:\n"
"You can quickly respond to any message on Slack with an emoji reaction."
"Reactions can be used for any purpose: voting, checking off to-do items, showing excitement."
)
information = (
":information_source: *<https://get.slack.help/hc/en-us/articles/206870317-Emoji-reactions|"
"Learn How to Use Emoji Reactions>*"
)
return self._get_task_block(text, information)
def _get_pin_block(self):
task_checkmark = self._get_checkmark(self.pin_task_completed)
text = (
f"{task_checkmark} *Pin this message* :round_pushpin:\n"
"Important messages and files can be pinned to the details pane in any channel or"
" direct message, including group messages, for easy reference."
)
information = (
":information_source: *<https://get.slack.help/hc/en-us/articles/205239997-Pinning-messages-and-files"
"|Learn How to Pin a Message>*"
)
return self._get_task_block(text, information)
@staticmethod
def _get_checkmark(task_completed: bool) -> str:
if task_completed:
return ":white_check_mark:"
return ":white_large_square:"
@staticmethod
def _get_task_block(text, information):
return [
{"type": "section", "text": {"type": "mrkdwn", "text": text}},
{"type": "context", "elements": [{"type": "mrkdwn", "text": information}]},
]