Skip to content

Commit

Permalink
[Release] 0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Jan 30, 2022
1 parent 45891bf commit 0af226f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 25 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ All notable changes to Kawaii Cocoa Grader will be documented here

Changelog before 0.2.2 will not be noted here

## [0.2.6] - 2021-01-30
## [0.2.7] - 2022-01-30

- Updated Embeds ✨✨

- Added JavaScript (0.2.6) and Haskell

## [0.2.6] - 2022-01-30

- Upgrade to Cocoa Discord Utils 1.0.0-rc.1 and use its new feature

- Embed Submission Result ✨✨

## [0.2.5] - 2021-01-29
## [0.2.5] - 2022-01-29

- Upgrade to Cocoa Discord Utils 1.0.0-pre.10 and use its new feature

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cocoa-grader",
"version": "0.2.6",
"version": "0.2.7",
"description": "Discord Bot Grader",
"main": "dist/bot/client.js",
"repository": "https://github.com/Leomotors/cocoa-grader",
Expand Down
6 changes: 3 additions & 3 deletions src/bot/commands/message/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function EmbedGen(msg: Message, result: Verdict, perf: number) {
.setAuthor(Author(msg))
.setTitle(pb.title)
.setDescription(
`Description: ${pb.description}\nSubmission Status: ${result.status}\nSubtasks Verdict: [${result.subtasks}]`
`Description: ${pb.description}\nTime Limit: ${pb.timelimit} seconds\nMemory Limit: ${pb.memorylimit} MB\nSubmission Status: ${result.status}\nSubtasks Verdict: [${result.subtasks}]`
)
.setColor(Cocoa.Color)
.setThumbnail(Cocoa.GIF.NoPoi)
Expand Down Expand Up @@ -53,12 +53,12 @@ function EmbedGen(msg: Message, result: Verdict, perf: number) {
inline: true,
},
{
name: "Time",
name: "Time Used",
value: `${result.limits.time} ms`,
inline: true,
},
{
name: "Memory",
name: "Memory Used",
value: `${result.limits.mem} KB`,
inline: true,
},
Expand Down
59 changes: 41 additions & 18 deletions src/bot/commands/slash/getstatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,49 @@ export const getstatement: CocoaSlash = {
return;
}

const embed = new Embed()
.setAuthor(Author(ctx))
.setTitle(Problem.title)
.setDescription(Problem.description)
.addFields(
{
name: "Problem ID",
value: problem_name,
inline: true,
},
{
name: "Time Limit",
value: `${Problem.timelimit} seconds`,
inline: true,
},
{
name: "Memory Limit",
value: `${Problem.memorylimit} MB`,
inline: true,
},
{
name: "Subtasks",
value: `${Object.keys(Problem.subtasks).length}`,
inline: true,
},
{
name: "Max Score",
value: `${Problem.maxScore ?? 100}`,
inline: true,
},
{
name: "Statement",
value: `[Click](${Problem.statement})`,
inline: true,
}
)
.setColor(Cocoa.Color)
.setThumbnail(Cocoa.GIF.CoffeeNomu)
.setFooter(Cocoa.Footer(ctx));

if (Problem.statement)
await ctx.reply({
embeds: [
new Embed()
.setAuthor(Author(ctx))
.setTitle(Problem.title)
.setDescription(
`ID: ${problem_name}\nDescription: ${
Problem.description
}\nStatement: ${
Problem.statement
? `[Click Here](${Problem.statement}`
: "Does not exist"
})`
)
.setColor(Cocoa.Color)
.setThumbnail(Cocoa.GIF.CoffeeNomu)
.setFooter(Cocoa.Footer(ctx))
.toJSON(),
],
embeds: [embed.toJSON()],
});
else await ctx.reply("Sorry, this problem doesn't have statement");
},
Expand Down
7 changes: 6 additions & 1 deletion src/grader/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { writeFile } from "fs/promises";

import { exec } from "./grader";

export type SupportedLang = "C" | "C++" | "Python" | "JavaScript";
export type SupportedLang = "C" | "C++" | "Python" | "JavaScript" | "Haskell";

export function getLang(str: string): SupportedLang | "Unsupported" {
if (str == "cpp" || str == "c++" || str == "cc") return "C++";
if (str == "c") return "C";
if (str == "hs" || str == "haskell") return "Haskell";
if (str == "js" || str == "javascript") return "JavaScript";
if (str.startsWith("py")) return "Python";
return "Unsupported";
Expand All @@ -16,6 +17,7 @@ export function getLang(str: string): SupportedLang | "Unsupported" {
const extensions = {
C: "c",
"C++": "cpp",
Haskell: "hs",
JavaScript: "js",
Python: "py",
};
Expand All @@ -42,6 +44,9 @@ export async function Compile(
`g++ temp/${id}.cpp -o temp/${id} -std=c++17 -O2 -lm`
);
break;
case "Haskell":
await exec(`ghc temp/${id}.hs -o temp/${id}`);
break;
case "JavaScript":
// Do Nothing Lmao
break;
Expand Down

0 comments on commit 0af226f

Please sign in to comment.