-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
GitHub Referencing & GitHub Command #599
Conversation
…em/BotCore.java Co-authored-by: Tanish Azad <[email protected]>
I LOVE YOU ILLU |
what about not having the ping when the bot replies back? |
why? |
coz its a bot reply |
@Tais993 what do you think? |
Don't have an opinion, either is fine to me |
I'll remove it since the command usage also has no ping I guess |
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java
Outdated
Show resolved
Hide resolved
note that this requires that people update their api key settings. gonna mention that when merging this. |
if (title.isEmpty()) { | ||
event.replyChoiceStrings(autocompleteCache.stream().limit(25).toList()).queue(); | ||
} else { | ||
Queue<String> queue = new PriorityQueue<>(Comparator.comparingInt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name isnt really optimal. maybe closestMatches
or closestSuggestions
.
it also reads a bit complex since u nested everything. i would at least move out the 25-list into a variable:
Queue<String> closestMatches = ...
List<String> suggestions = ...
event.replyChoiceStrings(suggestions).queue();
maybe also the logic u use to compute the score. So that its Comparator.comparingInt(this::scoreSuggestion)
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could u also move the Stream.generate(closestSuggestions::poll).limit(25).toList()
into its own variable? Its a bit harder to read when its all packed together with the JDA stuff of message-sending.
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubCommand.java
Outdated
Show resolved
Hide resolved
*/ | ||
private List<GHRepository> repositories; | ||
|
||
public GitHubReference(Config config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better, yes. but i still have problems with the term "reference" for this (see other discussion). maybe we can find a better word that has less confusion potential
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java
Show resolved
Hide resolved
} | ||
|
||
/** | ||
* Looks through all of the given repositories for an issue/pr with the given id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing dot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems u forgot to push this one
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubCommand.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java
Outdated
Show resolved
Hide resolved
String title = event.getOption(TITLE_OPTION).getAsString(); | ||
|
||
if (title.isEmpty()) { | ||
event.replyChoiceStrings(autocompleteGHIssueCache.stream().limit(25).toList()).queue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use the magic number 25
use OptionData#MAX_CHOICES instead
|
||
closestSuggestions.addAll(autocompleteGHIssueCache); | ||
|
||
event.replyChoiceStrings(Stream.generate(closestSuggestions::poll).limit(25).toList()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use the magic number 25
use OptionData#MAX_CHOICES instead
Co-authored-by: Tanish Azad <[email protected]>
…ub/GitHubCommand.java Co-authored-by: Tanish Azad <[email protected]>
…ub/GitHubReference.java Co-authored-by: Tanish Azad <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
"helpSystem": { | ||
"stagingChannelPattern": "ask_here", | ||
"overviewChannelPattern": "active_questions", | ||
"categories": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the indent for categories is one level too much
event | ||
.replyChoiceStrings(autocompleteCache.stream() | ||
.sorted(Comparator.comparingInt(s -> StringDistances.editDistance(title, | ||
s.replaceFirst("\\[\\d+] ", "")))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method is good, thanks for that. but i would still like to have a small comment on the regex. like // Remove the ID [#123] and then match
application/src/main/java/org/togetherjava/tjbot/commands/github/GitHubReference.java
Show resolved
Hide resolved
if (title.isEmpty()) { | ||
event.replyChoiceStrings(autocompleteCache.stream().limit(25).toList()).queue(); | ||
} else { | ||
Queue<String> queue = new PriorityQueue<>(Comparator.comparingInt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could u also move the Stream.generate(closestSuggestions::poll).limit(25).toList()
into its own variable? Its a bit harder to read when its all packed together with the JDA stuff of message-sending.
protected static final Pattern ISSUE_REFERENCE_PATTERN = Pattern.compile("#(?<id>\\d+)"); | ||
protected static final String ID_GROUP = "id"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotta use the ID_GROUP in ur pattern as well. "#(?<%s>\\d+".formatted(ID_GROUP)
} | ||
|
||
/** | ||
* Looks through all of the given repositories for an issue/pr with the given id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems u forgot to push this one
One year anniversary of this PR 🎉 |
#981 which continued work of this PR already merged. |
changes
gistApiKey
togithubApiKey
in the config