Skip to content
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

434 leetcode for codey #455

Merged
merged 8 commits into from
Mar 5, 2023
Merged

434 leetcode for codey #455

merged 8 commits into from
Mar 5, 2023

Conversation

mcpenguin
Copy link
Collaborator

Summary of Changes

Added commands for leetcode:

.leetcode / .leetcode random [difficulty] [tag] -> Generates a random Leetcode problem with an optional filter for difficulty and tag.
.leetcode specific [problem id] -> Generates a Leetcode problem with specified ID.

Motivation and Explanation

Leetcode Bot became broken - this functionality should replace it.

Related Issues

Resolves #434

Steps to Reproduce

Use the commands specified above.

Demonstration of Changes

image
image
image
image

Further Information and Comments

  • The Leetcode "API" might take longer than 3 seconds to run, which is the timeout for slash commands. So, instead of sending the problem via the original command, we send it as a followup message using the afterMessageReply functionality.
  • The command is significantly faster for a search for a random problem or by a specific id compared to using filters.

Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments.

problemId = problemIds[index];
}
const problemData = await getLeetcodeProblemDataFromId(problemId);
const content = getMessageForLeetcodeProblem(problemData).slice(0, 2000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to send multiple messages instead of just truncating the message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending multiple messages might look weird if the truncation occurs in a weird spot, eg in the middle of a word.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fair. I guess it might potentially mess up code blocks and equations as well, in which it might be more effort than what it is worth to detect them.

src/commands/leetcode/leetcode.ts Outdated Show resolved Hide resolved
src/components/leetcode.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcpenguin mcpenguin merged commit 2151c5e into main Mar 5, 2023
@mcpenguin mcpenguin deleted the 434-leetcode-for-codey branch March 5, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorporate Leetcode into Codey
2 participants