Skip to content

updating projects bot branch from the qa branch #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) }}
Expand Down
62 changes: 36 additions & 26 deletions commands/handbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,76 +27,86 @@ 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.",
ephemeral: true,
});
}

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)`,
"https://i.imgur.com/EE3Q40V.png",
)
.setAuthor(`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",
inline: true,
},
{
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})`)
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] });
}
},
Expand Down
85 changes: 85 additions & 0 deletions commands/project-descriptions.js
Original file line number Diff line number Diff line change
@@ -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;
}
},
};
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ user: user
dbname: bot
password: pass
host: 0.0.0.0
port: 40041
port: 40041
2 changes: 1 addition & 1 deletion config/handbook.json
Original file line number Diff line number Diff line change
@@ -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/"
}
17 changes: 12 additions & 5 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
]
}