tangled
alpha
login
or
join now
dunkirk.sh
/
hackatime-bot
0
fork
atom
providing password reset services for a long while: circa 2025
0
fork
atom
overview
issues
pulls
pipelines
feat: add next stage of password
Kieran Klukas
1 year ago
a66b0c4c
c5b8a18f
+86
-1
3 changed files
expand all
collapse all
unified
split
features
command.ts
index.ts
signup.ts
+11
-1
features/command.ts
···
1
1
import { slackApp } from "../index";
2
2
3
3
const command = async () => {
4
4
-
slackApp.command("/hackatime", async ({ context, payload }) => {
4
4
+
slackApp.command("/hackatime", async ({ context }) => {
5
5
context.respond({
6
6
response_type: "ephemeral",
7
7
text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:",
···
31
31
},
32
32
value: "yes",
33
33
style: "primary",
34
34
+
action_id: "create-account",
34
35
},
35
36
{
36
37
type: "button",
···
39
40
text: "No, thanks",
40
41
},
41
42
value: "no",
43
43
+
action_id: "no-thanks",
42
44
},
43
45
],
44
46
},
45
47
],
46
48
});
49
49
+
});
50
50
+
51
51
+
slackApp.action("no-thanks", async ({ context }) => {
52
52
+
if (context?.respond)
53
53
+
await context.respond({
54
54
+
response_type: "ephemeral",
55
55
+
text: "No worries! If you change your mind just type `/hackatime` again ^-^",
56
56
+
});
47
57
});
48
58
};
49
59
+1
features/index.ts
···
1
1
export { default as command } from "./command";
2
2
+
export { default as signup } from "./signup";
+74
features/signup.ts
···
1
1
+
import { slackApp } from "../index";
2
2
+
3
3
+
const signup = async () => {
4
4
+
slackApp.action("create-account", async ({ context }) => {
5
5
+
if (context?.respond)
6
6
+
await context.respond({
7
7
+
response_type: "ephemeral",
8
8
+
text: "sweet! i'll need a password from you then!",
9
9
+
blocks: [
10
10
+
{
11
11
+
type: "section",
12
12
+
text: {
13
13
+
type: "mrkdwn",
14
14
+
text: "sweet! i'll need a password from you then!",
15
15
+
},
16
16
+
},
17
17
+
{
18
18
+
type: "input",
19
19
+
dispatch_action: true,
20
20
+
block_id: "password",
21
21
+
element: {
22
22
+
type: "plain_text_input",
23
23
+
action_id: "set-password",
24
24
+
focus_on_load: true,
25
25
+
min_length: 6,
26
26
+
placeholder: {
27
27
+
type: "plain_text",
28
28
+
text: "hackatime4ever!",
29
29
+
},
30
30
+
},
31
31
+
label: {
32
32
+
type: "plain_text",
33
33
+
text: "Password:",
34
34
+
},
35
35
+
},
36
36
+
{
37
37
+
type: "context",
38
38
+
elements: [
39
39
+
{
40
40
+
type: "mrkdwn",
41
41
+
text: "`Password must be at least 6 characters long.`",
42
42
+
},
43
43
+
],
44
44
+
},
45
45
+
{
46
46
+
type: "actions",
47
47
+
elements: [
48
48
+
{
49
49
+
type: "button",
50
50
+
text: {
51
51
+
type: "plain_text",
52
52
+
text: "perfect, next!",
53
53
+
},
54
54
+
value: "next",
55
55
+
style: "primary",
56
56
+
action_id: "set-password",
57
57
+
},
58
58
+
{
59
59
+
type: "button",
60
60
+
text: {
61
61
+
type: "plain_text",
62
62
+
text: "i changed my mind",
63
63
+
},
64
64
+
value: "no",
65
65
+
action_id: "no-thanks",
66
66
+
},
67
67
+
],
68
68
+
},
69
69
+
],
70
70
+
});
71
71
+
});
72
72
+
};
73
73
+
74
74
+
export default signup;