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 a screen for already created accounts
Kieran Klukas
1 year ago
e9d7c261
e64ab8d7
+43
1 changed file
expand all
collapse all
unified
split
features
command.ts
+43
features/command.ts
···
2
2
3
3
const command = async () => {
4
4
slackApp.command("/hackatime", async ({ context }) => {
5
5
+
const hackatimeUser: { apiKey: string } | null = await fetch(
6
6
+
`https://waka.hackclub.com/api/special/apikey?user=${context.userId}`,
7
7
+
{
8
8
+
headers: {
9
9
+
Authorization: `Bearer ${process.env.HACKATIME_API_KEY}`,
10
10
+
},
11
11
+
},
12
12
+
).then((res) => (res.status === 404 ? null : res.json()));
13
13
+
14
14
+
if (hackatimeUser) {
15
15
+
if (context?.respond)
16
16
+
await context.respond({
17
17
+
response_type: "ephemeral",
18
18
+
text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:",
19
19
+
blocks: [
20
20
+
{
21
21
+
type: "section",
22
22
+
text: {
23
23
+
type: "mrkdwn",
24
24
+
text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:",
25
25
+
},
26
26
+
},
27
27
+
{
28
28
+
type: "section",
29
29
+
text: {
30
30
+
type: "mrkdwn",
31
31
+
text: `It looks like you already have an account! You can log in to the <https://waka.hackclub.com/login|Hackatime dashboard> with your username \`${context.userId}\` and password :3c:`,
32
32
+
},
33
33
+
},
34
34
+
{
35
35
+
type: "context",
36
36
+
elements: [
37
37
+
{
38
38
+
type: "mrkdwn",
39
39
+
text: `your api key for the Hackatime API is \`${hackatimeUser.apiKey}\``,
40
40
+
},
41
41
+
],
42
42
+
},
43
43
+
],
44
44
+
});
45
45
+
return;
46
46
+
}
47
47
+
5
48
context.respond({
6
49
response_type: "ephemeral",
7
50
text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:",