providing password reset services for a long while: circa 2025

feat: add a screen for already created accounts

+43
+43
features/command.ts
··· 2 2 3 3 const command = async () => { 4 4 slackApp.command("/hackatime", async ({ context }) => { 5 + const hackatimeUser: { apiKey: string } | null = await fetch( 6 + `https://waka.hackclub.com/api/special/apikey?user=${context.userId}`, 7 + { 8 + headers: { 9 + Authorization: `Bearer ${process.env.HACKATIME_API_KEY}`, 10 + }, 11 + }, 12 + ).then((res) => (res.status === 404 ? null : res.json())); 13 + 14 + if (hackatimeUser) { 15 + if (context?.respond) 16 + await context.respond({ 17 + response_type: "ephemeral", 18 + text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:", 19 + blocks: [ 20 + { 21 + type: "section", 22 + text: { 23 + type: "mrkdwn", 24 + text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:", 25 + }, 26 + }, 27 + { 28 + type: "section", 29 + text: { 30 + type: "mrkdwn", 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 + }, 33 + }, 34 + { 35 + type: "context", 36 + elements: [ 37 + { 38 + type: "mrkdwn", 39 + text: `your api key for the Hackatime API is \`${hackatimeUser.apiKey}\``, 40 + }, 41 + ], 42 + }, 43 + ], 44 + }); 45 + return; 46 + } 47 + 5 48 context.respond({ 6 49 response_type: "ephemeral", 7 50 text: "Hi there! I'm the Hackatime bot :hyper-dino-wave:",