update: share da grades

This commit is contained in:
Neon 2025-02-27 10:34:25 -07:00 committed by GitHub
parent ac624b9cb6
commit 15822ba8ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -180,7 +180,36 @@ export function tempcronjob(app: ModifiedApp) {
setInterval(() => {
try {
fetchHomePage().then((data) => {
app.db.set(`temp_mykcd_grades`, data);
// app.db.set(`temp_mykcd_grades`, data);
data.map(d => ({ grade: d.cumgrade, name: d.sectionidentifier, id: d.sectionid })).forEach(async d => {
const instance = app.dbs.mykcd.get(`class_`+d.id)
if(!instance) {
// shout its been discovered
await app.client.chat.postMessage({
channel: `C07R8DYAZMM`,
text: `Enrolled in *${d.name}* and starting with grade of *${d.grade || 0}%*`,
});
} else {
if(instance.grade !== d.grade) {
// post emph
await app.client.chat.postEphemeral({
channel: `C07R8DYAZMM`,
user: `U07L45W79E1`,
text: `Hey for *${d.name}* your grade updated to *${d.grade}%* from *${instance.grade}%*, would you like to share it?`,
// todo add button to share lol
// blocks: [{
// }]
});
}
if(instance.name !== d.name) {
await app.client.chat.postMessage({
channel: `C07R8DYAZMM`,
text: `Class *${instance.name}* -> *${d.name}*`,
});
}
}
app.dbs.mykcd.set(`class_`+d.id, d)
})
});
console.log(`omg it worked`);