-
-
Notifications
You must be signed in to change notification settings - Fork 89
Added ComponentIdInteractor delegate #588
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
Zabuzard
merged 6 commits into
develop
from
feature/simplify_user_interactor_without_adapter
Oct 13, 2022
Merged
Added ComponentIdInteractor delegate #588
Zabuzard
merged 6 commits into
develop
from
feature/simplify_user_interactor_without_adapter
Oct 13, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(FYI @SquidXTV ) |
Tais993
reviewed
Sep 29, 2022
...cation/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdInteractor.java
Outdated
Show resolved
Hide resolved
d6050af
to
f9fa20d
Compare
f9fa20d
to
de388e7
Compare
Tais993
reviewed
Oct 4, 2022
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 issue with the prefix enum before was that the component ID generation needed the prefixed name.
But that still is the case, so what have you actually changed?
application/src/main/java/org/togetherjava/tjbot/commands/BotCommandAdapter.java
Outdated
Show resolved
Hide resolved
...cation/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdInteractor.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/BotCommandAdapter.java
Show resolved
Hide resolved
...cation/src/main/java/org/togetherjava/tjbot/commands/componentids/ComponentIdInteractor.java
Outdated
Show resolved
Hide resolved
ae179f9
to
0f0832c
Compare
Kudos, SonarCloud Quality Gate passed! |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This adds a new class called
ComponentIdInteractor
, which effectively is a delegate-pattern solution to provide component-ID generation based out of a class that can be used as delegate for composition, instead of relying on the existingBotCommandAdapter
inheritance.Essentially, the existing code to generate component IDs has been moved out of
BotCommandAdapter
into this class instead.BotCommandAdapter
now delegates toComponentIdInteractor
for this functionality.Advantage
The benefit is that non-
BotCommand
classes, in particularRoutine
s can now easily access this functionality as well. For example, a routine might now easily create buttons like this:Redesign prefix
While at it, the whole topic with
UserInteractorPrefix
was redesigned. It is now essentially renamed toUserInteractionType
and will not only be used for prefixes, but essentailly just represents the type of interaction.This is then used by
BotCore
for prefix-based-forwarding. Implementations ofUserInteractor
now have to explicitly tell their type instead of the system being based on the classes and reflection.This gives maximum flexibility. At the same time, it is still convenient though, since everything is hidden behind the adapters for 99% of the use cases.
BotCommandAdapter
now auto-infers the type based on the JDA command types, for the commands its responsible for (slash, user context, message context).Checklist
ScamBlocker
use the delegate