feat: zeon be more lively

This commit is contained in:
Saahil 2025-03-09 21:49:18 -04:00
parent c16596c643
commit f2781a90b0
No known key found for this signature in database
GPG key ID: 8A8B64515254CFC6
3 changed files with 50 additions and 0 deletions

1
.gitignore vendored
View file

@ -148,3 +148,4 @@ t5.ts
s.csv
slack-users*
assignments.json
memdb.json

View file

@ -115,4 +115,18 @@ app.start(process.env.PORT || 3000).then(async (d) => {
PrivateDNS(app, process.env.HACKCLUB_NEXTDNS, `C07TWGJKK98`);
// grab spotify cache from db
resetSpotifyCache(app);
app.client.chat.postMessage({
channel: `D07LBMXD9FF`,
text: `Im up and running :3`,
});
});
process.on("SIGINT", async () => {
try {
await app.client.chat.postMessage({
channel: `D07LBMXD9FF`,
text: `I was up for ${process.uptime()} seconds :3 its now time for my leave`,
});
} catch (e) {
console.error(`Slack dont wana work >:3`)
}
})

View file

@ -1,4 +1,5 @@
import { App } from "@slack/bolt";
import ms from "ms";
import JSONdb from "simple-json-db";
export interface GitBody {
commit_id: string;
@ -15,8 +16,42 @@ export interface GitSession {
message_ts: null | string;
mlink: null | string;
}
function getTimeOfDay() {
const hour = new Date().getHours();
if (hour >= 5 && hour < 9) {
return "Early Morning";
} else if (hour >= 9 && hour < 12) {
return "Morning";
} else if (hour >= 12 && hour < 17) {
return "Afternoon";
} else if (hour >= 17 && hour < 21) {
return "Evening";
} else {
return "Night";
}
}
export function handleGitRequest(body: GitBody, app: App) {
const funny_words = [
"Mom! look i did something!",
"This is a working moment",
"I love linting your code :3",
`On this fine ${getTimeOfDay()}, im still working on code bruv`,
"PLEASE THIS NEEDS TO WORK",
"neon ur code sucks so im linting it",
`neon ur code is ASSSS`,
"this is what happens when you dont use spaces idiot",
"yum yum code :3",
`After being up for ${ms(process.uptime() * 1000)} im still at it!!`,
]
if (!db) return;
if(body.is_zeon) {
app.client.chat.postMessage({
channel: `C07LEEB50KD`,
text: `${funny_words[Math.floor(Math.random() * funny_words.length)]}\n> :zeon:\`<https://github.com/NeonGamerBot-QK/${body.repo_name}/commit/${body.commit_id}|${body.commit_id.slice(0, 7)}>\``,
})
}
if (!db.get("git_session")) return;
const session = (db.get("git_session") || []).find(
(e) => e.active,