Skip to content

Commit be30a3e

Browse files
zcDay1imagine-hussaintuneinAcdSoftColhjt
authored
updating projects bot branch from the qa branch (#146)
* 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 <z5371683@ad.unsw.edu.au> Co-authored-by: zcDay1 <113964162+zcDay1@users.noreply.github.com> * prettier formatted * chore(deps): update `renovate` config * chore(deps): update docker/build-push-action action to v4 (#134) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * 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> --------- Co-authored-by: imagine-hussain <93496985+imagine-hussain@users.noreply.github.com> Co-authored-by: tunein <z5371683@ad.unsw.edu.au> Co-authored-by: AcdSoftCo <106219586+AcdSoftCo@users.noreply.github.com> Co-authored-by: Jared L <48422312+lhjt@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent e9eca14 commit be30a3e

File tree

6 files changed

+136
-34
lines changed

6 files changed

+136
-34
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
username: ${{ github.actor }}
4040
password: ${{ secrets.GH_TOKEN }}
4141
- name: Build and push Docker image
42-
uses: docker/build-push-action@v3
42+
uses: docker/build-push-action@v4
4343
with:
4444
context: .
4545
push: ${{ github.event_name != 'pull_request' && ( github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/projects-bot' ) }}

commands/handbook.js

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,76 +27,86 @@ module.exports = {
2727

2828
let data;
2929
try {
30-
const response = await axios.get(`${apiURL}${courseCode}`);
30+
// Documented at:
31+
// https://circlesapi.csesoc.app/docs#/courses/get_course_courses_getCourse__courseCode__get
32+
const response = await axios.get(`${apiURL}/courses/getCourse/${courseCode}`);
3133
data = response.data;
34+
// console.log(data);
3235
} catch (e) {
3336
return await interaction.reply({
3437
content: "Invalid course code.",
3538
ephemeral: true,
3639
});
3740
}
3841

42+
const {
43+
title,
44+
code,
45+
UOC,
46+
// level,
47+
description,
48+
// study_level,
49+
// school,
50+
// campus,
51+
equivalents,
52+
raw_requirements,
53+
exclusions,
54+
// handbook_note,
55+
terms,
56+
} = data;
57+
3958
const courseInfo = new MessageEmbed()
40-
.setTitle(data["title"])
41-
.setURL(`${handbookURL}${courseCode}`)
59+
.setTitle(title)
60+
.setURL(`${handbookURL}/${code}`)
4261
.setColor(0x3a76f8)
43-
.setAuthor(
44-
`Course Info: ${courseCode} (${data["credit_points"]} UOC)`,
45-
"https://i.imgur.com/EE3Q40V.png",
46-
)
62+
.setAuthor(`Course Info: ${code} (${UOC} UOC)`, "https://i.imgur.com/EE3Q40V.png")
4763
.addFields(
4864
{
4965
name: "Overview",
50-
value: textVersion(data["description"]).substring(
66+
value: textVersion(description).substring(
5167
0,
52-
Math.min(textVersion(data["description"]).indexOf("\n"), 1024),
68+
Math.min(textVersion(description).indexOf("\n"), 1024),
5369
),
5470
inline: false,
5571
},
5672
{
5773
name: "Enrolment Requirements",
5874
value:
59-
data["enrolment_requirements"].replace(
75+
raw_requirements.replace(
6076
/[A-Z]{4}[0-9]{4}/g,
6177
`[$&](${handbookURL}$&)`,
6278
) || "None",
6379
inline: true,
6480
},
6581
{
6682
name: "Offering Terms",
67-
value: data["offering_terms"],
68-
inline: true,
69-
},
70-
{
71-
name: "Delivery Mode",
72-
value: data["delivery_mode"],
83+
value: terms.join(", "),
7384
inline: true,
7485
},
7586
{
7687
name: "Equivalent Courses",
7788
value:
78-
data["equivalent_courses"]
79-
.map((course) => `[${course}](${handbookURL}${course})`)
89+
Object.keys(equivalents)
90+
.map((course) => `[${course}](${course})`)
8091
.join(", ") || "None",
8192
inline: true,
8293
},
8394
{
8495
name: "Exclusion Courses",
8596
value:
86-
data["exclusion_courses"]
97+
Object.keys(exclusions)
8798
.map((course) => `[${course}](${handbookURL}${course})`)
8899
.join(", ") || "None",
89100
inline: true,
90101
},
91-
{
92-
name: "Course Outline",
93-
value: `[${courseCode} Course Outline](${data["course_outline_url"]})`,
94-
inline: true,
95-
},
102+
/* { */
103+
/* name: "Course Outline", */
104+
/* value: `[${courseCode} Course Outline](${data["course_outline_url"]})`, */
105+
/* inline: true, */
106+
/* }, */
96107
)
97108
.setTimestamp()
98-
.setFooter("Data fetched from Zac's Handbook API");
99-
109+
.setFooter("Data fetched from Circles' Api");
100110
await interaction.reply({ embeds: [courseInfo] });
101111
}
102112
},

commands/project-descriptions.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
const { SlashCommandBuilder } = require("@discordjs/builders");
2+
3+
module.exports = {
4+
data: new SlashCommandBuilder()
5+
.setName("project-descriptions")
6+
.setDescription("Returns a description for each project under CSESoc Development!")
7+
.addStringOption((option) =>
8+
option
9+
.setName("project")
10+
.setDescription("Which project do you want to be introduced to?")
11+
.setRequired(true)
12+
.addChoices([
13+
["Chaos", "chaos"],
14+
["Circles", "circles"],
15+
["CS Electives", "cselectives"],
16+
["Discord Bot", "discordbot"],
17+
["Freerooms", "freerooms"],
18+
["Jobsboard", "jobsboard"],
19+
["Notangles", "notangles"],
20+
["Structs.sh", "structs.sh"],
21+
["UI/UX", "ui/ux"],
22+
["Website", "website"],
23+
]),
24+
),
25+
26+
async execute(interaction) {
27+
const parsedOption = interaction.options.get("project").value.toLowerCase();
28+
// console.log(`.${parsedOption}.`);
29+
switch (parsedOption) {
30+
case "chaos":
31+
await interaction.reply(
32+
"Chaos is a CSESoc internal recruitment tool written in Rust.",
33+
);
34+
break;
35+
case "circles":
36+
await interaction.reply(
37+
"Circles is a degree planner that helps you choose courses, plan out your terms and check progression.",
38+
);
39+
break;
40+
case "cselectives":
41+
await interaction.reply(
42+
"Unsure about what a course is like? Worry no more; CSElectives lets you read and write reviews of UNSW CSE courses.",
43+
);
44+
break;
45+
case "discordbot":
46+
await interaction.reply(
47+
"CSESoc Discord Bot is your friendly helper in all things fun and CSE.",
48+
);
49+
break;
50+
case "freerooms":
51+
await interaction.reply(
52+
"Looking for a room to study in? Freerooms lets you see which on-campus rooms are vacant and which ones are booked.",
53+
);
54+
break;
55+
case "jobsboard":
56+
await interaction.reply(
57+
"Jobsboard is an app that connects CSE students with companies looking for recruits.",
58+
);
59+
break;
60+
case "notangles":
61+
await interaction.reply(
62+
"Notangles is a timetable planning app for UNSW students to build their perfect timetable, even before class registration opens.",
63+
);
64+
break;
65+
case "structs.sh":
66+
await interaction.reply("Structs.sh is an interactive algorithm visualiser.");
67+
break;
68+
case "ui/ux":
69+
await interaction.reply(
70+
"The CSESoc Development UI/UX team works with all things related to user interface and experience design!",
71+
);
72+
break;
73+
case "website":
74+
await interaction.reply(
75+
"The website team are in charge of writing the software for the CSESoc website.",
76+
);
77+
break;
78+
default:
79+
await interaction.reply(
80+
"Error: the switch case has fallen through to the default case.",
81+
);
82+
break;
83+
}
84+
},
85+
};

config/database.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ user: user
66
dbname: bot
77
password: pass
88
host: 0.0.0.0
9-
port: 40041
9+
port: 40041

config/handbook.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"apiURL": "https://handbook.insou.dev/api/v1/course/",
2+
"apiURL": "https://circlesapi.csesoc.app",
33
"handbookURL": "https://www.handbook.unsw.edu.au/undergraduate/courses/2022/"
44
}

renovate.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
"automerge": false,
1010
"automergeType": "branch"
1111
},
12+
{
13+
"matchUpdateTypes": ["patch"],
14+
"groupName": "weekly patch updates",
15+
"schedule": ["before 5am every monday"],
16+
"addLabels": ["deps: patches"]
17+
},
18+
{
19+
"matchUpdateTypes": ["minor"],
20+
"groupName": "weekly minor updates",
21+
"schedule": ["before 5am every monday"],
22+
"addLabels": ["deps: minor"]
23+
},
1224
{
1325
"groupName": "docker-github-actions",
1426
"matchPackagePatterns": ["docker/*"],
1527
"automerge": true,
1628
"automergeType": "branch"
1729
},
18-
{
19-
"matchUpdateTypes": ["patch"],
20-
"groupName": "weekly patch updates",
21-
"schedule": ["before 5am every monday"]
22-
}
2330
]
2431
}

0 commit comments

Comments
 (0)