tangled
alpha
login
or
join now
dunkirk.sh
/
smokie
1
fork
atom
a fun bot for the hc slack
1
fork
atom
overview
issues
pulls
pipelines
feat: add min time limit of 6 min
dunkirk.sh
10 months ago
0f816c06
7abc1085
verified
This commit was signed with the committer's
known signature
.
dunkirk.sh
SSH Key Fingerprint:
SHA256:DqcG0RXYExE26KiWo3VxJnsxswN1QNfTBvB+bdSpk80=
+31
-9
1 changed file
expand all
collapse all
unified
split
src
features
takes
handlers
upload.ts
+31
-9
src/features/takes/handlers/upload.ts
···
76
76
name: "spin-loading",
77
77
});
78
78
79
79
+
// fetch time spent on project via hackatime
80
80
+
const timeSpent = await fetchHackatimeSummary(
81
81
+
user,
82
82
+
userInDB.hackatimeVersion as HackatimeVersion,
83
83
+
JSON.parse(userInDB.hackatimeKeys),
84
84
+
new Date(userInDB.lastTakeUploadDate),
85
85
+
new Date(),
86
86
+
).then((res) => res.total_categories_sum || 0);
87
87
+
88
88
+
if (timeSpent < 360) {
89
89
+
await slackClient.chat.postMessage({
90
90
+
channel: payload.channel,
91
91
+
thread_ts: payload.ts,
92
92
+
text: "You haven't spent enough time on your project yet! Spend a few more minutes hacking then come back :)",
93
93
+
});
94
94
+
95
95
+
await slackClient.reactions.remove({
96
96
+
channel: payload.channel,
97
97
+
timestamp: payload.ts,
98
98
+
name: "spin-loading",
99
99
+
});
100
100
+
101
101
+
await slackClient.reactions.add({
102
102
+
channel: payload.channel,
103
103
+
timestamp: payload.ts,
104
104
+
name: "tw_timer_clock",
105
105
+
});
106
106
+
107
107
+
return;
108
108
+
}
109
109
+
79
110
// Convert Slack formatting to markdown
80
111
const replaceUserMentions = async (text: string) => {
81
112
const regex = /<@([A-Z0-9]+)>/g;
···
166
197
mediaUrls.push(...results.filter(Boolean));
167
198
}
168
199
}
169
169
-
170
170
-
// fetch time spent on project via hackatime
171
171
-
const timeSpent = await fetchHackatimeSummary(
172
172
-
user,
173
173
-
userInDB.hackatimeVersion as HackatimeVersion,
174
174
-
JSON.parse(userInDB.hackatimeKeys),
175
175
-
new Date(userInDB.lastTakeUploadDate),
176
176
-
new Date(),
177
177
-
).then((res) => res.total_categories_sum || 0);
178
200
179
201
await db.insert(takesTable).values({
180
202
id: Bun.randomUUIDv7(),