From 054128a9a08e81adda471180b574213dba99baba Mon Sep 17 00:00:00 2001 From: imagine-hussain <93496985+imagine-hussain@users.noreply.github.com> Date: Wed, 22 Feb 2023 12:14:04 +1100 Subject: [PATCH 1/5] migrate from insou api to circles for the handbook commands (#128) * migrate from insou api to circles for the handbook commands * remove trailing forward slash in handbook.json * handbook: the handbook is fixed * Update handbook.js commented out a console.log --------- Co-authored-by: tunein Co-authored-by: zcDay1 <113964162+zcDay1@users.noreply.github.com> --- commands/handbook.js | 52 +++++++++++++++++++++++--------------------- config/database.yml | 2 +- config/handbook.json | 2 +- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/commands/handbook.js b/commands/handbook.js index 6be75e35..339fd563 100644 --- a/commands/handbook.js +++ b/commands/handbook.js @@ -27,8 +27,11 @@ module.exports = { let data; try { - const response = await axios.get(`${apiURL}${courseCode}`); + // Documented at: + // https://circlesapi.csesoc.app/docs#/courses/get_course_courses_getCourse__courseCode__get + const response = await axios.get(`${apiURL}/courses/getCourse/${courseCode}`); data = response.data; + // console.log(data); } catch (e) { return await interaction.reply({ content: "Invalid course code.", @@ -36,27 +39,32 @@ module.exports = { }); } + const { + title, code, UOC, level, description, study_level, school, campus, + equivalents, raw_requirements, exclusions, handbook_note, terms + } = data; + const courseInfo = new MessageEmbed() - .setTitle(data["title"]) - .setURL(`${handbookURL}${courseCode}`) + .setTitle(title) + .setURL(`${handbookURL}/${code}`) .setColor(0x3a76f8) .setAuthor( - `Course Info: ${courseCode} (${data["credit_points"]} UOC)`, + `Course Info: ${code} (${UOC} UOC)`, "https://i.imgur.com/EE3Q40V.png", ) .addFields( { name: "Overview", - value: textVersion(data["description"]).substring( + value: textVersion(description).substring( 0, - Math.min(textVersion(data["description"]).indexOf("\n"), 1024), + Math.min(textVersion(description).indexOf("\n"), 1024), ), inline: false, }, { name: "Enrolment Requirements", value: - data["enrolment_requirements"].replace( + raw_requirements.replace( /[A-Z]{4}[0-9]{4}/g, `[$&](${handbookURL}$&)`, ) || "None", @@ -64,39 +72,33 @@ module.exports = { }, { name: "Offering Terms", - value: data["offering_terms"], - inline: true, - }, - { - name: "Delivery Mode", - value: data["delivery_mode"], + value: terms.join(", "), inline: true, }, { name: "Equivalent Courses", - value: - data["equivalent_courses"] - .map((course) => `[${course}](${handbookURL}${course})`) - .join(", ") || "None", + value: + Object.keys(equivalents) + .map((course) => `[${course}](${course})`) + .join(", ") || "None", inline: true, }, { name: "Exclusion Courses", value: - data["exclusion_courses"] + Object.keys(exclusions) .map((course) => `[${course}](${handbookURL}${course})`) .join(", ") || "None", inline: true, }, - { - name: "Course Outline", - value: `[${courseCode} Course Outline](${data["course_outline_url"]})`, - inline: true, - }, + /* { */ + /* name: "Course Outline", */ + /* value: `[${courseCode} Course Outline](${data["course_outline_url"]})`, */ + /* inline: true, */ + /* }, */ ) .setTimestamp() - .setFooter("Data fetched from Zac's Handbook API"); - + .setFooter("Data fetched from Circles' Api"); await interaction.reply({ embeds: [courseInfo] }); } }, diff --git a/config/database.yml b/config/database.yml index 1fa06e4f..eac5e48b 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,4 +6,4 @@ user: user dbname: bot password: pass host: 0.0.0.0 -port: 40041 +port: 40041 \ No newline at end of file diff --git a/config/handbook.json b/config/handbook.json index 3fe12ea2..9a8d7097 100644 --- a/config/handbook.json +++ b/config/handbook.json @@ -1,4 +1,4 @@ { - "apiURL": "https://handbook.insou.dev/api/v1/course/", + "apiURL": "https://circlesapi.csesoc.app", "handbookURL": "https://www.handbook.unsw.edu.au/undergraduate/courses/2022/" } From ea97f3371f9d40e2fd5f69b2d5a434a6a2de0c08 Mon Sep 17 00:00:00 2001 From: AcdSoftCo <106219586+AcdSoftCo@users.noreply.github.com> Date: Wed, 22 Feb 2023 12:25:08 +1100 Subject: [PATCH 2/5] prettier formatted --- commands/handbook.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/commands/handbook.js b/commands/handbook.js index 339fd563..64bf8b60 100644 --- a/commands/handbook.js +++ b/commands/handbook.js @@ -40,18 +40,26 @@ module.exports = { } const { - title, code, UOC, level, description, study_level, school, campus, - equivalents, raw_requirements, exclusions, handbook_note, terms + title, + code, + UOC, + level, + description, + study_level, + school, + campus, + equivalents, + raw_requirements, + exclusions, + handbook_note, + terms, } = data; const courseInfo = new MessageEmbed() .setTitle(title) .setURL(`${handbookURL}/${code}`) .setColor(0x3a76f8) - .setAuthor( - `Course Info: ${code} (${UOC} UOC)`, - "https://i.imgur.com/EE3Q40V.png", - ) + .setAuthor(`Course Info: ${code} (${UOC} UOC)`, "https://i.imgur.com/EE3Q40V.png") .addFields( { name: "Overview", @@ -77,16 +85,16 @@ module.exports = { }, { name: "Equivalent Courses", - value: + value: Object.keys(equivalents) - .map((course) => `[${course}](${course})`) - .join(", ") || "None", + .map((course) => `[${course}](${course})`) + .join(", ") || "None", inline: true, }, { name: "Exclusion Courses", value: - Object.keys(exclusions) + Object.keys(exclusions) .map((course) => `[${course}](${handbookURL}${course})`) .join(", ") || "None", inline: true, From 81e5085ff75b2f40d03d5fc0bf4f2a1eb31001f8 Mon Sep 17 00:00:00 2001 From: Jared L <48422312+lhjt@users.noreply.github.com> Date: Wed, 22 Mar 2023 17:57:21 +1100 Subject: [PATCH 3/5] chore(deps): update `renovate` config --- renovate.json | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/renovate.json b/renovate.json index 28505fd0..7262f36f 100644 --- a/renovate.json +++ b/renovate.json @@ -9,16 +9,23 @@ "automerge": false, "automergeType": "branch" }, + { + "matchUpdateTypes": ["patch"], + "groupName": "weekly patch updates", + "schedule": ["before 5am every monday"], + "addLabels": ["deps: patches"] + }, + { + "matchUpdateTypes": ["minor"], + "groupName": "weekly minor updates", + "schedule": ["before 5am every monday"], + "addLabels": ["deps: minor"] + }, { "groupName": "docker-github-actions", "matchPackagePatterns": ["docker/*"], "automerge": true, "automergeType": "branch" }, - { - "matchUpdateTypes": ["patch"], - "groupName": "weekly patch updates", - "schedule": ["before 5am every monday"] - } ] } From 883a0d866927d12fc3239bae0445879cba0aa054 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 23 Mar 2023 20:46:05 +1100 Subject: [PATCH 4/5] chore(deps): update docker/build-push-action action to v4 (#134) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 26102c42..b8316d72 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -39,7 +39,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GH_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: context: . push: ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/projects-bot' ) }} From d0656cabc2515ba37f59cb982d15994b1c874fe6 Mon Sep 17 00:00:00 2001 From: Alexander C <113964162+zcDay1@users.noreply.github.com> Date: Tue, 16 May 2023 13:30:04 +1000 Subject: [PATCH 5/5] Projects description command feature (#145) * projects-descriptions v1 commit * project-descriptions command v2 commit * linting fixes for project-descriptions.js, and for handbook.js --------- Co-authored-by: AcdSoftCo <106219586+AcdSoftCo@users.noreply.github.com> --- commands/handbook.js | 10 ++-- commands/project-descriptions.js | 85 ++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 commands/project-descriptions.js diff --git a/commands/handbook.js b/commands/handbook.js index 64bf8b60..3799f703 100644 --- a/commands/handbook.js +++ b/commands/handbook.js @@ -43,15 +43,15 @@ module.exports = { title, code, UOC, - level, + // level, description, - study_level, - school, - campus, + // study_level, + // school, + // campus, equivalents, raw_requirements, exclusions, - handbook_note, + // handbook_note, terms, } = data; diff --git a/commands/project-descriptions.js b/commands/project-descriptions.js new file mode 100644 index 00000000..0b186b0d --- /dev/null +++ b/commands/project-descriptions.js @@ -0,0 +1,85 @@ +const { SlashCommandBuilder } = require("@discordjs/builders"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("project-descriptions") + .setDescription("Returns a description for each project under CSESoc Development!") + .addStringOption((option) => + option + .setName("project") + .setDescription("Which project do you want to be introduced to?") + .setRequired(true) + .addChoices([ + ["Chaos", "chaos"], + ["Circles", "circles"], + ["CS Electives", "cselectives"], + ["Discord Bot", "discordbot"], + ["Freerooms", "freerooms"], + ["Jobsboard", "jobsboard"], + ["Notangles", "notangles"], + ["Structs.sh", "structs.sh"], + ["UI/UX", "ui/ux"], + ["Website", "website"], + ]), + ), + + async execute(interaction) { + const parsedOption = interaction.options.get("project").value.toLowerCase(); + // console.log(`.${parsedOption}.`); + switch (parsedOption) { + case "chaos": + await interaction.reply( + "Chaos is a CSESoc internal recruitment tool written in Rust.", + ); + break; + case "circles": + await interaction.reply( + "Circles is a degree planner that helps you choose courses, plan out your terms and check progression.", + ); + break; + case "cselectives": + await interaction.reply( + "Unsure about what a course is like? Worry no more; CSElectives lets you read and write reviews of UNSW CSE courses.", + ); + break; + case "discordbot": + await interaction.reply( + "CSESoc Discord Bot is your friendly helper in all things fun and CSE.", + ); + break; + case "freerooms": + await interaction.reply( + "Looking for a room to study in? Freerooms lets you see which on-campus rooms are vacant and which ones are booked.", + ); + break; + case "jobsboard": + await interaction.reply( + "Jobsboard is an app that connects CSE students with companies looking for recruits.", + ); + break; + case "notangles": + await interaction.reply( + "Notangles is a timetable planning app for UNSW students to build their perfect timetable, even before class registration opens.", + ); + break; + case "structs.sh": + await interaction.reply("Structs.sh is an interactive algorithm visualiser."); + break; + case "ui/ux": + await interaction.reply( + "The CSESoc Development UI/UX team works with all things related to user interface and experience design!", + ); + break; + case "website": + await interaction.reply( + "The website team are in charge of writing the software for the CSESoc website.", + ); + break; + default: + await interaction.reply( + "Error: the switch case has fallen through to the default case.", + ); + break; + } + }, +};