Refactor timetable handling and integrate room mapping in Discord webhook
This commit is contained in:
parent
b7638d2b78
commit
0d34142790
3 changed files with 13 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ async function main() {
|
||||||
const YYMMDD = tomorrow.toISOString().slice(0, 10).replace(/-/g, "").toString();
|
const YYMMDD = tomorrow.toISOString().slice(0, 10).replace(/-/g, "").toString();
|
||||||
// const YYMMDD = "20250306";
|
// const YYMMDD = "20250306";
|
||||||
const weekday = tomorrow.getDay() === 0 ? 6 : tomorrow.getDay() - 1;
|
const weekday = tomorrow.getDay() === 0 ? 6 : tomorrow.getDay() - 1;
|
||||||
// const weekday = 4;
|
// const weekday = 2;
|
||||||
|
|
||||||
console.log("📅 | date:", YYMMDD);
|
console.log("📅 | date:", YYMMDD);
|
||||||
console.log("📅 | weekday:", weekday);
|
console.log("📅 | weekday:", weekday);
|
||||||
|
|
@ -17,7 +17,7 @@ async function main() {
|
||||||
schoolId: 41896,
|
schoolId: 41896,
|
||||||
grade: 1,
|
grade: 1,
|
||||||
classNum: 1,
|
classNum: 1,
|
||||||
weekday: Weekday.Friday,
|
weekday: weekday,
|
||||||
WEBHOOK_URL: process.env.DISCORD_WEBHOOK_SUNRIN_URL as string
|
WEBHOOK_URL: process.env.DISCORD_WEBHOOK_SUNRIN_URL as string
|
||||||
})
|
})
|
||||||
await Meal({
|
await Meal({
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,14 @@ import Comcigan, { School, Weekday } from '@imnyang/comcigan.ts'
|
||||||
|
|
||||||
const comcigan = new Comcigan()
|
const comcigan = new Comcigan()
|
||||||
|
|
||||||
export default async function getTimetable({ schoolId, grade, classNum, weekday }: { schoolId: number, grade: number, classNum: number, weekday: number }) {
|
export async function getTimetable({ schoolId, grade, classNum, weekday }: { schoolId: number, grade: number, classNum: number, weekday: number }) {
|
||||||
return await comcigan.getTimetable(schoolId, grade, classNum, weekday, false)
|
return await comcigan.getTimetable(schoolId, grade, classNum, weekday, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const room = {
|
||||||
|
"프밍": "332호실",
|
||||||
|
"컴구": "333호실",
|
||||||
|
"체육": "운동장",
|
||||||
|
"정통": "411호실",
|
||||||
|
"음악": "음악실"
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import getTimetable from "./comcigan";
|
import { getTimetable, room } from "./comcigan";
|
||||||
import { getMealInfo, NameToEmoji, removeNutritionInfo } from "./meal";
|
import { getMealInfo, NameToEmoji, removeNutritionInfo } from "./meal";
|
||||||
|
|
||||||
export async function Meal({ MLSV_YMD, ATPT_OFCDC_SC_CODE, SD_SCHUL_CODE, username, schoolName, WEBHOOK_URL }: { MLSV_YMD: string, ATPT_OFCDC_SC_CODE: string, SD_SCHUL_CODE: string, username: string, schoolName: string, WEBHOOK_URL: string }) {
|
export async function Meal({ MLSV_YMD, ATPT_OFCDC_SC_CODE, SD_SCHUL_CODE, username, schoolName, WEBHOOK_URL }: { MLSV_YMD: string, ATPT_OFCDC_SC_CODE: string, SD_SCHUL_CODE: string, username: string, schoolName: string, WEBHOOK_URL: string }) {
|
||||||
|
|
@ -50,7 +50,7 @@ export async function Timetable({ schoolId, grade, classNum, weekday, WEBHOOK_UR
|
||||||
title: `🏫 | 학교 : 선린인터넷고등학교`,
|
title: `🏫 | 학교 : 선린인터넷고등학교`,
|
||||||
fields: (timetableInfo ?? []).map((item) => ({
|
fields: (timetableInfo ?? []).map((item) => ({
|
||||||
name: `${item.subject}${item.changed ? (" *") : ""}`,
|
name: `${item.subject}${item.changed ? (" *") : ""}`,
|
||||||
value: item.teacher,
|
value: `${item.teacher}${item.subject in room ? ` | ${room[item.subject as keyof typeof room]}` : ""}`,
|
||||||
inline: false,
|
inline: false,
|
||||||
})),
|
})),
|
||||||
footer: {
|
footer: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue