Repository navigation
Expand file tree
/
Copy pathresponse.py
More file actions
248 lines (226 loc) · 7.61 KB
/
Copy pathresponse.py
File metadata and controls
248 lines (226 loc) · 7.61 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import json
SLACK_INSTALL_REDIRECT_URL = 'https://cbeardsmore.github.io/fined?utm_source=fined_install_callback'
def wrap_response_body(response_body):
return {
"statusCode": 200,
"body": json.dumps(response_body),
"headers": {
"Content-Type": "application/json"
}
}
def create_empty_response():
return {
"statusCode": 200,
"body": "",
"headers": {
"Content-Type": "application/json"
}
}
def create_redirect_response():
return {
"statusCode": 302,
"headers": {
"Location": SLACK_INSTALL_REDIRECT_URL
}
}
def create_fallback_response():
return {
"response_type": "ephermeral",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Oops! I didn't quite catch that...try /fine help for how to use Fined!"
}
}
]
}
def create_no_fines_response():
return {
"response_type": "ephermeral",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "There are no fines for this channel! Use the /fine command to fine a teammate."
}
}
]
}
def create_fine_response(user_name):
return {
"response_type": "in_channel",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "@{} has been fined. Shame on them!".format(user_name)
}
}
]
}
def create_fines_response(team_fines):
response_template = {
"response_type": "in_channel",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\U0001F4B0 *Current Team Fines:* \U0001F4B0"
}
},
{
"type": "divider"
}
]
}
for fine in team_fines:
response_template['blocks'].append(
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\u2022 {} ".format(fine['text'])
},
"accessory": {
"type": "button",
"style": "primary",
"action_id": "pay_fine_button",
"text": {
"type": "plain_text",
"text": "Pay",
"emoji": True
},
"value": fine['id']
}
}
)
response_template['blocks'].append(
{
"type": "divider"
}
)
return response_template
def create_help_response():
return {
"response_type": "ephermeral",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hey there 👋 I'm FinedBot and I'm here to help. 🤖"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*1️⃣ Use the `/fine` command*. 🤔 Someone on your team deserves a fine? Type `/fine` followed by the victims alias, the cost and the reason. Here's some examples:\n • `/fine @Tim $5 for messing up the CSS...again`\n• `/fine @Sam $10 for wearing Activewear after 9am`\n• `/fine Jack $10 for being late to standup for the 5th time this week`\n\n Make sure you always follow the required format of: \n • `/fine @user $cost for reason`"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*2️⃣ Use the `/fines` command.* 👮♀️ Get a list of your teams biggest offenders and who needs to pay up. They'll be prompted to remind them of their outstanding fines:"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*3️⃣ Pay up!* 💰Users can mark their fines as paid. Shout a teammate a coffee, pay for the next group lunch, or donate to your favourite charity. It's up to you to keep people honest. Here's a few of our favourite:\n• http://www.americanhumane.org/\n• https://www.hopeforthewarriors.org/\n• https://www.beyondblue.org.au/ "
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": " 💻Check out the code at https://github.com/cbeardsmore/fined\n ❓Get help at any time with `/fine help\n"
}
]
}
]
}
def create_pay_modal(trigger_id, channel_id, fine_id):
return {
"trigger_id": trigger_id,
"view": {
"type": "modal",
"callback_id": channel_id,
"private_metadata": fine_id,
"title": {
"type": "plain_text",
"text": "Pay Your Fine!",
"emoji": True
},
"submit": {
"type": "plain_text",
"text": "Mark as Paid",
"emoji": True
},
"close": {
"type": "plain_text",
"text": "Cancel",
"emoji": True
},
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "💵 Time to pay up. You have 2 choices"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*🙆♂️ Pay the Team*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "It's up to you how you payback the team. Our favourites include:\n\n • Shout a coffee ☕️\n • Pay for team lunch 🍔\n • Buy the next round 🍻"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*❤️ Donate to Charity*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Pay it forward to a charity of your choice and give back to the community Here's some popular choices:\n\n • <http://www.americanhumane.org/|American Humane>\n • <https://www.hopeforthewarriors.org/| Hope for the Warriors>\n • <https://www.beyondblue.org.au/|Beyond Blue>"
}
}
]
}
}